Skip to content

Commit

Permalink
Fixed bug where intermediate string contains escaped characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcholio committed Oct 29, 2021
1 parent 13651ea commit 1155582
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/unescape.js
Expand Up @@ -2,12 +2,12 @@ import assertString from './util/assertString';

export default function unescape(str) {
assertString(str);
return (str.replace(/&/g, '&')
.replace(/"/g, '"')
return (str.replace(/"/g, '"')
.replace(/'/g, "'")
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&#x2F;/g, '/')
.replace(/&#x5C;/g, '\\')
.replace(/&#96;/g, '`'));
.replace(/&#96;/g, '`')
.replace(/&amp;/g, '&'));
}
3 changes: 3 additions & 0 deletions test/sanitizers.js
Expand Up @@ -184,6 +184,9 @@ describe('Sanitizers', () => {

'Backtick: &#96;':
'Backtick: `',

'Escaped string: &amp;lt;':
'Escaped string: &lt;',
},
});
});
Expand Down

0 comments on commit 1155582

Please sign in to comment.