Skip to content

Commit

Permalink
inlines: use peek_char_n here
Browse files Browse the repository at this point in the history
Upstream relies on there being a trailing NUL; we do not have the
luxury.
  • Loading branch information
kivikakk committed Mar 28, 2023
1 parent 59a312b commit 3c45d59
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/parser/inlines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,18 +949,18 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'subj> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'subj> {
let c = self.input[self.pos];
if c == b'!' && !self.flags.skip_html_comment {
let c = self.input[self.pos + 1];
if c == b'-' && self.input[self.pos + 2] == b'-' {
if self.input[self.pos + 3] == b'>' {
if c == b'-' && self.peek_char_n(2) == Some(&b'-') {
if self.peek_char_n(3) == Some(&b'>') {
matchlen = Some(4);
} else if self.input[self.pos + 3] == b'-' && self.input[self.pos + 4] == b'>' {
} else if self.peek_char_n(3) == Some(&b'-') && self.peek_char_n(4) == Some(&b'>') {
matchlen = Some(5);
} else if let Some(m) = scanners::html_comment(&self.input[self.pos + 1..]) {
matchlen = Some(m + 1);
} else {
self.flags.skip_html_comment = true;
}
} else if c == b'[' {
if !self.flags.skip_html_cdata {
if !self.flags.skip_html_cdata && self.pos + 3 <= self.input.len() {
if let Some(m) = scanners::html_cdata(&self.input[self.pos + 2..]) {
// The regex doesn't require the final "]]>". But if we're not at
// the end of input, it must come after the match. Otherwise,
Expand Down

0 comments on commit 3c45d59

Please sign in to comment.