Skip to content

Commit aa60883

Browse files
committed
[feat] add test unit for style html entity decode
1 parent 6cf9e53 commit aa60883

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/compiler/parse/utils/__test__.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,30 @@ describe('decode_character_references', () => {
298298
assert.equal(value, input);
299299
});
300300

301+
it('escape character in attribute 1', () => {
302+
// doesn't decode '&rect' which isn't html entity
303+
const input = '<div style="background-image: url(https://url.com/path?lib=test&height=902&width=1500&rect=type1);"></div>';
304+
const expect = '<div style="background-image: url(https://url.com/path?lib=test&height=902&width=1500&rect=type1);"></div>';
305+
const value = decode_character_references(input);
306+
assert.equal(value, expect);
307+
});
308+
309+
it('escape character in attribute 2', () => {
310+
// '&rect;' decode to ▭ which is html entity
311+
const input = '<div style="background-image: url(https://url.com/path?lib=test&height=902&width=1500&rect;=type1);"></div>';
312+
const expect = '<div style="background-image: url(https://url.com/path?lib=test&height=902&width=1500▭=type1);"></div>';
313+
const value = decode_character_references(input);
314+
assert.equal(value, expect);
315+
});
316+
317+
it('escape character in attribute 3', () => {
318+
// '&amp' decode to & which is html entity
319+
const input = '<div style="background-image: url(https://url.com/path?lib=test&height=902&width=1500&amp=type1);"></div>';
320+
const expect = '<div style="background-image: url(https://url.com/path?lib=test&height=902&width=1500&=type1);"></div>';
321+
const value = decode_character_references(input);
322+
assert.equal(value, expect);
323+
});
324+
301325
it('validate code 1', () => {
302326
// line feed becomes generic whitespace
303327
const input = '&#10;';

0 commit comments

Comments
 (0)