From 787a7a0f972fd1d7a7618fdbeca3a5267a0407ff Mon Sep 17 00:00:00 2001 From: FredApps Date: Sun, 1 Nov 2026 22:39:15 +0100 Subject: [PATCH 01/22] fix(ui): keep rail scrolling above the footer in short windows --- crates/ui/src/panes/rail.rs | 3 ++ crates/ui/src/panes/rail_tests.rs | 53 ++++++++++++++++++------------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/crates/ui/src/panes/rail.rs b/crates/ui/src/panes/rail.rs index c6756e7be8..169696b275 100644 --- a/crates/ui/src/panes/rail.rs +++ b/crates/ui/src/panes/rail.rs @@ -166,6 +166,9 @@ impl Rail { ui.with_layout(Layout::top_down(Align::Center), foot); }); egui::ScrollArea::vertical() + // The footer can leave less than the default 64-point minimum. + // Keep the scrolling viewport within the space above it. + .min_scrolled_height(0.0) .id_salt(self.id.with("rail-items")) .auto_shrink([false, false]) .show(ui, |ui| { diff --git a/crates/ui/src/panes/rail_tests.rs b/crates/ui/src/panes/rail_tests.rs index 2fa6ce770d..02027b10fc 100644 --- a/crates/ui/src/panes/rail_tests.rs +++ b/crates/ui/src/panes/rail_tests.rs @@ -267,29 +267,38 @@ fn the_rail_is_outermost_and_the_open_pane_sits_between_it_and_the_document() { #[test] fn in_a_short_window_the_items_scroll_and_the_foot_stays_visible() { - let mut app = App::new(); - app.foot = true; - let mut h = harness(app, 200.0); - let foot = h.get_by_label("Foot").rect(); - assert!(foot.bottom() <= 192.0, "{foot:?}"); - assert!(item(&h, Tool::Comments).top() < 30.0); - assert!(item(&h, Tool::Tags).bottom() > foot.top(), "the last item starts out of view"); + for (edge, height) in [(Edge::Start, 200.0), (Edge::End, 200.0), (Edge::Start, 100.0), (Edge::End, 100.0)] { + let mut app = App::new(); + app.foot = true; + app.edge = edge; + let mut h = harness(app, height); + let foot = h.get_by_label("Foot").rect(); + assert!(foot.bottom() <= height - 8.0, "{foot:?}"); + assert!(item(&h, Tool::Comments).top() < 30.0); + assert!(item(&h, Tool::Tags).bottom() > foot.top(), "the last item starts out of view"); - let over = item(&h, Tool::Comments).center(); - h.input_mut().events.extend([ - Event::PointerMoved(over), - Event::MouseWheel { - source: egui::MouseWheelSource::Unknown, - unit: egui::MouseWheelUnit::Point, - delta: vec2(0.0, -500.0), - phase: egui::TouchPhase::Move, - modifiers: Modifiers::NONE, - }, - ]); - h.run_steps(3); - let tags = item(&h, Tool::Tags); - assert!(tags.bottom() <= h.get_by_label("Foot").rect().top(), "{tags:?} above the foot after scrolling"); - assert_eq!(h.get_by_label("Foot").rect(), foot); + let first = item(&h, Tool::Comments); + if height == 100.0 { + let available = foot.top() - first.top(); + assert!((RAIL_BUTTON..64.0).contains(&available), "exercise a viewport smaller than the default minimum: {available}"); + } + let over = first.center(); + h.input_mut().events.extend([ + Event::PointerMoved(over), + Event::MouseWheel { + source: egui::MouseWheelSource::Unknown, + unit: egui::MouseWheelUnit::Point, + delta: vec2(0.0, -500.0), + phase: egui::TouchPhase::Move, + modifiers: Modifiers::NONE, + }, + ]); + h.run_steps(3); + let tags = item(&h, Tool::Tags); + assert!(tags.top() >= first.top(), "{tags:?} fully visible after scrolling"); + assert!(tags.bottom() <= h.get_by_label("Foot").rect().top(), "{tags:?} above the foot after scrolling"); + assert_eq!(h.get_by_label("Foot").rect(), foot); + } } #[test] From 031be8fe4ddd4935304ea7b5b9338a61aaefef9c Mon Sep 17 00:00:00 2001 From: Renato Pinto <74988048+quebranozes@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:25:25 +0000 Subject: [PATCH 02/22] craft-proof: the regions that write like Portugal read the pt-pt dictionary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ProofLang::from_tag sent only pt-PT to the pt-pt Language pack language, so text tagged pt-AO or pt-MZ was checked against the Brazilian pt_BR dictionary and facto, equipa and económico were flagged. The Portuguese branch now uses the regions CLDR gives pt_PT as their parent locale (supplementalData.xml): Angola, Cape Verde, Equatorial Guinea, Guinea-Bissau, Macao, Mozambique, São Tomé and Príncipe, Timor-Leste, Switzerland, France and Luxembourg, as de-CH and de-LI share de-ch. Brazil, a bare pt, private-use subtags and other regions stay Pt. Co-Authored-By: Claude Opus 5.5 --- crates/proof/README.md | 2 +- crates/proof/src/lang.rs | 19 ++++++++++++++----- crates/proof/src/lib.rs | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/proof/README.md b/crates/proof/README.md index 49a16473e2..8881bf9c13 100644 --- a/crates/proof/README.md +++ b/crates/proof/README.md @@ -14,7 +14,7 @@ craft-proof = { git = "https://github.com/storytold/craft-libs", rev = " | Language | Spelling | Grammar | Hyphenation | |---|---|---|---| | English (en-US, en-CA, en-GB and the British-spelling Englishes such as en-AU, en-NZ) | SCOWL 2026 Hunspell dictionary per English + `en-extra.txt`, dialect policy (`en-variants.txt`); a dictionaries-folder English first; without SCOWL the installed Hunspell English, else the built-in Moby list ([below](#english-is-always-checked)) | yes | Moby list, our patterns, heuristic | -| Polish, Portuguese, Italian | the installed Hunspell dictionary | yes | TeX patterns (embedded, or a Language pack) | +| Polish, Portuguese (pt-BR; pt-PT and the regions that write like Portugal, such as pt-AO and pt-MZ, read `pt_PT`), Italian | the installed Hunspell dictionary | yes | TeX patterns (embedded, or a Language pack) | | Croatian, Turkish, Russian, Czech, Indonesian, Spanish (es, es-MX, es-419, es-UY) | the installed Hunspell dictionary (Russian also `ru-extra.txt`) | yes | Turkish and Russian rules; English fallback otherwise | | German | — | — | TeX patterns (embedded, or a Language pack) | | Bulgarian | — | — | syllable rules | diff --git a/crates/proof/src/lang.rs b/crates/proof/src/lang.rs index 993e403063..6549d314fb 100644 --- a/crates/proof/src/lang.rs +++ b/crates/proof/src/lang.rs @@ -26,8 +26,9 @@ pub enum ProofLang { /// Bulgarian (`bg`, `bg-BG`): hyphenation by the Bulgarian syllable rules ([`crate::bg`]), and /// spelling when a Bulgarian Hunspell dictionary or `bg` pack is found. No grammar rules yet. Bg, - /// Portuguese (`pt`, `pt-BR`; `pt-PT` is [`ProofLang::Pack`] `pt-pt`, with its own dictionary - /// and these grammar rules and patterns): the installed Hunspell dictionary (VERO and + /// Portuguese (`pt`, `pt-BR`; `pt-PT` and the regions that write like Portugal, `pt-AO`, + /// `pt-MZ`…, are [`ProofLang::Pack`] `pt-pt`, with its own dictionary and these grammar rules + /// and patterns): the installed Hunspell dictionary (VERO and /// friends, when there is one), the Portuguese grammar rules and the Portuguese hyphenation /// patterns. Pt, @@ -120,7 +121,7 @@ impl ProofLang { ProofLang::Bg } else if primary.eq_ignore_ascii_case("pt") || primary.eq_ignore_ascii_case("por") { // European Portuguese spells differently: its own dictionary (`pt_PT`, a `pt-pt` pack). - if region(tag).is_some_and(|r| r.eq_ignore_ascii_case("PT")) { + if region(tag).is_some_and(|r| EUROPEAN_PORTUGUESE.iter().any(|e| e.eq_ignore_ascii_case(r))) { PackLocale::new("pt-PT").map_or(ProofLang::Pt, ProofLang::Pack) } else { ProofLang::Pt @@ -371,6 +372,12 @@ pub(crate) fn region(tag: &str) -> Option<&str> { const LATIN_AMERICA: [&str; 22] = ["419", "005", "013", "029", "AR", "BO", "CL", "CO", "CR", "CU", "DO", "EC", "GT", "HN", "NI", "PA", "PE", "PR", "PY", "SV", "US", "VE"]; +/// Regions whose Portuguese is Portugal's (the `pt-pt` [`ProofLang::Pack`]): Portugal and the +/// regions CLDR gives `pt_PT` as their parent locale: Angola, Cape Verde, Equatorial Guinea, +/// Guinea-Bissau, Macao, Mozambique, São Tomé and Príncipe and Timor-Leste, and Portuguese +/// written in Switzerland, France and Luxembourg. +const EUROPEAN_PORTUGUESE: [&str; 12] = ["PT", "AO", "CH", "CV", "FR", "GQ", "GW", "LU", "MO", "MZ", "ST", "TL"]; + /// Regions whose English uses British spelling ([`ProofLang::EnGb`]): the United Kingdom (and /// the non-standard `UK`), Ireland, Australia, New Zealand, South Africa, India and other /// Commonwealth countries, the Crown dependencies and Europe (`150`). @@ -452,9 +459,11 @@ mod tests { let sr_latn = ProofLang::Pack(PackLocale::new("sr-latn").unwrap()); assert_tags(&["sr@latin", "sr_RS@latin", "sr_RS.UTF-8@latin", "sr-Latn"], sr_latn); assert_tags(&["sr", "sr@cyrillic"], ProofLang::Pack(PackLocale::new("sr").unwrap())); - assert_tags(&["pt", "pt-BR", "PT_br", "pt-BR.UTF-8", "pt-AO", "por"], ProofLang::Pt); + assert_tags(&["pt", "pt-BR", "PT_br", "pt-BR.UTF-8", "por", "pt-Latn-BR", "pt-US", "pt-x-ao"], ProofLang::Pt); let pt_pt = ProofLang::Pack(PackLocale::new("pt-pt").unwrap()); - assert_tags(&[" pt-PT ", "pt_PT.UTF-8", "por-PT"], pt_pt); + assert_tags(&[" pt-PT ", "pt_PT.UTF-8", "por-PT", "pt_PT@euro", "pt-Latn-PT"], pt_pt); + // The regions CLDR gives pt_PT as parent write like Portugal. + assert_tags(&["pt-AO", "pt_MZ", "PT-cv", "pt-GW", "pt-ST", "pt-TL", "pt-MO", "pt-GQ", "pt-CH", "pt-FR", "pt-LU", "pt_AO.UTF-8"], pt_pt); assert_eq!((pt_pt.built_in(), ProofLang::Pt.built_in()), (ProofLang::Pt, ProofLang::Pt)); assert_tags(&["it", "it-IT", "IT_it", "it-CH", "it-CH.UTF-8", " it-IT ", "ita"], ProofLang::It); assert_tags(&["cs", "cs-CZ", "CS-cz", "cs_CZ", " ces ", "CES", "cze", "CZE"], ProofLang::Cs); diff --git a/crates/proof/src/lib.rs b/crates/proof/src/lib.rs index 5b58768ccd..841628f1ec 100644 --- a/crates/proof/src/lib.rs +++ b/crates/proof/src/lib.rs @@ -1773,11 +1773,13 @@ mod tests { let (pt_br, pt_pt) = (pack("pt-br"), pack("pt-pt")); packs::reload(); assert_eq!(chosen_dictionary(tag("pt-PT"), &system), Some(pt_pt.clone())); + assert_eq!(chosen_dictionary(tag("pt-AO"), &system), Some(pt_pt.clone()), "Angola writes like Portugal"); assert_eq!(chosen_dictionary(tag("pt-BR"), &system), Some(pt_br.clone())); std::fs::remove_dir_all(pt_br.parent().unwrap()).unwrap(); let sys_pt_br = sys("pt_BR"); packs::reload(); assert_eq!(chosen_dictionary(tag("pt-PT"), &system), Some(pt_pt.clone())); + assert_eq!(chosen_dictionary(tag("pt-MZ"), &system), Some(pt_pt.clone()), "never the system's Brazilian one"); assert_eq!(chosen_dictionary(tag("pt-BR"), &system), Some(sys_pt_br), "another region's pack after the system's right region"); std::fs::remove_dir_all(&packs_dir).unwrap(); From 67344e97a77f90bef841dedd14496257802ca015 Mon Sep 17 00:00:00 2001 From: kalmarr Date: Wed, 4 Nov 2026 15:16:29 +0100 Subject: [PATCH 03/22] fix(update): match GitHub repository names case-insensitively --- crates/update/src/release.rs | 42 +++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/crates/update/src/release.rs b/crates/update/src/release.rs index ca5419e4f8..2426e16ea3 100644 --- a/crates/update/src/release.rs +++ b/crates/update/src/release.rs @@ -124,7 +124,17 @@ pub fn download_prefix(repo: &str) -> String { /// segments with no traversal (`.`/`..`), no additional slashes, no query or fragment, and no /// backslash or percent-encoded separators that a client could later re-interpret. pub fn download_url_under(url: &str, prefix: &str) -> bool { - let Some(rest) = url.strip_prefix(prefix) else { return false }; + // GitHub repository identities are case-insensitive, but tags, asset names and route + // segments are not. Compare only owner/repo without changing the URL we will download. + let Some(expected) = prefix.strip_prefix("https://github.com/").and_then(|p| p.strip_suffix("/releases/download/")) else { return false }; + let Some((expected_owner, expected_repo)) = expected.split_once('/') else { return false }; + let Some(path) = url.strip_prefix("https://github.com/") else { return false }; + let Some((owner, path)) = path.split_once('/') else { return false }; + let Some((repo, path)) = path.split_once('/') else { return false }; + if !owner.eq_ignore_ascii_case(expected_owner) || !repo.eq_ignore_ascii_case(expected_repo) { + return false; + } + let Some(rest) = path.strip_prefix("releases/download/") else { return false }; download_suffix_ok(rest) } @@ -403,6 +413,36 @@ mod tests { assert!(download_url_under("https://github.com/storytold/photocraft/releases/download/v0.5.0/photocraft-0.5.0-macos-universal.dmg", &prefix)); } + #[test] + fn repository_casing_preserves_assets_without_weakening_confinement() { + let prefix = download_prefix("StoryTold/PhotoCraft"); + let asset = "https://github.com/storytold/photocraft/releases/download/v0.5.0/PhotoCraft-Linux.tar.gz"; + assert!(download_url_under(asset, &prefix)); + let release = parse_github_release(&api_json(asset), "StoryTold/PhotoCraft").unwrap(); + assert_eq!(release.assets.len(), 1); + assert_eq!(release.assets[0].url, asset, "tag and filename spelling is preserved"); + assert!(download_url_under( + "https://github.com/StoryTold/PhotoCraft/releases/download/V1/Artifact.ZIP", + &download_prefix("storytold/photocraft") + )); + for bad in [ + "https://github.com/storytold/photocraft-other/releases/download/v1/a.zip", + "https://github.com/other/photocraft/releases/download/v1/a.zip", + "https://github.com.evil.example/storytold/photocraft/releases/download/v1/a.zip", + "http://github.com/storytold/photocraft/releases/download/v1/a.zip", + "https://github.com/storytold/photocraft/releases/download/../a.zip", + "https://github.com/storytold/photocraft/releases/download/v1/../../../other/repo/a.zip", + "https://github.com/storytold/photocraft/releases/download/v1/a%2f.zip", + "https://github.com/storytold/photocraft/releases/download/v1/a.zip?x=1", + "https://github.com/storytold/photocraft/releases/download/v1/a.zip#fragment", + "https://github.com/storytold/photocraft/RELEASES/download/v1/a.zip", + ] { + assert!(!download_url_under(bad, &prefix), "{bad}"); + } + // Local mirrors retain their filesystem's case-sensitive path semantics. + assert!(!download_url_under_mirror("https://mirror.example/Repo/v1/a.zip", "https://mirror.example/repo/")); + } + #[test] fn list_picks_the_newest_stable_release() { let json = r#"[ From 18e673f71c8eccb469521fd94c0ac35d8f56c1b4 Mon Sep 17 00:00:00 2001 From: Renato Pinto <74988048+quebranozes@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:15:07 +0000 Subject: [PATCH 04/22] craft-proof: from_tag's doc names the Portuguese and German regions Portuguese reads the region through EUROPEAN_PORTUGUESE, and German through CH and LI, but the doc said only English and Spanish did. Co-Authored-By: Claude Opus 5.5 --- crates/proof/src/lang.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/proof/src/lang.rs b/crates/proof/src/lang.rs index 2ca871346c..89a03721a3 100644 --- a/crates/proof/src/lang.rs +++ b/crates/proof/src/lang.rs @@ -112,7 +112,8 @@ impl ProofLang { /// The proofing language of a BCP 47 tag (`pl-PL`, `en_GB`, `PL`…). The primary subtag /// counts, and for English and Spanish the region too ([`ProofLang::english`], - /// [`ProofLang::spanish`]). No tag (or an empty one) is English, WordCraft's default editing + /// [`ProofLang::spanish`]), for Portuguese ([`EUROPEAN_PORTUGUESE`]) and for German (`CH`, + /// `LI`). No tag (or an empty one) is English, WordCraft's default editing /// language. Any other valid language tag is [`ProofLang::Pack`] with its [`PackLocale`]; /// `x-none`, `und`, `zxx`, `mul`, `mis` and malformed tags are [`ProofLang::Other`]. pub fn from_tag(tag: Option<&str>) -> ProofLang { From 431e556bf8db4804f824ba20b8ac978402ec949e Mon Sep 17 00:00:00 2001 From: Renato Pinto <74988048+quebranozes@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:51:32 +0000 Subject: [PATCH 05/22] craft-proof: from_tag's doc names the Portuguese regions in words EUROPEAN_PORTUGUESE is private, so the link in a public doc added a rustdoc private_intra_doc_links warning; cargo doc -p craft-proof is back to main's 10. Co-Authored-By: Claude Opus 5.5 --- crates/proof/src/lang.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/proof/src/lang.rs b/crates/proof/src/lang.rs index 89a03721a3..b065066d0d 100644 --- a/crates/proof/src/lang.rs +++ b/crates/proof/src/lang.rs @@ -112,10 +112,11 @@ impl ProofLang { /// The proofing language of a BCP 47 tag (`pl-PL`, `en_GB`, `PL`…). The primary subtag /// counts, and for English and Spanish the region too ([`ProofLang::english`], - /// [`ProofLang::spanish`]), for Portuguese ([`EUROPEAN_PORTUGUESE`]) and for German (`CH`, - /// `LI`). No tag (or an empty one) is English, WordCraft's default editing - /// language. Any other valid language tag is [`ProofLang::Pack`] with its [`PackLocale`]; - /// `x-none`, `und`, `zxx`, `mul`, `mis` and malformed tags are [`ProofLang::Other`]. + /// [`ProofLang::spanish`]), for Portuguese (Portugal and the regions CLDR gives `pt_PT` as + /// parent) and for German (`CH`, `LI`). No tag (or an empty one) is English, WordCraft's + /// default editing language. Any other valid language tag is [`ProofLang::Pack`] with its + /// [`PackLocale`]; `x-none`, `und`, `zxx`, `mul`, `mis` and malformed tags are + /// [`ProofLang::Other`]. pub fn from_tag(tag: Option<&str>) -> ProofLang { let Some(tag) = tag.map(str::trim).filter(|t| !t.is_empty()) else { return ProofLang::En }; let primary = tag.split(['-', '_', '.', '@']).next().unwrap_or(""); From 877773daaafe8576116a4d8fe68b6b765c99286b Mon Sep 17 00:00:00 2001 From: Bruno-Alumn <171815746+Bruno-Alumn@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:26:50 +0100 Subject: [PATCH 06/22] craft-raw: keep the multipliers a Sony M / S ARW was balanced with (ColorData::balanced_with) --- crates/raw/src/arw.rs | 10 +++++++++- crates/raw/src/dng.rs | 1 + crates/raw/src/lib.rs | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/raw/src/arw.rs b/crates/raw/src/arw.rs index 639fc00327..ed2ecdf6a6 100644 --- a/crates/raw/src/arw.rs +++ b/crates/raw/src/arw.rs @@ -830,7 +830,12 @@ pub(crate) fn decode(bytes: &[u8], mode: Mode, limits: &Limits) -> Result ColorData { baseline_sharpness: get(t::BASELINE_SHARPNESS).and_then(|v| v.first().copied()).filter(|v| v.is_finite() && *v > 0.0 && *v <= 16.0), profile: profile_look(ifd0, raw, order), kelvin_presets: None, + balanced_with: None, } } diff --git a/crates/raw/src/lib.rs b/crates/raw/src/lib.rs index dbcf6f9531..c69172e145 100644 --- a/crates/raw/src/lib.rs +++ b/crates/raw/src/lib.rs @@ -995,6 +995,12 @@ pub struct ColorData { /// matrices a Kelvin scale ([`kelvin`]). Not a DNG tag: the DNG writer does not write it. #[serde(default)] pub kelvin_presets: Option, + /// The as-shot multipliers (green = 1) the samples were already balanced with. Sony's downsized lossless (M / S) + /// ARWs store white-balanced linear YCbCr, so their `wb_multipliers` are unit and the data renders as delivered; + /// a white balance scale reads As Shot from these instead (storytold/lightcraft#4078). Not a DNG tag: the DNG + /// writer does not write it. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub balanced_with: Option<[f32; 3]>, } /// A decoded raw image. From e1167c4b1bb61474b1aa27e71b2883075c325967 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:30:42 +0100 Subject: [PATCH 07/22] fix(markdown): preserve oversized numeric references as literal text --- crates/markdown/src/inlines.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/markdown/src/inlines.rs b/crates/markdown/src/inlines.rs index 99c3972463..61b3f7047c 100644 --- a/crates/markdown/src/inlines.rs +++ b/crates/markdown/src/inlines.rs @@ -377,7 +377,20 @@ fn tokenize(s: &str, base: &Fmt, depth: usize, refs: &Refs) -> Vec { } b'&' => { let rest = s.get(i..).unwrap_or(""); - match within(rest, 33).find(';').and_then(|k| decode_entity(rest.get(1..k)?).map(|ch| (ch, k))) { + match within(rest, 33).find(';').and_then(|k| { + let name = rest.get(1..k)?; + // CommonMark limits numeric references to seven decimal or six hexadecimal digits. + if let Some(num) = name.strip_prefix('#') { + let (digits, max) = match num.strip_prefix(['x', 'X']) { + Some(hex) => (hex, 6), + None => (num, 7), + }; + if digits.len() > max { + return None; + } + } + decode_entity(name).map(|ch| (ch, k)) + }) { Some((ch, k)) => { flush!(); push_text(&mut nodes, &ch, base); From b6fb8bde718d05225661a0a0699a0f5a9454ef58 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:31:50 +0100 Subject: [PATCH 08/22] test(markdown): cover numeric reference digit boundaries --- crates/markdown/src/tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/markdown/src/tests.rs b/crates/markdown/src/tests.rs index 96ad1dc3aa..d3962c11a5 100644 --- a/crates/markdown/src/tests.rs +++ b/crates/markdown/src/tests.rs @@ -36,6 +36,28 @@ fn links_code_escapes() { assert!(text.contains("*lit* & "), "{text}"); } +#[test] +fn numeric_references_respect_commonmark_digit_limits() { + for (input, expected) in [ + ("�", "�"), + ("�", "�"), + ("�", "�"), + ("�", "�"), + ("A", "A"), + ("A", "A"), + ("A", "A"), + ("A", "A"), + ("A", "A"), + ("�", "\u{FFFD}"), + ("􏿿", "\u{10FFFF}"), + ("�", "\u{FFFD}"), + ("�", "\u{FFFD}"), + ("&", "&"), + ] { + assert_eq!(spans(input), vec![(expected.into(), false, false)], "{input}"); + } +} + /// Reference links: `[text][label]`, `[text][]` and `[text]` take their destination from a /// definition line, and the definition itself leaves the document. Before, none of the three /// was a link and the definition stayed as a paragraph of its own (#3238). From c7bedac14f0f2e9f179b3da6bbb58ee592a612ba Mon Sep 17 00:00:00 2001 From: beeraw <3447138+beeraw@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:22:35 +0300 Subject: [PATCH 09/22] =?UTF-8?q?craft-markdown:=20an=20=20?= =?UTF-8?q?tag=20checks=20only=20the=20next=20four=20bytes=20for=20its=20=20(wordcraft#3715)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each tag lower-cased a copy of the rest of its paragraph to look for , which is quadratic on a paragraph of tags. Compare the next four bytes with eq_ignore_ascii_case instead; str::get returns None off a character boundary, so a multi-byte character there fails the match without panicking. Port of storytold/wordcraft#4263. --- crates/markdown/src/inlines.rs | 2 +- crates/markdown/src/tests.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/markdown/src/inlines.rs b/crates/markdown/src/inlines.rs index 99c3972463..25d4fe6e43 100644 --- a/crates/markdown/src/inlines.rs +++ b/crates/markdown/src/inlines.rs @@ -415,7 +415,7 @@ fn angle_inlines(s: &str, start: usize, base: &Fmt) -> Option<(usize, Vec) } else if matches!(lower.trim_end_matches('/').trim(), "br") { push_text(&mut nodes, "\n", base); Some((end, nodes)) - } else if lower.starts_with("a ") && rest.get(inner.len() + 1..).is_some_and(|tail| tail.to_ascii_lowercase().starts_with("")) { + } else if lower.starts_with("a ") && rest.get(inner.len() + 1..).and_then(|tail| tail.get(..4)).is_some_and(|p| p.eq_ignore_ascii_case("")) { if let Some(name) = tag_attr(inner, "id").or_else(|| tag_attr(inner, "name")) { nodes.push(Node::Inl(Inline::Anchor(name))); } diff --git a/crates/markdown/src/tests.rs b/crates/markdown/src/tests.rs index 96ad1dc3aa..931db94422 100644 --- a/crates/markdown/src/tests.rs +++ b/crates/markdown/src/tests.rs @@ -21,6 +21,29 @@ fn emphasis() { assert!(matches!(&s[0], Inline::Text(t, f) if t == "gone" && f.strike)); } +/// An empty `` or `` is an anchor whatever the case of its `` (wordcraft#3715). +#[test] +fn empty_html_anchor() { + let anchors = |s: &str| inl(s).into_iter().filter_map(|i| if let Inline::Anchor(a) = i { Some(a) } else { None }).collect::>(); + assert_eq!(anchors(r#"x y"#), vec!["n"]); + assert_eq!(anchors(r#"x y"#), vec!["m"]); + assert_eq!(anchors(r#""#), vec!["p"]); + assert!(anchors(r#"text"#).is_empty()); + assert!(anchors(r#"` tag lower-cased a copy of the rest of its paragraph to look for `` +/// (wordcraft#3715): quadratic on a paragraph of tags. +#[test] +fn a_paragraph_of_anchor_tags_parses_in_linear_time() { + let src = "".repeat(1_000_000); + let t = std::time::Instant::now(); + inl(&src); + // Well under a second now; the per-tag copy took 40 s in a release build. + assert!(t.elapsed() < std::time::Duration::from_secs(10), "{:?}", t.elapsed()); +} + #[test] fn links_code_escapes() { let s = inl("see [the *site*](http://x.org \"T\") and `a*b*` \\*lit\\* & "); From 5e00a073a85527fc9eb198d5be6b631ee57a99d4 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 17 Nov 2026 02:12:57 +0100 Subject: [PATCH 10/22] exr: list a part's multiView view names on PartInfo A single-part stereo OpenEXR names its views in the multiView attribute, default view first. The exr crate reads it into multi_view_names, but part_info dropped it, so a caller could not tell right.R (a view) from diffuse.R (a channel group). PartInfo::multi_view now carries the names from parts and decode_part, empty without the attribute. --- crates/exr/src/decode.rs | 8 +++++++- crates/exr/src/decode_tests.rs | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/exr/src/decode.rs b/crates/exr/src/decode.rs index 2797e36414..e6fecb70e8 100644 --- a/crates/exr/src/decode.rs +++ b/crates/exr/src/decode.rs @@ -1,7 +1,7 @@ //! Bounded OpenEXR reading and writing on top of the `exr` crate (feature `decode`). //! //! - [`parts`] lists every part from the headers alone (size, windows, channels, compression, -//! text attributes), after checking the declared sizes against [`Limits`] and the file's size. +//! views, text attributes), after checking the declared sizes against [`Limits`] and the file's size. //! - [`pick_part`] chooses the part a plain picture decode shows: the best colour channel group //! ([`crate::channels::color_channels`]), the earliest part on a tie. //! - [`decode_part`] decodes the channels of one flat part that a filter keeps, in their stored @@ -161,6 +161,11 @@ pub struct PartInfo { pub name: Option, /// The `view` attribute of a stereo part. pub view: Option, + /// The `multiView` attribute of a single-part stereo file: its view names, the default view + /// first. A channel without a period is the default view's; another view's channels carry + /// the view name before the channel's own (`right.R`, `diffuse.right.R`). Empty without the + /// attribute. + pub multi_view: Vec, pub data_window: Window, pub display_window: Window, pub deep: bool, @@ -316,6 +321,7 @@ fn part_info(index: usize, header: &Header) -> PartInfo { index, name: header.own_attributes.layer_name.as_ref().map(|n| n.to_string()), view: header.own_attributes.view_name.as_ref().map(|v| v.to_string()), + multi_view: header.own_attributes.multi_view_names.iter().flatten().map(|v| v.to_string()).collect(), data_window: Window { x: header.own_attributes.layer_position.0, y: header.own_attributes.layer_position.1, width: w, height: h }, display_window: Window { x: display.position.0, y: display.position.1, width: dw, height: dh }, deep: header.deep, diff --git a/crates/exr/src/decode_tests.rs b/crates/exr/src/decode_tests.rs index 89f44d5068..608ad38808 100644 --- a/crates/exr/src/decode_tests.rs +++ b/crates/exr/src/decode_tests.rs @@ -86,6 +86,28 @@ fn multi_part_files_list_and_decode_one_part() { assert_eq!(pick_part(&[]), None); } +#[test] +fn a_multi_view_part_lists_its_views_default_first() { + let mut stereo = layer(None, 3, 2, &["B", "G", "R", "right.B", "right.G", "right.R"], false, exr::prelude::Compression::ZIP1); + stereo.attributes.multi_view_names = Some(vec![Text::from("left"), Text::from("right")]); + let bytes = file(vec![stereo], (3, 2)); + let listed = parts(&bytes, &Limits::default()).unwrap(); + assert_eq!(listed[0].multi_view, ["left", "right"]); + assert_eq!(listed[0].view, None); + // The decoded part carries the same header facts. + assert_eq!(decode_part(&bytes, 0, &all, &Limits::default()).unwrap().info.multi_view, ["left", "right"]); + + // Parts that each name their own view, and a plain file, have no `multiView`. + let mut left = layer(Some("beauty.left"), 3, 2, &["R"], false, exr::prelude::Compression::ZIP1); + left.attributes.view_name = Some(Text::from("left")); + let mut right = layer(Some("beauty.right"), 3, 2, &["R"], false, exr::prelude::Compression::ZIP1); + right.attributes.view_name = Some(Text::from("right")); + let listed = parts(&file(vec![left, right], (3, 2)), &Limits::default()).unwrap(); + assert_eq!(listed.iter().map(|p| (p.view.as_deref(), p.multi_view.len())).collect::>(), [(Some("left"), 0), (Some("right"), 0)]); + let plain = file(vec![layer(None, 3, 2, &["R"], false, exr::prelude::Compression::ZIP1)], (3, 2)); + assert!(parts(&plain, &Limits::default()).unwrap()[0].multi_view.is_empty()); +} + #[test] fn written_files_read_back() { let h: Vec = (0..6).map(|i| f16::from_f32(i as f32 / 4.0)).collect(); From 5624c06682bd03abb1ff194010daa7cd219eb1cb Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 17 Nov 2026 02:18:38 +0100 Subject: [PATCH 11/22] exr: test that multiView keeps its declared order, right view first --- crates/exr/src/decode_tests.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/exr/src/decode_tests.rs b/crates/exr/src/decode_tests.rs index 608ad38808..4ce92ba7fd 100644 --- a/crates/exr/src/decode_tests.rs +++ b/crates/exr/src/decode_tests.rs @@ -96,6 +96,10 @@ fn a_multi_view_part_lists_its_views_default_first() { assert_eq!(listed[0].view, None); // The decoded part carries the same header facts. assert_eq!(decode_part(&bytes, 0, &all, &Limits::default()).unwrap().info.multi_view, ["left", "right"]); + // The declared order, not a sorted one: the right view may be the default. + let mut right_first = layer(None, 3, 2, &["B", "G", "R", "left.B", "left.G", "left.R"], false, exr::prelude::Compression::ZIP1); + right_first.attributes.multi_view_names = Some(vec![Text::from("right"), Text::from("left")]); + assert_eq!(parts(&file(vec![right_first], (3, 2)), &Limits::default()).unwrap()[0].multi_view, ["right", "left"]); // Parts that each name their own view, and a plain file, have no `multiView`. let mut left = layer(Some("beauty.left"), 3, 2, &["R"], false, exr::prelude::Compression::ZIP1); From 7fdd21b4b563a889a4325b7bbc5fbff228f4f973 Mon Sep 17 00:00:00 2001 From: ljkx <177671075+ljkx@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:19:58 +0100 Subject: [PATCH 12/22] craft-xlsx: write a dxf's border before its protection, in CT_Dxf order --- crates/xlsx/src/styles.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/xlsx/src/styles.rs b/crates/xlsx/src/styles.rs index 89575ea795..6e29148a15 100644 --- a/crates/xlsx/src/styles.rs +++ b/crates/xlsx/src/styles.rs @@ -593,7 +593,8 @@ impl Dxf { } } - /// ``. + /// ``, its children in the `CT_Dxf` sequence: `font`, `numFmt`, `fill`, `alignment`, + /// `border`, `protection`. pub fn to_el(&self) -> El { let mut e = El::new("dxf"); if let Some(f) = &self.font { @@ -611,12 +612,12 @@ impl Dxf { if let Some(a) = &self.alignment { e.push(a.to_el()); } - if let Some(p) = self.protection { - e.push(p.to_el()); - } if let Some(b) = &self.border { e.push(b.to_el()); } + if let Some(p) = self.protection { + e.push(p.to_el()); + } e } } @@ -798,6 +799,23 @@ mod tests { assert_eq!(styles("").palette(), DEFAULT_PALETTE); } + #[test] + fn dxf_children_are_written_in_schema_order() { + // Every child CT_Dxf allows (but extLst), in its sequence; the issue's case is border then protection. + let s = styles( + r#""#, + ); + let written = styles(std::str::from_utf8(&s.to_xml()).unwrap()); + assert_eq!(written.dxfs, s.dxfs); + let root = craft_xml::Options::local().parse(&s.to_xml()).unwrap_or_default(); + let dxf = root.child("dxfs").and_then(|d| d.child("dxf")).expect("dxf written"); + let names: Vec<&str> = dxf.elements().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["font", "numFmt", "fill", "alignment", "border", "protection"]); + // border and protection alone keep that order too. + let pair = Dxf { border: s.dxfs[0].border.clone(), protection: s.dxfs[0].protection, ..Dxf::default() }.to_el(); + assert_eq!(pair.elements().map(|c| c.name.as_str()).collect::>(), ["border", "protection"]); + } + #[test] fn long_font_names_are_cut() { let s = styles(&format!(r#""#, "é".repeat(300))); From 979a0c4994bd3229bc603b9671a3708eeb98578a Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:07:02 +0100 Subject: [PATCH 13/22] fix(mime): resolve percent-encoded CID references --- crates/mime/src/related.rs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/crates/mime/src/related.rs b/crates/mime/src/related.rs index 56ef6a1aab..b5c180ba60 100644 --- a/crates/mime/src/related.rs +++ b/crates/mime/src/related.rs @@ -48,12 +48,14 @@ impl<'a> Resources<'a> { self.by_location.get(&location.to_ascii_lowercase()).copied() } - /// The part a reference in a page names: `cid:id` by `Content-ID`; anything else by - /// `Content-Location`, as written, or resolved against `base`, the page's own location - /// ([`resolve_location`]; empty when it has none). Nothing is fetched. + /// The part a reference in a page names. A `cid:` URL is percent-decoded before the + /// `Content-ID` lookup. Other references use `Content-Location`, as written or resolved + /// against `base`, the page's own location ([`resolve_location`]). Nothing is fetched. pub fn find(&self, reference: &str, base: &str) -> Option<&'a Part> { let reference = reference.trim(); match reference.get(..4).filter(|s| s.eq_ignore_ascii_case("cid:")).and(reference.get(4..)) { + // RFC 2392 percent-decodes the URL, without form-style plus substitution. + Some(id) if id.contains('%') => self.by_content_id(&crate::mailto::percent_decode(id)).or_else(|| self.by_content_id(id)), Some(id) => self.by_content_id(id), None => self.by_location(reference).or_else(|| self.by_location(&resolve_location(base, reference))), } @@ -231,6 +233,27 @@ mod tests { assert!(start_part(&m.root).is_none()); } + #[test] + fn cid_references_decode_url_escapes_once() { + let message = parse( + b"Content-Type: multipart/related; boundary=b\n\n\ + --b\nContent-ID: \n\nplus\n\ + --b\nContent-ID: \n\npercent\n\ + --b\nContent-ID: \n\nlegacy\n--b--\n", + &Limits::default(), + ); + let resources = Resources::of(&message.root); + for (reference, expected) in [ + ("cid:part+id@example.test", "part+id@example.test"), + ("CID:part%2bid%40example.test", "part+id@example.test"), + ("cid:part%2Bid@example.test", "part+id@example.test"), + ("cid:part%252Bid@example.test", "part%2Bid@example.test"), + ("cid:legacy%41@example.test", "legacy%41@example.test"), + ] { + assert_eq!(resources.find(reference, "").and_then(Part::content_id), Some(expected), "{reference}"); + } + } + proptest::proptest! { #[test] fn any_reference_resolves(base in "[a-c:/?#.]{0,24}", reference in "[a-c:/?#.]{0,24}") { From 5bf96b0833413c440d07fc4d4d15aaa710f42489 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:07:32 +0100 Subject: [PATCH 14/22] Reuse the existing URI percent decoder for CID lookups --- crates/mime/src/mailto.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/mime/src/mailto.rs b/crates/mime/src/mailto.rs index 36a8f1c701..bd252ec0da 100644 --- a/crates/mime/src/mailto.rs +++ b/crates/mime/src/mailto.rs @@ -44,13 +44,13 @@ pub fn parse_mailto(link: &str) -> Option { let mut m = Mailto::default(); // Commas separate the addresses before they are decoded: an encoded comma belongs to its address. for address in path.split(',') { - add(&mut m.to, &decode(address)); + add(&mut m.to, &percent_decode(address)); } let (mut subject, mut body) = (None, None); for field in query.split('&') { let (name, value) = field.split_once('=').unwrap_or((field, "")); - let value = decode(value); - match decode(name).to_ascii_lowercase().as_str() { + let value = percent_decode(value); + match percent_decode(name).to_ascii_lowercase().as_str() { "to" => add_list(&mut m.to, &value), "cc" => add_list(&mut m.cc, &value), "bcc" => add_list(&mut m.bcc, &value), @@ -79,7 +79,7 @@ pub(crate) fn cut(text: &str, max: usize) -> &str { /// Percent-decoding. An escape that isn't one stays as it is written, a plus sign is a plus sign /// (RFC 6068 section 5), and bytes that aren't UTF-8 become the replacement character. -fn decode(text: &str) -> String { +pub(super) fn percent_decode(text: &str) -> String { let bytes = text.as_bytes(); let mut out = Vec::with_capacity(bytes.len()); let mut i = 0; From b126e87bae7fd17dbbb8a0ed23878cec2ad5c3b6 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sun, 22 Nov 2026 22:19:14 +0200 Subject: [PATCH 15/22] fix(i18n): stop Subtags::parse at BCP 47 singletons and private-use tags --- crates/i18n/src/scripts.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/i18n/src/scripts.rs b/crates/i18n/src/scripts.rs index aa39d8917f..48acffb6b3 100644 --- a/crates/i18n/src/scripts.rs +++ b/crates/i18n/src/scripts.rs @@ -278,6 +278,9 @@ impl Subtags { let base = tag.split(['.', '@']).next().unwrap_or("").replace('_', "-"); let mut parts = base.split('-').filter(|p| !p.is_empty()); let language = parts.next().unwrap_or("").to_owned(); + if language.len() == 1 { + return Subtags { language, script: None, region: None }; + } let mut script = match tag.split_once('@').map(|(_, m)| m) { Some("latin") => Some("latn".to_owned()), Some("cyrillic") => Some("cyrl".to_owned()), @@ -285,6 +288,11 @@ impl Subtags { }; let mut region = None; for part in parts { + // Stop at BCP 47 extension or private-use singletons (`-u-`, `-t-`, `-x-`) so their + // subtags are never mistaken for a script or region. + if part.len() == 1 { + break; + } if part.len() == 4 && part.bytes().all(|b| b.is_ascii_alphabetic()) { script.get_or_insert_with(|| part.to_owned()); } else if super::is_region(part) { @@ -456,6 +464,25 @@ mod tests { assert_eq!(direction("ug-KZ"), Direction::Ltr); } + #[test] + fn extensions_and_private_use_do_not_set_script_or_region() { + for (tag, want, dir) in [ + ("en-u-arab", &[Latn][..], Direction::Ltr), + ("en-u-nu-arab", &[Latn], Direction::Ltr), + ("en-t-hebr", &[Latn], Direction::Ltr), + ("en-x-arab", &[Latn], Direction::Ltr), + ("x-arab", &[Latn], Direction::Ltr), + ("x-he-arab", &[Latn], Direction::Ltr), + ("he-u-latn", &[Hebr], Direction::Rtl), + ("he-u-nu-latn", &[Hebr], Direction::Rtl), + ("sr-Latn-u-arab", &[Latn], Direction::Ltr), + ("pa-u-pk", &[Guru], Direction::Ltr), + ] { + assert_eq!(scripts(tag), want, "{tag}"); + assert_eq!(direction(tag), dir, "{tag}"); + } + } + /// The usual scripts tag matching relies on agree with the table. #[test] fn agrees_with_usual_script() { From 6c46de12384daad94101fca404d772202a17a228 Mon Sep 17 00:00:00 2001 From: yonatan-langer83 <223155288+yonatan-langer83@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:53:36 +0200 Subject: [PATCH 16/22] test(mpegts): read across large PES boundaries Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- crates/media/src/mpegts/work_tests.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/media/src/mpegts/work_tests.rs b/crates/media/src/mpegts/work_tests.rs index d92aca42af..07dfc69e42 100644 --- a/crates/media/src/mpegts/work_tests.rs +++ b/crates/media/src/mpegts/work_tests.rs @@ -94,9 +94,22 @@ fn program_stream_with_large_pes_packets_gives_back_every_frame() { assert_eq!(f.streams.len(), 2); for (s, frames) in f.streams.iter().zip([&a, &b]) { assert_eq!(s.units.len(), frames.len()); - // a read refills a 1 MiB window: every seventh unit and the last ones keep a debug build quick - for (i, fr) in frames.iter().enumerate().filter(|(i, _)| i % 7 == 0 || i + 4 > frames.len()) { - assert_eq!(&f.read_unit(&data, f.streams.iter().position(|x| std::ptr::eq(x, s)).unwrap(), i).unwrap(), fr, "mpeg1 {mpeg1} unit {i}"); + // Sparse reads keep the debug build quick; also force PES-boundary and end reads. + let mut read_unit = frames.iter().enumerate().map(|(i, _)| i % 7 == 0 || i + 4 > frames.len()).collect::>(); + for boundary in (60_000..frames.len() * 576).step_by(60_000) { + read_unit[(boundary - 1) / 576] = true; + if boundary % 576 == 0 { + read_unit[boundary / 576] = true; + } + } + for (i, (fr, should_read)) in frames.iter().zip(read_unit).enumerate() { + if should_read { + assert_eq!( + &f.read_unit(&data, f.streams.iter().position(|x| std::ptr::eq(x, s)).unwrap(), i).unwrap(), + fr, + "mpeg1 {mpeg1} unit {i}" + ); + } } } // cut inside the last packets: never panics, and the units before the cut are intact From 3348a65737fc6e3ab9cf5eb72eb678e7277ddf7d Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Fri, 27 Nov 2026 19:59:17 +0000 Subject: [PATCH 17/22] fcproj-format: schema v20 for FilmCraft colour range masks (#1926) Append the no-op v19_to_v20 step after the Script items v19 (#3782): effect masks may carry an optional colour range, and the bump makes older builds refuse such projects instead of dropping the ranges on save. --- crates/fcproj-format/src/lib.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/fcproj-format/src/lib.rs b/crates/fcproj-format/src/lib.rs index 10c8348811..73ce858f68 100644 --- a/crates/fcproj-format/src/lib.rs +++ b/crates/fcproj-format/src/lib.rs @@ -15,7 +15,7 @@ pub type Migration = fn(Value) -> Result; /// edit a shipped one. pub const MIGRATIONS: &[Migration] = &[ v1_to_v2, v2_to_v3, v3_to_v4, v4_to_v5, v5_to_v6, v6_to_v7, v7_to_v8, v8_to_v9, v9_to_v10, v10_to_v11, v11_to_v12, v12_to_v13, v13_to_v14, - v14_to_v15, v15_to_v16, v16_to_v17, v17_to_v18, v18_to_v19, + v14_to_v15, v15_to_v16, v16_to_v17, v17_to_v18, v18_to_v19, v19_to_v20, ]; /// The schema version this build writes (and the newest it reads). @@ -269,6 +269,12 @@ fn v18_to_v19(doc: Value) -> Result { Ok(doc) } +/// v19 → v20: effect masks may carry a colour range. Existing masks have none; older builds must +/// refuse such projects instead of silently dropping saved colour ranges. +fn v19_to_v20(doc: Value) -> Result { + Ok(doc) +} + #[cfg(test)] mod tests { use super::*; @@ -340,10 +346,28 @@ mod tests { assert_eq!(file.project["items"]["2"]["kind"], script); assert_eq!(file.project["items"]["1"]["kind"], media); } + /// Schema 20 (mask colour ranges): a v19 project upgrades with its data untouched, and a v20 + /// project with a colour range on a mask is read rather than refused as too new. + #[test] + fn v19_upgrades_and_v20_mask_colour_ranges_are_read() { + let mask = json!({"mode": "add"}); + let v19 = json!({"format": FORMAT_ID, "schema_version": 19, "project": {"items": {}, "root": {}, "effects": [{"masks": [mask]}]}}); + let up = migrate_with(MIGRATIONS, v19.clone(), 19).unwrap(); + assert!(up["schema_version"].as_u64().unwrap() > 19); + assert_eq!(up["project"], v19["project"]); + let range = json!({"hue": [0.1, 0.2], "luma": [0.0, 0.2]}); + let mut v20 = up; + v20["schema_version"] = json!(20); + v20["project"]["effects"][0]["masks"][0]["color"] = range.clone(); + let bytes = serde_json::to_vec(&v20).unwrap(); + let (file, version): (EnvelopeIn, _) = decode(&bytes).unwrap(); + assert_eq!(version, 20); + assert_eq!(file.project["effects"][0]["masks"][0]["color"], range); + } #[test] fn rejects_wrong_future_and_damaged_envelopes() { assert!(matches!(detect_bytes(br#"{"format":"other","schema_version":1}"#), Err(FormatError::NotAProject(_)))); - assert!(matches!(detect_bytes(br#"{"schema_version":20}"#), Err(FormatError::TooNew { found: 20, supported: 19 }))); + assert!(matches!(detect_bytes(br#"{"schema_version":21}"#), Err(FormatError::TooNew { found: 21, supported: 20 }))); assert!(matches!(detect_bytes(br#"{"schema_version":0}"#), Err(FormatError::TooOld { found: 0, oldest: 1 }))); assert!(matches!(detect_bytes(b"{"), Err(FormatError::Corrupt(_)))); assert!(matches!(migrate_with(MIGRATIONS, json!([]), 1), Err(FormatError::Migration { from: 1, .. }))); From 8513457fab691103b2756e008431e3e6627cf107 Mon Sep 17 00:00:00 2001 From: Serafim Date: Sat, 28 Nov 2026 08:33:16 +0000 Subject: [PATCH 18/22] fix(ical): reject dates with misplaced dashes in when::parse --- crates/ical/src/values.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/ical/src/values.rs b/crates/ical/src/values.rs index 1f75a804d7..0b4d686926 100644 --- a/crates/ical/src/values.rs +++ b/crates/ical/src/values.rs @@ -50,8 +50,12 @@ pub(crate) fn valid_time(t: NaiveDateTime) -> NaiveDateTime { /// A date from `YYYY-MM-DD` or `YYYYMMDD`, years 1 to 9999. fn parse_iso_date(s: &str) -> Option { let s = s.trim(); - let digits: String = s.chars().filter(char::is_ascii_digit).collect(); - if digits.len() != 8 || s.chars().any(|c| !c.is_ascii_digit() && c != '-') { + let digits: String = match s.len() { + 8 => s.to_string(), + 10 if s.as_bytes().get(4) == Some(&b'-') && s.as_bytes().get(7) == Some(&b'-') => s.chars().filter(char::is_ascii_digit).collect(), + _ => return None, + }; + if digits.len() != 8 || !digits.bytes().all(|b| b.is_ascii_digit()) { return None; } let year: i32 = digits.get(0..4)?.parse().ok()?; @@ -293,6 +297,11 @@ mod tests { "20261312", "20260230", "00000101", + "2026-1011", + "-20261012", + "20-261012", + "20261012-", + "2026101-2T090000", "20261012T", "20261012T25", "20261012T240000", From c9f6810cc4563d31628732931ca00b244a870d8a Mon Sep 17 00:00:00 2001 From: Serafim Date: Sat, 28 Nov 2026 08:42:51 +0000 Subject: [PATCH 19/22] fix(ical): reject whitespace inside the date in when::parse --- crates/ical/src/values.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ical/src/values.rs b/crates/ical/src/values.rs index 0b4d686926..1cd021bef8 100644 --- a/crates/ical/src/values.rs +++ b/crates/ical/src/values.rs @@ -49,7 +49,6 @@ pub(crate) fn valid_time(t: NaiveDateTime) -> NaiveDateTime { /// A date from `YYYY-MM-DD` or `YYYYMMDD`, years 1 to 9999. fn parse_iso_date(s: &str) -> Option { - let s = s.trim(); let digits: String = match s.len() { 8 => s.to_string(), 10 if s.as_bytes().get(4) == Some(&b'-') && s.as_bytes().get(7) == Some(&b'-') => s.chars().filter(char::is_ascii_digit).collect(), @@ -302,6 +301,7 @@ mod tests { "20-261012", "20261012-", "2026101-2T090000", + "20261012 T090000", "20261012T", "20261012T25", "20261012T240000", From c2ec2415e8575e5f328f4a37271f5c4fa5183e08 Mon Sep 17 00:00:00 2001 From: kalmarr Date: Sun, 29 Nov 2026 00:00:49 +0100 Subject: [PATCH 20/22] fix(update): preserve exact matching for non-GitHub download prefixes --- crates/update/src/release.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/update/src/release.rs b/crates/update/src/release.rs index 9be842cf7b..60c014d263 100644 --- a/crates/update/src/release.rs +++ b/crates/update/src/release.rs @@ -146,6 +146,7 @@ pub fn expected_download_url(repo: &str, tag: &str, name: &str) -> Option bool { let (url, expected) = github_repository_paths(url, expected).unwrap_or((url, expected)); url == expected || url.replace("%2B", "+") == expected.replace("%2B", "+") @@ -169,8 +170,8 @@ fn github_repository_paths<'a>(url: &'a str, expected: &'a str) -> Option<(&'a s /// segments with no traversal (`.`/`..`), no additional slashes, no query or fragment, and no /// backslash or percent-encoded separators that a client could later re-interpret. pub fn download_url_under(url: &str, prefix: &str) -> bool { - let Some((path, prefix)) = github_repository_paths(url, prefix) else { return false }; - let Some(rest) = path.strip_prefix(prefix) else { return false }; + let (url, prefix) = github_repository_paths(url, prefix).unwrap_or((url, prefix)); + let Some(rest) = url.strip_prefix(prefix) else { return false }; download_suffix_ok(rest) } @@ -387,6 +388,14 @@ pub(crate) mod tests { const REPO: &str = "storytold/photocraft"; + #[trial] + fn download_url_under_preserves_exact_non_github_prefixes() { + let prefix = "https://example.com/Releases/"; + assert!(download_url_under("https://example.com/Releases/v1/file.zip", prefix)); + assert!(!download_url_under("https://example.com/releases/v1/file.zip", prefix)); + assert!(!download_url_under("https://example.com/Releases/v1/file.zip?query=1", prefix)); + } + #[trial] fn github_download_matching_ignores_only_repository_case() { let repo = "Storytold/PdfCraft"; From f762f98a988b8a94a0031f428d4256eb38c87adb Mon Sep 17 00:00:00 2001 From: Martin Ball <98639962+benandez@users.noreply.github.com> Date: Sun, 29 Nov 2026 00:32:07 +0000 Subject: [PATCH 21/22] Clear the design-lint findings on main (units cell memory, floating window slot) (#4161) * fix(color-ui, ui-panels): clear the three design-lint findings on main Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx * fix(color-ui): the units cell keeps its first click in component memory, not the session escape hatch Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx --------- Co-authored-by: Claude Opus 5.5 --- crates/color-ui/src/ui/picker/channel.rs | 14 +++++++------- crates/ui-panels/src/docking/floating.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/color-ui/src/ui/picker/channel.rs b/crates/color-ui/src/ui/picker/channel.rs index 8cb04ab0a5..53411dd79c 100644 --- a/crates/color-ui/src/ui/picker/channel.rs +++ b/crates/color-ui/src/ui/picker/channel.rs @@ -14,6 +14,7 @@ use craft_ui::form::{Field, FieldDecimals, SliderField, SliderFieldLayout}; use craft_ui::layout_components::Row; use craft_ui::primitives::{PaintShape, StrokeWidth}; use craft_ui::runtime::env::{Label, UnitKind}; +use craft_ui::runtime::memory::sub; use craft_ui::runtime::pointer; use craft_ui::style::{ComponentStyle, DataColor, StyleColor, StyleCx}; use craft_ui::value_drag::{SliderThumb, TrackFace}; @@ -351,23 +352,22 @@ impl Component for UnitsCell { } fn update(&mut self, cx: &mut Cx<'_, Self>) { - let first = cx.id.with("units-first-click"); - let ctx = &cx.response.ctx; + let first = sub(cx.core.id, "units-first-click"); // A press off the cell ends the cell's click run, even when it starts a new count that the next click on the // cell continues. - if pointer::frame(ctx).press.is_some_and(|press| !cx.response.rect.contains(press.origin)) { - ctx.data_mut(|data| data.remove::<(f64, u32)>(first)); + if pointer::frame(&cx.response.ctx).press.is_some_and(|press| !cx.response.rect.contains(press.origin)) { + *cx.core.memory.shown::>(first) = None; } let PressPhase::Release { start, click: true, .. } = cx.part(UNITS).press.phase else { return }; // The click count also counts a press just beside the cell, on the number field, so a click is the second of a // double click only when the click just before it, by the count, was a click on this cell. - let earlier = ctx.data(|data| data.get_temp::<(f64, u32)>(first)); + let earlier = *cx.core.memory.shown::>(first); let follows = earlier.is_some_and(|(time, clicks)| start.clicks == clicks + 1 && start.time - time <= MULTI_CLICK_TIME); if start.clicks >= 2 && follows { self.double_clicked = true; - ctx.data_mut(|data| data.remove::<(f64, u32)>(first)); + *cx.core.memory.shown::>(first) = None; } else { - ctx.data_mut(|data| data.insert_temp(first, (start.time, start.clicks))); + *cx.core.memory.shown::>(first) = Some((start.time, start.clicks)); } } diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs index 81f1aafbb9..762ab48bab 100644 --- a/crates/ui-panels/src/docking/floating.rs +++ b/crates/ui-panels/src/docking/floating.rs @@ -222,9 +222,9 @@ pub struct FloatingGroupOutput { /// Whether a move of the group's window is running: set by its `Begin` and `Update` steps, cleared by its `Commit` /// or `Cancel` and by any step of a resize. #[derive(Clone, Copy, Default)] -struct Gesture(bool); +struct WindowMoving(bool); -/// The memory slot of [`Gesture`] under the group's id. +/// The memory slot of [`WindowMoving`] under the group's id. const GESTURE: &str = "window_gesture"; impl Outcome for FloatingGroupOutput { @@ -631,7 +631,7 @@ impl Component for FloatingGroup<'_> { // A dock window's band double click collapses or expands its column, as a dock column's bar does. let collapsed = self.column.map(|column| column.collapsed.is_some()); let iconic = collapsed.filter(|_| self.chevron || self.toggled).map(|collapsed| !collapsed); - let gesture = &mut cx.core.memory.shown::(sub(cx.core.id, GESTURE)).0; + let gesture = &mut cx.core.memory.shown::(sub(cx.core.id, GESTURE)).0; if let Some(change) = self.placed { *gesture = change.kind == PlacementKind::Move && matches!(change.phase, GesturePhase::Begin | GesturePhase::Update); } From 5ffe4ad0569af8212c27aeebcbe46165c57e7a34 Mon Sep 17 00:00:00 2001 From: Martin Ball <98639962+benandez@users.noreply.github.com> Date: Sun, 29 Nov 2026 00:47:45 +0000 Subject: [PATCH 22/22] fix(text): escape caret ampersand in Find Special menu (#3914) Lands #3914 onto main after #3909. The only change from the approved head is the merge resolution in tests/it/find_dialog.rs: both PRs appended a test at the end of the file, and both tests are kept. Co-Authored-By: batistalucasv <175663788+batistalucasv@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/text/src/ui/find/dialog.rs | 10 +++++++++- crates/text/tests/it/find_dialog.rs | 30 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/crates/text/src/ui/find/dialog.rs b/crates/text/src/ui/find/dialog.rs index 4dac416b9a..841661e4f8 100644 --- a/crates/text/src/ui/find/dialog.rs +++ b/crates/text/src/ui/find/dialog.rs @@ -818,5 +818,13 @@ fn special_entries(words: &FindLabels, replacing: bool, wildcards: bool) -> Vec< (true, false) => REPLACE_CODES.iter().collect(), (true, true) => std::iter::once(&FIND_EXPRESSION).chain(REPLACE_CODES.iter()).collect(), }; - table.into_iter().map(|(name, code)| Entry::new(*code, words.special_item.fill(&[("name", name(words)), ("code", *code)]))).collect() + table + .into_iter() + .map(|(name, code)| { + // `&` starts a menu mnemonic, so double any literal ampersands (`^&` -> `^&&`) in the label while keeping + // the raw token as the picked value. + let label = words.special_item.fill(&[("name", &name(words).replace('&', "&&")), ("code", &code.replace('&', "&&"))]); + Entry::new(*code, label) + }) + .collect() } diff --git a/crates/text/tests/it/find_dialog.rs b/crates/text/tests/it/find_dialog.rs index b6790d4047..97333c18af 100644 --- a/crates/text/tests/it/find_dialog.rs +++ b/crates/text/tests/it/find_dialog.rs @@ -162,3 +162,33 @@ fn special_menu_follows_focused_box_on_replace_tab() { assert!(fixture.by_label("Beginning of Word <").is_some(), "tab switch resets Special target to Find what"); assert!(fixture.by_label("Find What Expression \\1").is_none()); } + +#[trial] +fn special_menu_shows_and_inserts_literal_caret_ampersand() { + let dialog = Rc::new(RefCell::new(FindReplaceDialog::new("", FindTab::Replace).word(true))); + let shown = Rc::clone(&dialog); + let mut fixture = Fixture::new(move |ui| { + let _ = shown.borrow_mut().show(ui, &DialogStack::default()); + }); + fixture.room(egui::vec2(900.0, 1000.0)).settle(); + + press(&mut fixture, "Search Options"); + let replace_box = fixture + .by_role(Role::TEXT_INPUT) + .into_iter() + .find(|input| fixture.tree().name_of(input.node) == Some("Replace with:")) + .expect("Replace with input"); + fixture.click(&replace_box).settle(); + press(&mut fixture, "Special"); + let items: Vec<_> = fixture.by_role(Role::MENU_ITEM); + let labels: Vec<_> = items.iter().filter_map(|item| fixture.tree().name_of(item.node).map(str::to_owned)).collect(); + assert!(labels.iter().any(|label| label == "Find What Text ^&"), "expected literal `^&` in Special menu, got {labels:?}"); + assert!(!labels.iter().any(|label| label == "Find What Text ^"), "mnemonic stripping dropped `&` from `^&` in {labels:?}"); + + let found_text = + items.into_iter().find(|item| fixture.tree().name_of(item.node) == Some("Find What Text ^&")).expect("Find What Text ^& menu item"); + fixture.click(&found_text).settle(); + let fields = dialog.borrow().json_fields().expect("fields"); + let inserted = [fields["find"].as_str(), fields["replace"].as_str()]; + assert!(inserted.contains(&Some("^&")), "expected raw `^&` to be inserted, got {fields:?}"); +}