Open sigil66 opened 6 years ago
The syntax doesn't seem to support a way of encoding a single backslash?
Thanks for reporting this, @sigil66!
This looks like a parser bug. It is indeed intended that the extra backslash would be removed here.
The relevant part of the code is here:
I'm not sure yet what's causing this but I'll dig into this some more soon.
Hi again, @sigil66!
Looking at this again with fresh eyes, I think the string is actually as expected, and it's actually just the dump syntax (is that go-spew
?) that is making it seem incorrect:
Pattern: (string) (len=13) "^whatever\\/.*$",
This line is using Go's own string quoting syntax. If we peel that off by removing the quotes and processing all the escapes, I think the string looks like this:
^whatever\/.*$
Does that seem right? This could be confirmed by printing out the string alone, rather than printing it out as part of a larger dump in quotes.
I don't think so, as I encountered the issue trying to pass parsed string to utilize in a go regex match which generated the original error.
I can provide the offending code if this helps.
If you have a small reproduction case then I'd be happy to take a look at it!
Given the following string in HCL2 the \ required to parse \/:
"^whatever\\/.*$"
When decoding with gohcl into a struct the resulting string within the struct still contains the extra \
I would expect that the when decoding the string escape is removed?