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 1/7] 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 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 2/7] 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 3/7] 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 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 4/7] 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 5/7] 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 6/7] =?UTF-8?q?craft-markdown:=20an=20=20ta?= =?UTF-8?q?g=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 3348a65737fc6e3ab9cf5eb72eb678e7277ddf7d Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Fri, 27 Nov 2026 19:59:17 +0000 Subject: [PATCH 7/7] 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, .. })));