Skip to content

Commit

Permalink
Fix sanitization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasminocha committed Jul 10, 2022
1 parent 0e0f1fb commit a228f1f
Show file tree
Hide file tree
Showing 4 changed files with 578 additions and 616 deletions.
6 changes: 4 additions & 2 deletions VerbalExpressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ class VerbalExpression extends RegExp {

// Regular expression to match meta characters
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/regexp
const toEscape = /([\].|*?+(){}^$\\:=[])/g;
const toEscape = /[|\\{}()[\]^$+*?.]/g;

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch
const lastMatch = '$&';

// Escape meta characters
return value.replace(toEscape, `\\${lastMatch}`);
return value
.replace(toEscape, `\\${lastMatch}`)
.replace(/-/g, '\\x2d');
}

/**
Expand Down
Loading

0 comments on commit a228f1f

Please sign in to comment.