-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fixes #12616: ${const.dollar} in generic method parameter leads to missing report #1930
Conversation
PR rebased |
54cec38
to
a65cda4
Compare
final def replaceCFEngineVars(x : String) : String = { | ||
x.replaceAll(replaceCFEngineVars, ".*").replaceAll("""\\""", """\\\\""") | ||
final def replaceCFEngineVars(x : String) : Pattern = { | ||
Pattern.compile("""\Q"""+ x.replaceAll("""\\""", """\\\\""").replaceAll(replaceCFEngineVars, """\\E.*\\Q""") + """\E""") |
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 don't understand the goal of the "\" => "\\" here. Is it because CFEngine change "" into "\"?
If so, why don't we do it always (not only when the expression contains a cfengine var), because here, only one of the test on "\" passe.
, reports = Repaired("yx\\\\x}") :: Nil | ||
) | ||
|
||
test("""escape '\' into '\\' *without* cfengine vars""" |
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.
This does not passe (the other one above does pass).
PR rebased |
a65cda4
to
3b04655
Compare
*/ | ||
final def replaceCFEngineVars(x : String) : String = { | ||
x.replaceAll(replaceCFEngineVars, ".*").replaceAll("""\\""", """\\\\""") |
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.
The replace all seems to have been here to avoid having "\x" be interpreted as a regex predifined character classes. Now that we correctly quote the regex, we don't need it anymore.
* Returns a string that is suitable for a being used as a regexp | ||
* Returns a string that is suitable for a being used as a regexp, with anything not | ||
* in ".*" quoted with \Q...\E. | ||
* For example, "${foo}(bar)$(baz)foo" => ".*\Q(bar)\E.*\Qfoo\E" |
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.
are you missing the first Q/E in your example ? I think it hsould be: "\Q\E ".\Q(bar)\E.\Qfoo\E"
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.
yes! Sorry
PR rebased |
3b04655
to
97a9e63
Compare
This PR is not mergeable to upper versions. |
OK, merging this PR |
https://www.rudder-project.org/redmine/issues/12616