Skip to content

Commit 689d930

Browse files
zolagonanocanewsin
authored andcommitted
Fix ReDos Varnurablity in codemirror library
1 parent 5eeecc6 commit 689d930

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

UiFileManager/media/codemirror/all.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17366,7 +17366,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
1736617366
var kw = keywords[word]
1736717367
return ret(kw.type, kw.style, word)
1736817368
}
17369-
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
17369+
17370+
// vulnerable code: https://security.snyk.io/vuln/SNYK-JS-CODEMIRROR-1016937
17371+
// if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
17372+
17373+
// Fix: https://github.com/codemirror/codemirror5/blob/a0854c752a76e4ba9512a9beedb9076f36e4f8f9/mode/javascript/javascript.js#L130C36-L130C36
17374+
if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
1737017375
return ret("async", "keyword", word)
1737117376
}
1737217377
return ret("variable", "variable", word)

UiFileManager/media/codemirror/mode/javascript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
126126
var kw = keywords[word]
127127
return ret(kw.type, kw.style, word)
128128
}
129-
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
129+
// vulnerable code: https://security.snyk.io/vuln/SNYK-JS-CODEMIRROR-1016937
130+
//if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
131+
132+
// Fix: https://github.com/codemirror/codemirror5/blob/a0854c752a76e4ba9512a9beedb9076f36e4f8f9/mode/javascript/javascript.js#L130C36-L130C36
133+
if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
130134
return ret("async", "keyword", word)
131135
}
132136
return ret("variable", "variable", word)

0 commit comments

Comments
 (0)