Skip to content

Commit f6d0835

Browse files
committed
JS: Show problem with new RegExp().exec()
1 parent ef833de commit f6d0835

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • javascript/ql/test/query-tests/Security/CWE-601/ClientSideUrlRedirect

javascript/ql/test/query-tests/Security/CWE-601/ClientSideUrlRedirect/tst.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ window.location = /.*redirect=([^&]*).*/.exec(document.location.href)[1];
66
window.location = indirect.exec(document.location.href)[1];
77
});
88

9-
// NOT OK
9+
// NOT OK [INCONSISTENCY]
1010
window.location = new RegExp('.*redirect=([^&]*).*').exec(document.location.href)[1];
1111

1212
(function(){
1313
var indirect = new RegExp('.*redirect=([^&]*).*')
1414
window.location = indirect.exec(document.location.href)[1];
1515
});
1616

17-
// NOT OK
17+
// NOT OK [INCONSISTENCY]
1818
window.location = new RegExp(/.*redirect=([^&]*).*/).exec(document.location.href)[1];
1919

2020
(function(){
@@ -23,7 +23,7 @@ window.location = new RegExp(/.*redirect=([^&]*).*/).exec(document.location.href
2323
});
2424

2525
function foo(win) {
26-
win.location.assign(new RegExp(/.*redirect=([^&]*).*/).exec(win.location.href)[1]); // NOT OK
26+
win.location.assign(new RegExp(/.*redirect=([^&]*).*/).exec(win.location.href)[1]); // NOT OK [INCONSISTENCY]
2727
}
2828

29-
foo(window);
29+
foo(window);

0 commit comments

Comments
 (0)