mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 15:08:45 +00:00
address review: a visibility expression naming a group through an alias reference fails closed
This commit is contained in:
@@ -144,6 +144,11 @@ impl<'a> Scope<'a> {
|
||||
}
|
||||
*budget -= 1;
|
||||
let reference = expression.as_ref();
|
||||
// A reference to a reference is no listed group: the renderer rejects the alias, so it
|
||||
// is not taken as visible because the object it names isn't hidden.
|
||||
if reference.is_some_and(|r| matches!(*doc.get(r), Object::Ref(_))) {
|
||||
return None;
|
||||
}
|
||||
if let Some(r) = reference
|
||||
&& !path.insert(r)
|
||||
{
|
||||
@@ -195,6 +200,9 @@ impl<'a> Scope<'a> {
|
||||
if self.hidden_layers.contains(&r) {
|
||||
return true;
|
||||
}
|
||||
if matches!(*doc.get(r), Object::Ref(_)) {
|
||||
return true;
|
||||
}
|
||||
if !path.insert(r) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4038,6 +4038,8 @@ fn hidden_ocmd_policy_matches_the_default_configuration() {
|
||||
(Some("AllOn"), false, Some("not_off"), false),
|
||||
(None, false, Some("malformed_not"), true),
|
||||
(None, false, Some("malformed_without_ocgs"), true),
|
||||
// `/VE` names the hidden group through an alias object (10 0 R is a reference to 8 0 R).
|
||||
(None, false, Some("alias"), true),
|
||||
];
|
||||
for (policy, malformed_policy, visibility, should_remove) in cases {
|
||||
let mut doc = one_page(
|
||||
@@ -4075,9 +4077,11 @@ fn hidden_ocmd_policy_matches_the_default_configuration() {
|
||||
Some("malformed_without_ocgs") => {
|
||||
membership.set(b"VE".to_vec(), Object::Array(vec![Object::name("UnknownOperator"), Object::Ref(ObjRef::new(8, 0))]))
|
||||
}
|
||||
Some("alias") => membership.set(b"VE".to_vec(), Object::Array(vec![Object::name("Or"), Object::Ref(ObjRef::new(10, 0))])),
|
||||
_ => {}
|
||||
}
|
||||
doc.set(ObjRef::new(9, 0), Object::Dict(membership));
|
||||
doc.set(ObjRef::new(10, 0), Object::Ref(ObjRef::new(8, 0)));
|
||||
let root = doc.root().unwrap();
|
||||
doc.update_dict(root, |d| {
|
||||
d.set(
|
||||
|
||||
Reference in New Issue
Block a user