Skip to content

Commit 1155582

Browse files
committed
Fixed bug where intermediate string contains escaped characters
1 parent 13651ea commit 1155582

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/lib/unescape.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import assertString from './util/assertString';
22

33
export default function unescape(str) {
44
assertString(str);
5-
return (str.replace(/&/g, '&')
6-
.replace(/"/g, '"')
5+
return (str.replace(/"/g, '"')
76
.replace(/'/g, "'")
87
.replace(/&lt;/g, '<')
98
.replace(/&gt;/g, '>')
109
.replace(/&#x2F;/g, '/')
1110
.replace(/&#x5C;/g, '\\')
12-
.replace(/&#96;/g, '`'));
11+
.replace(/&#96;/g, '`')
12+
.replace(/&amp;/g, '&'));
1313
}

test/sanitizers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ describe('Sanitizers', () => {
184184

185185
'Backtick: &#96;':
186186
'Backtick: `',
187+
188+
'Escaped string: &amp;lt;':
189+
'Escaped string: &lt;',
187190
},
188191
});
189192
});

0 commit comments

Comments
 (0)