File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
javascript/ql/test/query-tests/Security/CWE-116/DoubleEscaping Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 6
6
| tst.js:60:7:60:28 | s.repla ... '%25') | This replacement may double-escape '%' characters from $@. | tst.js:59:7:59:28 | s.repla ... '%26') | here |
7
7
| tst.js:68:10:70:38 | s.repla ... &") | This replacement may double-escape '&' characters from $@. | tst.js:68:10:69:39 | s.repla ... apos;") | here |
8
8
| tst.js:79:10:79:66 | s.repla ... &") | This replacement may double-escape '&' characters from $@. | tst.js:79:10:79:43 | s.repla ... epl[c]) | here |
9
+ | tst.js:99:10:101:49 | s.repla ... &") | This replacement may double-escape '&' characters from $@. | tst.js:99:10:100:51 | s.repla ... apos;") | here |
Original file line number Diff line number Diff line change @@ -94,3 +94,21 @@ function testWithCapturedVar(x) {
94
94
function encodeDecodeEncode ( s ) {
95
95
return goodEncode ( goodDecode ( goodEncode ( s ) ) ) ;
96
96
}
97
+
98
+ function badEncode ( s ) {
99
+ return s . replace ( new RegExp ( "\"" , "g" ) , """ )
100
+ . replace ( new RegExp ( "\'" , "g" ) , "'" )
101
+ . replace ( new RegExp ( "&" , "g" ) , "&" ) ; // NOT OK
102
+ }
103
+
104
+ function goodEncode ( s ) {
105
+ return s . replace ( new RegExp ( "\"" , "" ) , """ )
106
+ . replace ( new RegExp ( "\'" , "" ) , "'" )
107
+ . replace ( new RegExp ( "&" , "" ) , "&" ) ; // OK
108
+ }
109
+
110
+ function goodEncode ( s ) {
111
+ return s . replace ( new RegExp ( "\"" , unknownFlags ( ) ) , """ )
112
+ . replace ( new RegExp ( "\'" , unknownFlags ( ) ) , "'" )
113
+ . replace ( new RegExp ( "&" , unknownFlags ( ) ) , "&" ) ; // OK
114
+ }
You can’t perform that action at this time.
0 commit comments