mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
Paint: an opacity call refuses a bad target with an id or selected characters
The opacity path of paint.setFill and paint.setStroke (apply_paint_opacity)
never checked `target` or `aligned`. With `id` or `ids` naming an object,
item_target reads no `target`, so a call such as {"opacity": 40,
"target": "content", "id": ...} painted the object instead of failing.
The test added in 6898eed99 covers that case, and the opacity path from
4f065ccbb (Show Opacity in the Color Wheel panel) merged beside it without
the check, so main's gate failed on
tests::paintopacity::a_bad_target_is_refused_with_an_id_or_selected_characters.
The opacity path now runs the same two checks as the color path
(tool_color_params): appearance::aligned and appearance::targets_contents.
Valid values are read where they were before.
This commit is contained in:
1 parent
fb450d346d
commit
3dfd7393c2
1 file changed
+4
@@ -945,6 +945,10 @@ fn apply_paint_opacity(s: &mut Session, p: &Value, paint: Option<Paint>, opacity
|
||||
let cmd = if fill { "paint.setFill" } else { "paint.setStroke" };
|
||||
let for_tool = tool_color_params(s, p, cmd, !fill)?;
|
||||
let p = for_tool.as_ref().unwrap_or(p);
|
||||
// A bad `target` or `aligned` is refused for every kind of target: `item_target` reads no
|
||||
// `target` once `id` or `ids` names an object, and selected characters read neither.
|
||||
super::appearance::aligned(p, cmd)?;
|
||||
super::appearance::targets_contents(p)?;
|
||||
let focus = switch_or(p, "focus", true, cmd)?;
|
||||
// An opacity alone places no gradient, so `span` may only be "object" with it.
|
||||
let span = spans_targets(p, paint.as_ref().unwrap_or(&Paint::None)).map_err(|e| bad(cmd, e))?;
|
||||
|
||||
Reference in new issue
Block a user