Skip to content

Commit

Permalink
Fix XSS logic that matched some valid urls (#2529)
Browse files Browse the repository at this point in the history
* Fix XSS logic that matched some valid urls, e.g. "/one/?foo=bar", when it shouldn't match those
  • Loading branch information
yasuf committed Nov 8, 2019
1 parent bbfd5b1 commit 8414664
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/helpers/isValidXss.js
@@ -1,6 +1,7 @@
'use strict';

module.exports = function isValidXss(requestURL) {
var xssRegex = /(\b)(on\S+)(\s*)=|javascript|(<\s*)(\/*)script/gi;
var xssRegex = /(\b)(on\w+)=|javascript|(<\s*)(\/*)script/gi;
return xssRegex.test(requestURL);
};

1 change: 1 addition & 0 deletions test/specs/helpers/isValidXss.spec.js
Expand Up @@ -12,6 +12,7 @@ describe('helpers::isValidXss', function () {
});

it('should not detect non script tags', function() {
expect(isValidXss("/one/?foo=bar")).toBe(false);
expect(isValidXss("<safe> tags")).toBe(false);
expect(isValidXss("<safetag>")).toBe(false);
expect(isValidXss(">>> safe <<<")).toBe(false);
Expand Down

0 comments on commit 8414664

Please sign in to comment.