mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Fix #1373, ignore incorrect html close tags
This commit is contained in:
@@ -35,6 +35,7 @@ pub fn dehtml(buf: &str) -> String {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut reader = quick_xml::Reader::from_str(buf);
|
let mut reader = quick_xml::Reader::from_str(buf);
|
||||||
|
reader.check_end_names(false);
|
||||||
|
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
||||||
@@ -225,4 +226,23 @@ mod tests {
|
|||||||
"<>\"\'& äÄöÖüÜß fooÆçÇ \u{2666}\u{200e}\u{200f}\u{200c}&noent;\u{200d}"
|
"<>\"\'& äÄöÖüÜß fooÆçÇ \u{2666}\u{200e}\u{200f}\u{200c}&noent;\u{200d}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unclosed_tags() {
|
||||||
|
let input = r##"
|
||||||
|
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
|
||||||
|
'http://www.w3.org/TR/html4/loose.dtd'>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hi</title>
|
||||||
|
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
lots of text
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"##;
|
||||||
|
let txt = dehtml(input);
|
||||||
|
assert_eq!(txt.trim(), "lots of text");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user