Skip to content

Commit a487d99

Browse files
committed
Escape highlighting keywords for safe use in regex
Fixes avg( breaking the expression due to an unterminated group
1 parent 411615e commit a487d99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dashboard/js/components/22.angular-smart-area-1.5.0.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ angular.module('smartArea', [])
312312
var cssId = cssClasses.length;
313313
cssClasses.push(autoList.cssClass);
314314
if(typeof(autoList.words[i]) === "string"){
315-
text = text.replace(new RegExp("([^\\w]|\\b)("+autoList.words[i]+")([^\\w]|\\b)", 'g'), '$1§x'+cssId+'x§$2§/x' + cssId + 'x§$3');
315+
text = text.replace(new RegExp("([^\\w]|\\b)("+autoList.words[i].replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')+")([^\\w]|\\b)", 'g'), '$1§x'+cssId+'x§$2§/x' + cssId + 'x§$3');
316316
}else{
317317
text = text.replace(autoList.words[i], function(match){
318318
return '§x' + cssId + 'x§'+match+'§/x' + cssId + 'x§';

0 commit comments

Comments
 (0)