mirror of
https://github.com/swc-project/swc.git
synced 2024-11-27 13:38:33 +03:00
fix(html/lexer): Fix lexing of html entity (#4423)
This commit is contained in:
parent
09565a3533
commit
9b26dbd457
33
crates/swc_html_minifier/tests/fixture/text/input.html
Normal file
33
crates/swc_html_minifier/tests/fixture/text/input.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id = "John"&Harry">Test</div>
|
||||
<div id = 'John"&HarryOther'>Test</div>
|
||||
<div id = 'John"<HarryOtherOther'>Test</div>
|
||||
<div id = 'John HarryOtherOtherOther'>Test</div>
|
||||
<div id = 'John<test>'>Test</div>
|
||||
<div id = 'JohnTest'>Test</div>
|
||||
|
||||
<div> Registered Trademark Symbol: </div>
|
||||
|
||||
<div>HTML Entities demo: </div>
|
||||
|
||||
<p>®</p>
|
||||
<p>©</p>
|
||||
<p>©</p>
|
||||
|
||||
<p> This Registered Trademark is a Script used in HTML document. </p>
|
||||
|
||||
<div>I want to display <br> tag</div>
|
||||
|
||||
<div>I want to display <i> tag</div>
|
||||
|
||||
<div>The cent sign: ¢</div>
|
||||
<div>The cent sign: ¢</div>
|
||||
|
||||
</body>
|
||||
</html>
|
31
crates/swc_html_minifier/tests/fixture/text/output.min.html
Normal file
31
crates/swc_html_minifier/tests/fixture/text/output.min.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html><html lang=en><head>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id='John"&Harry'>Test</div>
|
||||
<div id='John"&HarryOther'>Test</div>
|
||||
<div id='John"<HarryOtherOther'>Test</div>
|
||||
<div id=John HarryOtherOtherOther>Test</div>
|
||||
<div id="John<test>">Test</div>
|
||||
<div id=JohnTest>Test</div>
|
||||
|
||||
<div> Registered Trademark Symbol: </div>
|
||||
|
||||
<div>HTML Entities demo: </div>
|
||||
|
||||
<p>®</p>
|
||||
<p>©</p>
|
||||
<p>©</p>
|
||||
|
||||
<p> This Registered Trademark is a Script used in HTML document. </p>
|
||||
|
||||
<div>I want to display <br> tag</div>
|
||||
|
||||
<div>I want to display <i> tag</div>
|
||||
|
||||
<div>The cent sign: ¢</div>
|
||||
<div>The cent sign: ¢</div>
|
||||
|
||||
|
||||
</body></html>
|
@ -5073,13 +5073,12 @@ where
|
||||
|
||||
if let Some(found_entity) = found_entity {
|
||||
cur_pos = Some(self.input.cur_pos());
|
||||
|
||||
entity = Some(found_entity);
|
||||
}
|
||||
|
||||
// We stop when:
|
||||
// - not ascii alphabetic
|
||||
// - we consume more characters them the longest entity
|
||||
// - we consume more characters than the longest entity
|
||||
if !c.is_ascii_alphabetic() || temporary_buffer.len() > 33 {
|
||||
if let Some(cur_pos) = cur_pos {
|
||||
self.input.reset_to(cur_pos);
|
||||
@ -5138,7 +5137,7 @@ where
|
||||
// Flush code points consumed as a character reference. Switch to the
|
||||
// return state.
|
||||
else {
|
||||
if is_last_semicolon {
|
||||
if !is_last_semicolon {
|
||||
self.emit_error(ErrorKind::MissingSemicolonAfterCharacterReference);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user