From 06650357d85e04e0b2475d510574b0b6fc0883c8 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Wed, 11 Nov 2026 00:41:27 -0700 Subject: [PATCH 1/5] Fix main: drop the TIFF tag constants #9781 and #10983 both added, split prepare #9781 and #10983 each defined TAG_JPEG_TABLES and TAG_PREDICTOR in tiff/decode.rs and merged minutes apart, so main stopped compiling (E0428). Keep one definition, and move the structural-tag checks and the held-bytes sum out of prepare, whose cognitive complexity the two changes together pushed past clippy's limit. --- crates/codecs/src/codecs/tiff/decode.rs | 54 +++++++++++++------------ 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/crates/codecs/src/codecs/tiff/decode.rs b/crates/codecs/src/codecs/tiff/decode.rs index e7956ad9b1..f47b3c90c0 100644 --- a/crates/codecs/src/codecs/tiff/decode.rs +++ b/crates/codecs/src/codecs/tiff/decode.rs @@ -775,23 +775,42 @@ fn prepared_warnings(p: &Prepared) -> Vec { warnings } -/// Checks one directory and lays it out for decoding. `whole`: the image is decoded into one -/// buffer, which `limits.max_alloc` bounds; otherwise only its size is checked here. Chunk -/// tables larger than `limits.max_alloc` are refused before the `tiff` crate reads them. -fn prepare(f: &File<'_>, dir: &Ifd, limits: &Limits, whole: bool) -> Result { - // The values the `tiff` crate reads must exist: a count past the end of the file is - // neither allocated nor read. +/// The structural tags the `tiff` crate reads must exist (a count past the end of the file is +/// neither allocated nor read) and appear once: this parser reads the first entry of a tag and +/// the `tiff` crate the last, so a repeated structural tag (a small SamplesPerPixel first, a +/// large one last) would be checked here with one value and sized by the crate with another. +fn check_structural_tags(f: &File<'_>, dir: &Ifd) -> Result<(), CodecError> { if let Some(e) = dir.entries.iter().find(|e| ifd::STRUCTURAL_TAGS.contains(&e.tag) && f.data(e).is_none()) { return Err(err(format!("tag {} points past the end of the file", e.tag))); } - // This parser reads the first entry of a tag and the `tiff` crate the last, so a repeated - // structural tag (a small SamplesPerPixel first, a large one last) would be checked here with - // one value and sized by the crate with another. let mut structural: Vec = dir.entries.iter().map(|e| e.tag).filter(|t| ifd::STRUCTURAL_TAGS.contains(t)).collect(); structural.sort_unstable(); if let Some(w) = structural.windows(2).find(|w| w[0] == w[1]) { return Err(err(format!("tag {} appears more than once", w[0]))); } + Ok(()) +} + +/// The bytes the first `expected` strips or tiles hold inside the file, never more than the file. +fn held_bytes(f: &File<'_>, (offsets, sizes): (&ifd::Entry, &ifd::Entry), expected: u64) -> u64 { + let len = f.b.len() as u64; + let mut held = 0u64; + for i in 0..expected { + if held >= len { + break; + } + if let (Some(at), Some(n)) = (f.uint(offsets, i), f.uint(sizes, i)) { + held = held.saturating_add(n.min(len.saturating_sub(at))); + } + } + held.min(len) +} + +/// Checks one directory and lays it out for decoding. `whole`: the image is decoded into one +/// buffer, which `limits.max_alloc` bounds; otherwise only its size is checked here. Chunk +/// tables larger than `limits.max_alloc` are refused before the `tiff` crate reads them. +fn prepare(f: &File<'_>, dir: &Ifd, limits: &Limits, whole: bool) -> Result { + check_structural_tags(f, dir)?; let need = |tag: u16, name: &str| f.tag_uint(dir, tag).ok_or_else(|| err(format!("missing or unreadable {name}"))); let w = u32::try_from(need(ifd::TAG_WIDTH, "ImageWidth")?).map_err(|_| err("ImageWidth out of range"))?; let h = u32::try_from(need(ifd::TAG_HEIGHT, "ImageLength")?).map_err(|_| err("ImageLength out of range"))?; @@ -934,21 +953,11 @@ fn prepare(f: &File<'_>, dir: &Ifd, limits: &Limits, whole: bool) -> Result cw.clamp(4096, 65_535), _ => 4096, }; - let len = f.b.len() as u64; let (offsets, sizes) = ( dir.get(offsets_tag).ok_or_else(|| err("missing strip or tile offsets"))?, dir.get(counts_tag).ok_or_else(|| err("missing strip or tile byte counts"))?, ); - let mut held = 0u64; - for i in 0..expected { - if held >= len { - break; - } - if let (Some(at), Some(n)) = (f.uint(offsets, i), f.uint(sizes, i)) { - held = held.saturating_add(n.min(len.saturating_sub(at))); - } - } - let held = held.min(len); + let held = held_bytes(f, (offsets, sizes), expected); if stored > held.saturating_mul(ratio).saturating_add(1 << 20) { return Err(err(format!("the strips or tiles in this file hold {held} bytes, too few for a {w}x{h} image"))); } @@ -1074,11 +1083,6 @@ fn prepare(f: &File<'_>, dir: &Ifd, limits: &Limits, whole: bool) -> Result Date: Wed, 11 Nov 2026 00:49:15 -0700 Subject: [PATCH 2/5] Fix main: clippy after the 11-11 merges - io: drop the no-op drop(tick) in psd_export (clippy::drop_non_drop). - automation: split the Windows UNC helper test from #10323 into three, each under the cognitive-complexity limit. - ui-egui: RangeInclusive::contains in the pen cursor and the dash test. --- crates/automation/src/workspace/tests.rs | 18 +++++++++++++++++- crates/io/src/psd_export/document.rs | 1 - crates/ui-egui/src/canvas/paint.rs | 2 +- crates/ui-egui/src/canvas/tool_cursor/pen.rs | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/crates/automation/src/workspace/tests.rs b/crates/automation/src/workspace/tests.rs index 219ca6c9b4..59bd768bc5 100644 --- a/crates/automation/src/workspace/tests.rs +++ b/crates/automation/src/workspace/tests.rs @@ -449,7 +449,7 @@ fn windows_unc_root_writes_and_exports_when_supported() { #[cfg(windows)] #[test] fn windows_handle_relative_helpers_match_the_capability_operations() { - let (inside, outside, workspace) = roots("unc-helpers"); + let (inside, _outside, workspace) = roots("unc-helpers"); let root = workspace.write.as_ref().unwrap(); assert!(!is_unc_root(root)); @@ -464,7 +464,15 @@ fn windows_handle_relative_helpers_match_the_capability_operations() { std::fs::create_dir(inside.join("dir")).unwrap(); assert!(delete_on_close(&root.dir, Path::new("dir")).is_err()); assert!(inside.join("dir").is_dir()); +} +/// The ambient rename that stands in for the capability's below a UNC root (#10317). +#[cfg(windows)] +#[test] +fn windows_rename_unc_matches_the_capability_rename() { + let (inside, outside, workspace) = roots("unc-rename"); + let root = workspace.write.as_ref().unwrap(); + std::fs::create_dir(inside.join("dir")).unwrap(); // The ambient rename on the canonical root path behaves like the capability's: it creates, // replaces a file, replaces a link instead of writing through it, and refuses a directory. std::fs::write(inside.join("plain.tmp"), b"the longer first version").unwrap(); @@ -487,7 +495,15 @@ fn windows_handle_relative_helpers_match_the_capability_operations() { assert_eq!(std::fs::read(outside.join("target.png")).unwrap(), b"outside"); } let _ = std::fs::remove_file(inside.join("plain.tmp")); +} +/// The directory walk that stands in for the capability's `create_dir_all` below a UNC root +/// (#10317) creates, refuses files on the way and never follows a junction outside. +#[cfg(windows)] +#[test] +fn windows_create_dir_all_unc_matches_the_capability_operation() { + let (inside, outside, workspace) = roots("unc-dirs"); + let root = workspace.write.as_ref().unwrap(); create_dir_all_unc(root, Path::new("a/b/c")).unwrap(); assert!(inside.join("a/b/c").is_dir()); create_dir_all_unc(root, Path::new("a/b/c")).unwrap(); diff --git a/crates/io/src/psd_export/document.rs b/crates/io/src/psd_export/document.rs index f4a118b003..fb09a54ffc 100644 --- a/crates/io/src/psd_export/document.rs +++ b/crates/io/src/psd_export/document.rs @@ -127,7 +127,6 @@ fn export_supported_document( }; let space = photocraft_compose::cmyk_space(doc); photocraft_color::convert::with_cmyk_space(space.as_ref(), || ex.emit(&doc.layers, &mut tick)); - drop(tick); ctl.progress(layers_share); let merged = prepare_merged_planes(doc, &mut ex, opts, ctl, fmt, duotone_inks.is_some(), layers_share); diff --git a/crates/ui-egui/src/canvas/paint.rs b/crates/ui-egui/src/canvas/paint.rs index 07e507d935..af38b54dbc 100644 --- a/crates/ui-egui/src/canvas/paint.rs +++ b/crates/ui-egui/src/canvas/paint.rs @@ -741,7 +741,7 @@ mod clip_segment_tests { assert!(!starts.is_empty(), "the view at {left} shows dashes"); for d in starts { let off = d % (2.0 * DASH); - assert!(off < 0.01 || off > 2.0 * DASH - 0.01, "view at {left}: a dash starts {d} from the corner, off the pattern by {off}"); + assert!(!(0.01..=2.0 * DASH - 0.01).contains(&off), "view at {left}: a dash starts {d} from the corner, off the pattern by {off}"); } } } diff --git a/crates/ui-egui/src/canvas/tool_cursor/pen.rs b/crates/ui-egui/src/canvas/tool_cursor/pen.rs index fc7d968af4..302f92e8c2 100644 --- a/crates/ui-egui/src/canvas/tool_cursor/pen.rs +++ b/crates/ui-egui/src/canvas/tool_cursor/pen.rs @@ -92,7 +92,7 @@ pub fn rasterize(variant: PenVariant, scale: f32) -> Option { return None; } let icon_px_f = (LOGICAL_SIZE * scale).round(); - if icon_px_f < 1.0 || icon_px_f > 512.0 { + if !(1.0..=512.0).contains(&icon_px_f) { return None; } let icon_px = icon_px_f as u32; From cb5243bf785b9ea3814101a88976cf6c5cad23c3 Mon Sep 17 00:00:00 2001 From: FredApps Date: Wed, 11 Nov 2026 09:27:55 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=EF=BB=BFFix=20main:=20SVG=20raster=20depth?= =?UTF-8?q?=20test=20after=20#11009=20and=20#10953?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #11009 added a check that rasterize_rgba8 renders 500 nested opacity groups. #10953, merged after it, refuses whole-drawing rasterisation past 200 nested layers. The test now expects that refusal as an error, and still renders a drawing within the limit on the same 512 KiB stack. --- crates/io/tests/it/svg.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/io/tests/it/svg.rs b/crates/io/tests/it/svg.rs index fc398796cb..7402bf290d 100644 --- a/crates/io/tests/it/svg.rs +++ b/crates/io/tests/it/svg.rs @@ -448,7 +448,16 @@ fn retained_deep_svg_groups_lower_render_and_drop_on_a_bounded_worker() { let (preview, _) = svg::import_svg_preview_with_work("retained.svg", source.as_bytes(), u64::MAX).unwrap(); assert_eq!(preview.document.max_group_depth(), 100); assert!(pixel(&preview.document)[3] > 0.5); - let (w, h, pixels) = svg::rasterize_rgba8(source.as_bytes()).unwrap(); + // Whole-drawing rasterisation refuses more than 200 nested layers (#10953) with an + // error, not a crash; a drawing within that limit still renders on this small stack. + let refused = svg::rasterize_rgba8(source.as_bytes()).unwrap_err().to_string(); + assert!(refused.contains("layers are nested too deeply"), "{refused}"); + let within = format!( + "{}{}", + "".repeat(150), + "".repeat(150) + ); + let (w, h, pixels) = svg::rasterize_rgba8(within.as_bytes()).unwrap(); assert_eq!((w, h), (8, 8)); assert!(pixels[3] > 127); }) From 9d0363f189edf8ca8cdbdb73c0d782f763cb4924 Mon Sep 17 00:00:00 2001 From: FredApps Date: Wed, 11 Nov 2026 10:14:43 +0100 Subject: [PATCH 4/5] Fix main: Apply Data Set test after #10597 and #10203 #10203 gates image.applyDataSet on a document having data sets. #10597, merged later from an older base, expected the engine's index error for an empty list. The command now refuses earlier with the gate's message, so the test expects that. --- crates/ui-egui/tests/it/variables_data_sets.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/variables_data_sets.rs b/crates/ui-egui/tests/it/variables_data_sets.rs index 4e02322313..aef5630199 100644 --- a/crates/ui-egui/tests/it/variables_data_sets.rs +++ b/crates/ui-egui/tests/it/variables_data_sets.rs @@ -159,7 +159,7 @@ fn apply_menu_ok_requires_a_row_but_not_variable_definitions() { assert!(h.state().ui.dialogs.is_empty()); assert_eq!(h.state().session.active().unwrap().doc.variables.active, expected); if explicit { - assert!(h.state().ui.status.contains("no data set at index 0")); + assert!(h.state().ui.status.contains("no data sets in document")); } else { assert!(h.state().ui.status.is_empty(), "{}", h.state().ui.status); } From a572185694567dd69a5a752825aca736efe1cb84 Mon Sep 17 00:00:00 2001 From: FredApps Date: Wed, 11 Nov 2026 11:29:58 +0100 Subject: [PATCH 5/5] Fix main: gradient alert expectation and heading glyph bearings --- crates/ui-egui/src/canvas/tests.rs | 10 +++++----- crates/ui-egui/src/widgets/panel.rs | 10 +++++++++- crates/ui-egui/src/widgets/tests.rs | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 5e3dc5ae09..6506b65987 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -1921,11 +1921,11 @@ fn painting_a_group_is_refused_at_the_press_with_a_message() { app.ui.dialogs.clear(); app.ui.tool = tool; tool_event(&mut app, ToolEvent::Down { x: 10.0, y: 10.0, pressure: 1.0 }, egui::Modifiers::NONE); - // The Brush has its own measured alert, tested in `brush_refusal_alert_tests` (#11898). - let want = if tool == Tool::Brush { - "Could not use the brush tool because the pixels in a group cannot be edited without merging the group.".to_string() - } else { - format!("Could not use the {} because the target layer is a group.", tool.label()) + // Brush and Classic gradient use the measured alerts (#11898, #12017). + let want = match tool { + Tool::Brush => "Could not use the brush tool because the pixels in a group cannot be edited without merging the group.".to_string(), + Tool::Gradient => "Could not use the gradient tool because the pixels in a group cannot be edited without merging the group.".to_string(), + _ => format!("Could not use the {} because the target layer is a group.", tool.label()), }; assert_eq!(errors(&app), [want], "{tool:?}"); assert!(app.drag.is_none() && app.live_stroke.is_none(), "{tool:?} starts no stroke"); diff --git a/crates/ui-egui/src/widgets/panel.rs b/crates/ui-egui/src/widgets/panel.rs index 7833edc2bc..1d012a8423 100644 --- a/crates/ui-egui/src/widgets/panel.rs +++ b/crates/ui-egui/src/widgets/panel.rs @@ -125,7 +125,15 @@ pub fn pill_tab(ui: &mut Ui, label: &str, selected: bool) -> Response { /// Small caps section label. pub fn section_label(ui: &mut Ui, text: &str) { let t = Tokens::get(ui.ctx()); - ui.label(egui::RichText::new(tl!(text)).font(theme::medium(11.5)).color(t.text_faint)); + let text = tl!(text); + let font = theme::medium(11.5); + let galley = ui.painter().layout(text.to_owned(), font.clone(), t.text_faint, ui.available_width()); + // A glyph can start before its logical advance (the Urdu Stroke heading does). Reserve + // that bearing in the layout instead of clipping the glyph or relaxing dialog bounds. + let left = (galley.rect.left() - galley.mesh_bounds.left()).max(0.0).ceil() as i8; + egui::Frame::NONE.inner_margin(egui::Margin { left, ..Default::default() }).show(ui, |ui| { + ui.label(egui::RichText::new(text).font(font).color(t.text_faint)); + }); } /// Hairline separator. diff --git a/crates/ui-egui/src/widgets/tests.rs b/crates/ui-egui/src/widgets/tests.rs index a48873abce..6a02717e58 100644 --- a/crates/ui-egui/src/widgets/tests.rs +++ b/crates/ui-egui/src/widgets/tests.rs @@ -196,6 +196,34 @@ fn drawn_texts(out: &egui::FullOutput) -> Vec<(String, egui::Rect, bool)> { texts } +/// The Urdu Stroke heading has a negative left glyph bearing with the shipped fonts. Its ink +/// must stay inside the panel at every scale, even though its logical advance starts at zero. +#[test] +fn section_labels_keep_glyph_bearings_inside_the_panel() { + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + for kind in crate::theme::ThemeKind::ALL { + crate::theme::apply(&ctx, kind); + for ppp in [1.0, 1.25, 2.0] { + ctx.set_pixels_per_point(ppp); + for label in ["Stroke", "\u{644}\u{6a9}\u{6cc}\u{631}", "Location"] { + let mut room = egui::Rect::NOTHING; + let mut out = ctx.run_ui(Default::default(), |ui| { + ui.set_max_width(440.0); + room = ui.max_rect(); + super::section_label(ui, label); + }); + out.textures_delta.clear(); + let texts = drawn_texts(&out); + assert_eq!(texts.len(), 1, "{kind:?} @{ppp}x: {label}"); + let (_, ink, _) = &texts[0]; + assert!(ink.left() >= room.left() - 0.01, "{kind:?} @{ppp}x: {label} ink {ink:?} in {room:?}"); + assert!(ink.right() <= room.right() + 0.01, "{kind:?} @{ppp}x: {label} ink {ink:?} in {room:?}"); + } + } + } +} + /// #9635: the shared dialog label column is as wide as its widest label, between the English /// width and a cap, and a label wider than the column elides inside it. #[test]