Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
13d30d4
#565: SVG pictures are drawn, with nothing they refer to loaded
vangel76 Nov 5, 2026
7af877c
#565: weigh a drawing as the renderer copies it, inheritance and all
vangel76 Nov 5, 2026
ac66996
#565: a test's drawing without format!
vangel76 Nov 5, 2026
4345b38
#565: refuse what is copied by where it is drawn, instead of estimati…
vangel76 Nov 5, 2026
fb7620c
#565: draw only plain drawings; count the tree usvg made
vangel76 Nov 5, 2026
6f7eee6
#565: draw flat drawings alone, by an allowlist
vangel76 Nov 5, 2026
3b8d224
#565: a test's words without format!
vangel76 Nov 5, 2026
e6a8491
#565: count the segments of a drawing's paths
vangel76 Nov 5, 2026
d5dfbe8
#565: draw a drawing on a thread of its own; count curves as lines
vangel76 Nov 5, 2026
82d697b
#565: only xml:space and xml:lang; bound strokes before usvg reads them
vangel76 Nov 5, 2026
d4c8ac8
#565: merge main
vangel76 Nov 5, 2026
5aad92f
#565: review: a drawing given up on holds the next until its thread ends
vangel76 Nov 5, 2026
aeca97a
Merge remote-tracking branch 'upstream/main' into feat/565-svg-pictures
vangel76 Nov 6, 2026
c35db43
Merge remote-tracking branch 'upstream/main' into feat/565-svg-pictures
vangel76 Nov 6, 2026
fc3dade
#565: refuse a <style> of any namespace, hold no-namespace elements t…
vangel76 Nov 6, 2026
d693e0d
#565: merge main
vangel76 Nov 6, 2026
31f4401
Merge main into feat/565-svg-pictures
vangel76 Nov 10, 2026
8dd50c9
Merge main into feat/565-svg-pictures
vangel76 Nov 12, 2026
01e32e2
Merge main into feat/565-svg-pictures
vangel76 Nov 12, 2026
d208e15
#565: a reply hands over no SVG drawing as a picture
vangel76 Nov 12, 2026
a9a03e0
Merge main into feat/565-svg-pictures
vangel76 Nov 13, 2026
5b3f98d
Merge main into feat/565-svg-pictures
vangel76 Nov 14, 2026
3a00726
#565: keep main's resvg 0.49 in xtask
vangel76 Nov 15, 2026
fa6e150
#565 review: read SVG pictures off the window's thread, bound wide st…
vangel76 Nov 15, 2026
c23b289
Merge main into feat/565-svg-pictures
vangel76 Nov 15, 2026
9546f5e
Merge main into feat/565-svg-pictures
vangel76 Nov 15, 2026
dfb12f7
Weigh every stroke-width declaration of an SVG, not only the first
vangel76 Nov 16, 2026
dcfd595
Refuse prefixed SVG-namespace attributes in pictures; read !important…
vangel76 Nov 16, 2026
97074ae
Merge main into feat/565-svg-pictures
vangel76 Nov 16, 2026
e34b48d
Merge main into feat/565-svg-pictures
vangel76 Nov 17, 2026
aeb75f8
Merge main into #830's branch
benandez Nov 17, 2026
6b79fdc
Merge main into #830's branch
benandez Nov 17, 2026
669ed12
Merge main into feat/565-svg-pictures
benandez Nov 17, 2026
71bc9bc
Merge main into feat/565-svg-pictures
benandez Nov 17, 2026
4dea5c7
Merge main into feat/565-svg-pictures
benandez Nov 17, 2026
a3815cd
i18n: cs catalogue refreshed after merging main
benandez Nov 17, 2026
3317c8d
Merge main into feat/565-svg-pictures
benandez Nov 17, 2026
576f979
Merge main into feat/565-svg-pictures
vangel76 Nov 18, 2026
10995b0
Merge main into feat/565-svg-pictures
vangel76 Nov 19, 2026
aa15572
Merge main into feat/565-svg-pictures
vangel76 Nov 19, 2026
ecb5486
Keep attachment thumbnails to raster pictures after merging main
vangel76 Nov 19, 2026
0b8b9ab
#565: Add Georgian draft for the SVG preview message
vangel76 Nov 19, 2026
0af7768
Merge upstream/main into feat/565-svg-pictures
vangel76 Nov 20, 2026
6b11bfa
test(svg): retain merged file coverage (#565)
vangel76 Nov 21, 2026
8412cd9
#565: correct the SVG privacy rules
vangel76 Nov 21, 2026
c765fdc
Merge main into feat/565-svg-pictures
vangel76 Nov 22, 2026
e4c3892
#565: fuzz SVG when the HTML gate changes
vangel76 Nov 22, 2026
70d5528
Merge main into feat/565-svg-pictures
vangel76 Nov 22, 2026
f5e9569
Merge main into feat/565-svg-pictures
vangel76 Nov 22, 2026
797d8c9
Merge main into feat/565-svg-pictures
vangel76 Nov 30, 2026
bb81ae0
#565: rect corners count in the stroke bound, round weight only for w…
vangel76 Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Fuzz

on:
pull_request:
paths: [fuzz/**, crates/assuan/**, crates/ber/**, crates/dav/**, crates/charset/**, crates/engine/**, crates/ews/**, crates/html/**, crates/i18n/src/**, .github/workflows/fuzz.yml, crates/ical/**, crates/jmap/**, crates/link/**, crates/mime/**, crates/mime-model/**, crates/model/**, crates/proto/**, crates/oab/**, crates/openpgp/**, crates/pst/**, crates/smime/**, crates/spell/**, crates/tnef/**, crates/vcard/**]
paths: [fuzz/**, crates/assuan/**, crates/ber/**, crates/dav/**, crates/charset/**, crates/engine/**, crates/ews/**, crates/html/**, crates/i18n/src/**, .github/workflows/fuzz.yml, crates/ical/**, crates/jmap/**, crates/link/**, crates/mime/**, crates/mime-model/**, crates/model/**, crates/proto/**, crates/oab/**, crates/openpgp/**, crates/pst/**, crates/smime/**, crates/spell/**, crates/tnef/**, crates/ui-egui/src/reading/svg.rs, crates/vcard/**]
schedule:
- cron: '17 4 * * 1'
workflow_dispatch:
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
all="assuan dav_xml dav_answers dav_apply dav_discovery dav_document mime html sheet ical vcard charset link imap smtp po jmap_address jmap_discovery jmap_response jmap_session ews ews_autodiscover ews_ntlm pst oab rtf mailbox_file header_block openpgp openpgp_decrypt smime smime_decrypt pkcs12 tnef spell"
all="assuan dav_xml dav_answers dav_apply dav_discovery dav_document mime html sheet ical vcard charset link imap smtp po jmap_address jmap_discovery jmap_response jmap_session ews ews_autodiscover ews_ntlm pst oab rtf mailbox_file header_block openpgp openpgp_decrypt smime smime_decrypt pkcs12 tnef spell svg"
paths_of() {
case "$1" in
assuan) echo crates/assuan/ ;;
Expand All @@ -60,6 +60,7 @@ jobs:
mime) echo crates/mime/ crates/mime-model/ ;;
openpgp|openpgp_decrypt) echo crates/openpgp/ crates/ber/ ;;
smime|smime_decrypt) echo crates/smime/ crates/model/ crates/ber/ ;;
svg) echo crates/ui-egui/src/reading/svg.rs crates/html/src/data.rs ;;
tnef) echo crates/tnef/ ;;
spell) echo crates/spell/ ;;
pkcs12) echo crates/smime/ crates/ber/ ;;
Expand Down
123 changes: 107 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ ed25519-dalek = { version = "2", default-features = false }
# (which brings BMP, the pictures inside one) for a sender's picture that is a web site's icon
# alone: everything else names the kinds it decodes (`reading::images::KINDS`).
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "ico"] }
# SVG drawings: the pictures of mail that are SVG (#565, `reading::svg`) and the app icon
# (`cargo xtask icon`). Pure Rust (usvg, tiny-skia). None of its features: no text, so no fonts are
# looked for or read, and no decoders of the pictures a drawing may hold, which are never loaded.
resvg = { version = "0.45", default-features = false }
# The path and length syntax of SVG, which resvg reads with (already in the tree): a drawing is measured with it before resvg reads it (`reading::svg`).
svgtypes = "0.15"

# ui
egui = "0.37"
Expand Down
32 changes: 24 additions & 8 deletions apps/mailcraft/src/picture_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
//! Not the address (only its hash: the folder doesn't list what was read), not the message,
//! not who sent it, nothing a server said besides the bytes. The same picture at two addresses
//! is one file.
//! - **Only pictures:** bytes are kept when they begin as a PNG, a JPEG, a GIF or a WebP does
//! (or an ICO, a web site's icon, for a sender's picture: [`Cache::get_as`]) and are no
//! - **Only pictures:** bytes are kept when they begin as a PNG, a JPEG, a GIF, a WebP or an SVG
//! drawing does (#565; or an ICO, a web site's icon, for a sender's picture, which is never a
//! drawing: [`Cache::get_as`]) and are no
//! larger than a download may be; the window, which decodes them, takes back what turns
//! out to be none ([`Cache::forget`]). Nothing here is ever run, opened by another program on
//! our say-so, or served to anyone: a file is read back as bytes, and only when it is a plain
Expand Down Expand Up @@ -123,8 +124,15 @@ fn clock() -> u64 {
SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |since| since.as_secs())
}

/// Whether bytes begin the way a picture that is shown begins: PNG, JPEG, GIF or WebP.
/// Whether bytes begin the way a picture of a message that is shown begins: PNG, JPEG, GIF, WebP
/// or an SVG drawing (#565).
pub fn looks_like_a_picture(bytes: &[u8]) -> bool {
looks_like_a_raster(bytes) || mailcraft_ui_egui::looks_like_svg(bytes)
}

/// Whether bytes begin the way a PNG, JPEG, GIF or WebP does: a picture of pixels, as a sender's
/// picture is ([`crate::sender_images`]).
pub fn looks_like_a_raster(bytes: &[u8]) -> bool {
bytes.starts_with(b"\x89PNG\r\n\x1a\n")
|| bytes.starts_with(b"\xff\xd8\xff")
|| bytes.starts_with(b"GIF87a")
Expand Down Expand Up @@ -760,16 +768,24 @@ mod tests {
bytes.extend([7u8; 60]);
bytes
};
for (name, bytes) in
[("png", png(2, 64)), ("jpeg", b"\xff\xd8\xff\xe0\0\x10JFIF\0rest".to_vec()), ("gif", b"GIF89a\x01\0\x01\0rest".to_vec()), ("webp", webp)]
{
for (name, bytes) in [
("png", png(2, 64)),
("jpeg", b"\xff\xd8\xff\xe0\0\x10JFIF\0rest".to_vec()),
("gif", b"GIF89a\x01\0\x01\0rest".to_vec()),
("webp", webp),
// A drawing (#565), which the window draws with what it says runs left out.
("svg", b"<?xml version='1.0'?>\n<svg xmlns='http://www.w3.org/2000/svg'><script>alert(1)</script></svg>".to_vec()),
] {
assert!(looks_like_a_picture(&bytes) && cache.put(&format!("https://img.example/{name}"), &bytes), "{name}");
assert_eq!(cache.get(&format!("https://img.example/{name}")).as_deref(), Some(&bytes[..]), "{name}");
}
// A drawing is no sender's picture.
assert!(!looks_like_a_raster(b"<svg xmlns='http://www.w3.org/2000/svg'/>"));
let too_large = png(3, MAX_PICTURE + 1);
for (what, bytes) in [
("nothing", &b""[..]),
("a web page", b"<!DOCTYPE html><html><script>alert(1)</script></html>"),
("a drawing with a script", b"<svg xmlns='http://www.w3.org/2000/svg'><script>alert(1)</script></svg>"),
("a web page with a drawing in it", b"<html><svg xmlns='http://www.w3.org/2000/svg'/></html>"),
("a program", b"MZ\x90\0\x03\0\0\0\x04\0\0\0\xff\xff\0\0"),
("a script", b"#!/bin/sh\nrm -rf ~\n"),
("a shortcut", b"[InternetShortcut]\r\nURL=file:///C:/Windows/System32/calc.exe\r\n"),
Expand All @@ -783,7 +799,7 @@ mod tests {
}
assert_eq!(cache.get("https://img.example/other"), None);
assert!(!cache.put("", &png(4, 64)) && !cache.put(&"a".repeat(MAX_ADDRESS + 1), &png(4, 64)));
assert_eq!(cache.usage().0, 4);
assert_eq!(cache.usage().0, 5);
// Every file kept has a name of 64 hex digits and nothing after it: nothing to run.
for file in temp.files().iter().filter(|file| *file != "index") {
let name = file.rsplit('/').next().unwrap();
Expand Down
Loading
Loading