Compare commits

..

No commits in common. "acd590111edf9842346d7bb77fa1a42f6e00068d" and "79ed24135fcd07637e46cdfc30f9d987d14e7984" have entirely different histories.

7 changed files with 40 additions and 90 deletions

10
Cargo.lock generated
View File

@ -3001,7 +3001,7 @@ dependencies = [
[[package]]
name = "letterbox-notmuch"
version = "0.10.10"
version = "0.10.9"
dependencies = [
"itertools",
"log",
@ -3016,14 +3016,14 @@ dependencies = [
[[package]]
name = "letterbox-procmail2notmuch"
version = "0.10.10"
version = "0.10.9"
dependencies = [
"anyhow",
]
[[package]]
name = "letterbox-server"
version = "0.10.10"
version = "0.10.9"
dependencies = [
"ammonia",
"anyhow",
@ -3065,7 +3065,7 @@ dependencies = [
[[package]]
name = "letterbox-shared"
version = "0.10.10"
version = "0.10.9"
dependencies = [
"build-info",
"letterbox-notmuch",
@ -3074,7 +3074,7 @@ dependencies = [
[[package]]
name = "letterbox-web"
version = "0.10.10"
version = "0.10.9"
dependencies = [
"build-info",
"build-info-build",

View File

@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
edition = "2021"
license = "UNLICENSED"
publish = ["xinu"]
version = "0.10.10"
version = "0.10.9"
repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev]

View File

@ -47,8 +47,8 @@ urlencoding = "2.1.3"
#xtracing = { path = "../../xtracing" }
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
xtracing = { version = "0.3.0", registry = "xinu" }
letterbox-notmuch = { version = "0.10.10", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.10.10", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.10.9", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.10.9", path = "../shared", registry = "xinu" }
[build-dependencies]
build-info-build = "0.0.40"

View File

@ -441,38 +441,6 @@ pub fn sanitize_html(
}
};
let mut element_content_handlers = vec![
// Remove width and height attributes on elements
element!("[width],[height]", |el| {
println!("width or height {el:?}");
el.remove_attribute("width");
el.remove_attribute("height");
Ok(())
}),
// Remove width and height values from inline styles
element!("[style]", |el| {
println!("style {el:?}");
let style = el.get_attribute("style").unwrap();
let style = style
.split(";")
.filter(|s| {
println!("s {s}");
let Some((k, _)) = s.split_once(':') else {
return true;
};
match k {
"width" | "max-width" | "min-width" | "height" | "max-height"
| "min-height" => false,
_ => true,
}
})
.collect::<Vec<_>>()
.join(";");
println!("style: {style}");
if let Err(e) = el.set_attribute("style", &style) {
error!("Failed to set style attribute: {e}");
}
Ok(())
}),
// Open links in new tab
element!("a[href]", |el| {
el.set_attribute("target", "_blank").unwrap();
@ -945,21 +913,3 @@ async fn clean_title(title: &str) -> Result<String, ServerError> {
}
Ok(title)
}
#[cfg(test)]
mod tests {
use super::{SanitizeHtml, Transformer};
#[tokio::test]
async fn strip_sizes() -> Result<(), Box<dyn std::error::Error>> {
let ss = SanitizeHtml {
cid_prefix: "",
base_url: &None,
};
let input = r#"<p width=16 height=16 style="color:blue;width:16px;height:16px;">This el has width and height attributes and inline styles</p>"#;
let want = r#"<p style="color:blue;">This el has width and height attributes and inline styles</p>"#;
let got = ss.transform(&None, input).await?;
assert_eq!(got, want);
Ok(())
}
}

View File

@ -12,5 +12,5 @@ version.workspace = true
[dependencies]
build-info = "0.0.40"
letterbox-notmuch = { version = "0.10.10", path = "../notmuch", registry = "xinu" }
letterbox-notmuch = { version = "0.10.9", path = "../notmuch", registry = "xinu" }
serde = { version = "1.0.147", features = ["derive"] }

View File

@ -33,8 +33,8 @@ wasm-bindgen = "=0.2.100"
uuid = { version = "1.13.1", features = [
"js",
] } # direct dep to set js feature, prevents Rng issues
letterbox-shared = { version = "0.10.10", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.10.10", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.10.9", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.10.9", path = "../notmuch", registry = "xinu" }
seed_hooks = { version = "0.4.0", registry = "xinu" }
strum_macros = "0.27.1"

View File

@ -56,10 +56,10 @@ html {
margin-left: 2em;
}
.mail-thread .noreply-news-bloomberg-com a {
background-color: initial !important;
.mail-thread .noreply-news-bloomberg-com img.logo-image {
width: initial !important;
max-width: 100% !important;
}
.mail-thread .noreply-news-bloomberg-com h2 {
margin: 0 !important;
padding: 0 !important;