Skip to content

Commit cfc8166

Browse files
committed
fix: bug where pos.width inverted; skip_until_close_tag allocation
1 parent d100084 commit cfc8166

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

litehtml/src/email.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,11 @@ fn skip_until_close_tag(
287287
let open_pattern = format!("<{}", tag_name);
288288

289289
while let Some(&(i, _)) = chars.peek() {
290-
let rest = &html[i..].to_ascii_lowercase();
290+
let rest = &html[i..];
291291

292-
if rest.starts_with(&close_pattern) {
292+
if rest.len() >= close_pattern.len()
293+
&& rest[..close_pattern.len()].eq_ignore_ascii_case(&close_pattern)
294+
{
293295
// Check it's actually a close tag (followed by > or whitespace)
294296
let after = &rest[close_pattern.len()..];
295297
if after.starts_with('>') || after.starts_with(char::is_whitespace) {
@@ -302,7 +304,9 @@ fn skip_until_close_tag(
302304
return;
303305
}
304306
}
305-
} else if rest.starts_with(&open_pattern) {
307+
} else if rest.len() >= open_pattern.len()
308+
&& rest[..open_pattern.len()].eq_ignore_ascii_case(&open_pattern)
309+
{
306310
let after = &rest[open_pattern.len()..];
307311
if after.starts_with('>')
308312
|| after.starts_with(char::is_whitespace)

litehtml/src/pixbuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl DocumentContainer for PixbufContainer {
447447
let mut buffer = cosmic_text::Buffer::new(&mut fs, ct_metrics);
448448
buffer.set_size(
449449
&mut fs,
450-
Some(pos.width.max(f32::MAX / 2.0)),
450+
Some(pos.width.min(f32::MAX / 2.0)),
451451
Some(line_height),
452452
);
453453
buffer.set_text(&mut fs, text, &attrs, Shaping::Advanced);

0 commit comments

Comments
 (0)