Merge PR #7571: Refuse strict .atn export of Apply Image with a blending mask

Conflicts:
crates/engine/src/atn_cmds/tests.rs: appended tests, kept both
This commit is contained in:
aiongg committed 2026-10-22 02:22:48 +00:00
commit aa4f03a8ad
2 files changed
+29

No files matched your search

+9
View File
@@ -1911,6 +1911,15 @@ fn apply_image_from(d: &Descriptor) -> Mapped {
}
fn apply_image_to(_: &str, p: &Value) -> Option<Descriptor> {
// The optional blending mask has no descriptor mapping: refuse it rather than drop it,
// which would widen the edit to the whole layer.
let mask_channel = match p.get("mask") {
Some(m) => m.get("channel"),
None => p.get("maskChannel"),
};
if mask_channel.is_some_and(|c| !(c.is_null() || c == "none" || c == "")) {
return None;
}
let source = p.get("source").cloned().unwrap_or(json!({}));
let channel = jstr(&source, "channel").unwrap_or("composite");
let chan = lookup_back(SOURCE_CHANNELS, channel).or_else(|| lookup_back(CHANNELS, channel))?;
+20
View File
@@ -1829,3 +1829,23 @@ fn transform_with_mask_or_channel_target_is_not_exported_as_layer_transform() {
assert!(transform_to("edit.transform", &form).is_none());
}
}
/// Apply Image's optional blending mask has no `.atn` mapping: a strict export must refuse the
/// step rather than drop the mask and widen the edit to the whole layer.
#[test]
fn apply_image_with_blending_mask_is_not_exported_without_its_mask() {
let source = json!({"layer": "Pixels", "channel": "green", "invert": true});
for params in [json!({"source": source, "blending": "normal", "mask": {"channel": 0}}), json!({"source": source, "blending": "normal", "maskChannel": 0})] {
let masked = Action { name: "Masked".into(), steps: vec![("image.applyImage".into(), params.clone())], ..Default::default() };
assert!(export("Audit5", &[&masked], &[], false).is_err(), "{params}");
let (_, skipped) = export("Audit5", &[&masked], &[], true).unwrap();
assert_eq!(skipped, vec![Skipped { action: "Masked".into(), step: 0, id: "image.applyImage".into() }]);
}
for params in [json!({"source": source, "blending": "normal"}), json!({"source": source, "blending": "normal", "mask": {"channel": "none"}})] {
let plain = Action { name: "Plain".into(), steps: vec![("image.applyImage".into(), params.clone())], ..Default::default() };
let (bytes, skipped) = export("Audit5", &[&plain], &[], false).unwrap();
assert!(skipped.is_empty());
let imported = import(&bytes).unwrap();
assert_eq!(imported.actions[0].steps, vec![("image.applyImage".to_string(), json!({"source": source, "blending": "normal"}))]);
}
}