mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 14:56:33 +03:00
fix: preserve upper-/lowercase of links parsed by dehtml() (#5362)
this PR fixes a bug that lowercases all links handleld by `dehtml()`, which is wrong. closes #5361
This commit is contained in:
@@ -301,7 +301,7 @@ fn dehtml_starttag_cb<B: std::io::BufRead>(
|
|||||||
let href = href
|
let href = href
|
||||||
.decode_and_unescape_value(reader)
|
.decode_and_unescape_value(reader)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_lowercase();
|
.to_string();
|
||||||
|
|
||||||
if !href.is_empty() {
|
if !href.is_empty() {
|
||||||
dehtml.last_href = Some(href);
|
dehtml.last_href = Some(href);
|
||||||
@@ -463,6 +463,13 @@ mod tests {
|
|||||||
assert_eq!(plain, "[text](url)");
|
assert_eq!(plain, "[text](url)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_dehtml_case_sensitive_link() {
|
||||||
|
let html = "<html><A HrEf=\"https://foo.bar/Data\">case in URLs matter</A></html>";
|
||||||
|
let plain = dehtml(html).unwrap().text;
|
||||||
|
assert_eq!(plain, "[case in URLs matter](https://foo.bar/Data)");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_dehtml_bold_text() {
|
fn test_dehtml_bold_text() {
|
||||||
let html = "<!DOCTYPE name [<!DOCTYPE ...>]><!-- comment -->text <b><?php echo ... ?>bold</b><![CDATA[<>]]>";
|
let html = "<!DOCTYPE name [<!DOCTYPE ...>]><!-- comment -->text <b><?php echo ... ?>bold</b><![CDATA[<>]]>";
|
||||||
|
|||||||
Reference in New Issue
Block a user