mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Fix XSS logic that matched some valid urls (#2529)
* Fix XSS logic that matched some valid urls, e.g. "/one/?foo=bar", when it shouldn't match those
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user