You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a custom handler for regular expressions (match(value, regex)) where the regex can be configured from the front-end (web application).
For example, inputting match(variable, "[a-z]\d") would be presented as (when dumping the value) "match(variable, \"[a-z]\\d\")" (which seems correct to me), but when passed to gval, it raises parsing error: match(variable, "[a-z]\d") :1:11 - 1:20 could not parse string: invalid syntax.
If I bypass all of the surrounding code and run it directly as so x, err := gval.Evaluate("match(variable, \"[a-z]\\d\")", map[string]any{"a": "b"}) the error is the same.
Another example would be running this x, err := gval.Evaluate("\"\\\"", map[string]any{"a": "b"}) -- same error in regards to the invalid string (parsing error: "\" :1:1 - 1:4 could not parse string: invalid syntax).
But then, if I do this x, err := gval.Evaluate("\"apple\\banana\"", map[string]any{"a": "b"}), it passes and outputs (when running spew.Dump(x, err))
Am I doing something wrong with my strings, or is this a (un)intentional edge case?
If this needs more investigation I can take a look through the code and propose a fix as well, but I'd appreciate some notes on where would be a good place to start/your suspicions about what's wrong
The text was updated successfully, but these errors were encountered:
Env
This is on
github.com/PaesslerAG/gval v1.2.1
Issue
We have a custom handler for regular expressions (
match(value, regex)
) where the regex can be configured from the front-end (web application).For example, inputting
match(variable, "[a-z]\d")
would be presented as (when dumping the value)"match(variable, \"[a-z]\\d\")"
(which seems correct to me), but when passed to gval, it raisesparsing error: match(variable, "[a-z]\d") :1:11 - 1:20 could not parse string: invalid syntax
.If I bypass all of the surrounding code and run it directly as so
x, err := gval.Evaluate("match(variable, \"[a-z]\\d\")", map[string]any{"a": "b"})
the error is the same.Another example would be running this
x, err := gval.Evaluate("\"\\\"", map[string]any{"a": "b"})
-- same error in regards to the invalid string (parsing error: "\" :1:1 - 1:4 could not parse string: invalid syntax
).But then, if I do this
x, err := gval.Evaluate("\"apple\\banana\"", map[string]any{"a": "b"})
, it passes and outputs (when runningspew.Dump(x, err)
)Conclusion
Am I doing something wrong with my strings, or is this a (un)intentional edge case?
If this needs more investigation I can take a look through the code and propose a fix as well, but I'd appreciate some notes on where would be a good place to start/your suspicions about what's wrong
The text was updated successfully, but these errors were encountered: