-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem defining string with literal '\' #1895
Comments
I think this is a little unintuitive on Spicy's end, but try putting this in a parser. For example, I made this:
Notice that it's Try with some data, I grabbed what came from that issue and escaped it to get:
The escaping is weird because you have to double-escape some things when it goes through bash, but you can see the actual bytes in prints are on the inside of the parens in that issue (so the inside part of Then just shove that into the spicy parser:
That seems like what you want to me, does that seem accurate? EDIT: I just reread and see you're making a function to do that escaping, here's an example of the parser that uses that escaping in order to find the lparen and rparen. Basically,
|
Yeah, this indeed seems like the underlying issue here, Spicy is storing things correctly, but is "overescaping" on output. Compare these two prints:
We should fix this but it probably needs a bit of care to understand when we do need to escape and when not (because string rendering is used in different contexts). |
Hi all, thank you for your swift reactions to this issue. I think I will postpone my attempt at the original escaping issue for LDAP until this issue has been resolved. I don't think I currently have an idea on how to fix this properly. Let me know if you require any more input! Regards Martin |
In relation to the above discussion, I find the following line suspect in the bytes.h: spicy/hilti/runtime/include/types/bytes.h Line 449 in 0e3bc48
I would expect the If a function uses join on bytes that contain special characters there is a risk of them getting escaped implicitly. |
* origin/topic/robin/gh-1895-escaping: Do no longer escape backslashes when printing strings or bytes. Rename `expandEscapes()` to `expandUTF8Escapes`. Introduce style flags for functions rendering values into strings.
Hi team,
I am new to spicy and am not sure if I am doing something wrong or if there is an issue with spicy.
I am trying to attempt to work on zeek/zeek#3955 where I need to implement escaping. In short, I need to escape the character
'('
to the three byte string"\28"
. So this is a literal "\
" and must not be interpreted as an escape code.This made me create an escaping function where I need to define the replacement string
"\28"
but no matter what I try, I can't seem to get this to work. Consider the example script below:I would assume that the variable
b
would be printed on the console as\
but it is printed as\\
(even though it is c++ compliant escaping). Also,e
andf
output\\28
.Trying other type of syntaxes such as:
all either do not compile or give me the double
\\
result.Eventually these double literal slashes also end up in the zeek logs and thus are erroneous.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: