Skip to content

Commit

Permalink
Merge pull request #36 from Neovici/gh35-1
Browse files Browse the repository at this point in the history
35 - Sanitize RegExp input when highlighting suggestions
  • Loading branch information
nomego authored Apr 18, 2019
2 parents ad32975 + ee3514c commit c73cddd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@
"no-use-before-define": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"one-var": "error",
"one-var": [
"error",
{
"var": "always",
"let": "always"
}
],
"one-var-declaration-per-line": [
"error",
"always"
Expand Down
3 changes: 2 additions & 1 deletion paper-autocomplete-chips.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@
continue;
}

result.html = result.text.replace(new RegExp('(' + query + ')', 'ig'), regexpResult);
const escapedQuery = query.replace(/[|\\{}()[\]^$+*?.-]/gu, '\\$&');
result.html = result.text.replace(new RegExp('(' + escapedQuery + ')', 'ig'), regexpResult);
results.push(result);

if (results.length >= maxResults) {
Expand Down

0 comments on commit c73cddd

Please sign in to comment.