Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
// declaration
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
var COLON_REGEX = /^:\s*/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^};])+)/;
var VALUE_REGEX =
/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/;
var SEMICOLON_REGEX = /^[;\s]*/;

// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
Expand Down Expand Up @@ -122,7 +123,7 @@
* @param {RegExp} re
* @return {undefined|Array}
*/
function match(re) {

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with ''' and with many repetitions of '\''.
This
regular expression
that depends on
library input
may run slow on strings starting with '"' and with many repetitions of '\"'.
This
regular expression
that depends on
library input
may run slow on strings starting with 'url(' and with many repetitions of 'url(('.
var m = re.exec(style);
if (!m) return;
var str = m[0];
Expand Down
1 change: 1 addition & 0 deletions test/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const cases = [
"background-image: url('http://example.com/img.png')",
'background: url(http://example.com/img.png) no-repeat',
'background: url("data:image/svg+xml,<svg/>")',
'background: url(data:image/png; base64,abc+/=)',

// vendor prefixes
'background: -webkit-linear-gradient(90deg, black, #111)',
Expand Down