JavaScript: Fix regexes for escaping schemes.

This commit is contained in:
Max Schaefer
2019-10-30 14:15:59 +00:00
parent 4f899a9b0d
commit 61aa075e8d
2 changed files with 8 additions and 3 deletions

View File

@@ -54,11 +54,11 @@ DataFlow::Node getASimplePredecessor(DataFlow::Node nd) {
* into a form described by regular expression `regex`.
*/
predicate escapingScheme(string metachar, string regex) {
metachar = "&" and regex = "&.*;"
metachar = "&" and regex = "&.+;"
or
metachar = "%" and regex = "%.*"
metachar = "%" and regex = "%.+"
or
metachar = "\\" and regex = "\\\\.*"
metachar = "\\" and regex = "\\\\.+"
}
/**

View File

@@ -78,3 +78,8 @@ function badEncodeWithReplacer(s) {
};
return s.replace(/["']/g, (c) => repl[c]).replace(/&/g, "&");
}
// dubious, but out of scope for this query
function badRoundtrip(s) {
return s.replace(/\\\\/g, "\\").replace(/\\/g, "\\\\");
}