-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix template string not serialized with { escaped
#8161
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
Fix template string not serialized with { escaped
#8161
Conversation
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
v1/ast/term.go
Outdated
|
|
||
| errFindNotFound = errors.New("find: not found") | ||
|
|
||
| unescapedLeftCurly = regexp.MustCompile(`([^\\])({)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why capture? Should this not be the same?
| unescapedLeftCurly = regexp.MustCompile(`([^\\])({)`) | |
| unescapedLeftCurly = regexp.MustCompile(`[^\\]{`) |
Hmm looking at this without the (), it does look kind of ambiguous. Is that why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll give Expected "unescaped \\{ left curly brace." but got "unescaped\\{ left curly brace."
i.e. space removed for reasons I didn't care enough about to find out about. I don't like the regex thing either, so I'll see if I can get something else to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out both solutions were flawed, as they would not escape a curly brace at position 0 in a string. Will cook something better up tonight.
srenatus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda feel like we don't need a regex to find a { not preceded by a \. 🤔 But I suppose you have considered alternatives already.
|
@srenatus it was 3 AM, and went with the first thing I could think of. I'll see if there's something cheaper. |
Escaping `{` only at the time of serializtion, which should help
avoid special case treatment of these string values. But if there
is a better approach I haven't thought of, let me know.
Fixes open-policy-agent#8156
Signed-off-by: Anders Eknert <[email protected]>
328e2fc to
b782fa5
Compare
|
@srenatus sorry about the delay.. turns out there is little time for coding when you are alone with two kids. I have just pushed an updated version that doesn't use a regular expression, and while it performs much better, it's more importantly correct. At least for any case I managed to come up with. PTAL, so that we can bump our Regal OPA dep and have a release first thing in the new year 🙂 |
srenatus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…t#8161) Escaping `{` only at the time of serializtion, which should help avoid special case treatment of these string values. But if there is a better approach I haven't thought of, let me know. Fixes open-policy-agent#8156 Signed-off-by: Anders Eknert <[email protected]> (cherry picked from commit b06737b)
Escaping
{only at the time of serializtion, which should help avoid special case treatment of these string values. But if there is a better approach I haven't thought of, let me know.Fixes #8156