Fix discarding significant characters

This commit is contained in:
Wilson Lin 2020-01-06 19:53:46 +11:00
parent 0edea36920
commit 3ecfe2b41f
5 changed files with 8 additions and 7 deletions

View File

@ -323,6 +323,8 @@ However, there are some syntax requirements for speed and sanity reasons.
Tag names are case sensitive. For example, this means that `P` won't be recognised as a content element, `bR` won't be considered as a void tag, and the contents of `Script` won't be parsed as JavaScript.
[Tags must not be omitted.](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission)
### Entities
Well-formed entities are decoded, including in attribute values.

View File

@ -5,7 +5,7 @@ pub fn process_bang(proc: &mut Processor) -> ProcessingResult<()> {
if cfg!(debug_assertions) {
chain!(proc.match_seq(b"<!").expect().keep());
} else {
proc.skip_amount_expect(2);
proc.accept_amount_expect(2);
};
chain!(proc.match_while_not_char(b'>').keep());

View File

@ -65,7 +65,7 @@ macro_rules! handle_content_type {
};
}
pub fn process_wss_content(proc: &mut Processor) -> ProcessingResult<()> {
fn process_wss_content(proc: &mut Processor) -> ProcessingResult<()> {
loop {
handle_content_type!(proc, ContentType::peek(proc), { parse_entity(proc, false)?.keep(proc); }, { proc.accept()?; });
};

View File

@ -9,7 +9,7 @@ fn parse_comment_single(proc: &mut Processor) -> ProcessingResult<()> {
if cfg!(debug_assertions) {
chain!(proc.match_seq(b"//").expect().keep());
} else {
proc.skip_amount_expect(2);
proc.accept_amount_expect(2);
};
// Comment can end at closing </script>.
@ -29,7 +29,7 @@ fn parse_comment_multi(proc: &mut Processor) -> ProcessingResult<()> {
if cfg!(debug_assertions) {
chain!(proc.match_seq(b"/*").expect().keep());
} else {
proc.skip_amount_expect(2);
proc.accept_amount_expect(2);
};
// Comment can end at closing </script>.
@ -82,7 +82,7 @@ fn parse_template(proc: &mut Processor) -> ProcessingResult<()> {
if cfg!(debug_assertions) {
chain!(proc.match_char(b'`').expect().keep());
} else {
proc.skip_expect();
proc.accept_expect();
};
let mut escaping = false;

View File

@ -48,12 +48,11 @@ pub fn process_tag(proc: &mut Processor) -> ProcessingResult<()> {
if cfg!(debug_assertions) {
chain!(proc.match_char(b'<').expect().keep());
} else {
proc.skip_expect();
proc.accept_expect();
};
// May not be valid tag name at current position, so require instead of expect.
let opening_name_range = chain!(proc.match_while_pred(is_valid_tag_name_char).require_with_reason("tag name")?.keep().out_range());
// TODO DOC: Tags must be case sensitive.
let tag_type = match &proc[opening_name_range] {
b"script" => TagType::Script,
b"style" => TagType::Style,