Skip to content

Commit

Permalink
Fix XObject validation to accept any XObject subtype.
Browse files Browse the repository at this point in the history
Instead of generating an error if the XObject subtype is not /Form,
just make the validation of the content stream conditional, and only
apply it to form XObjects.
  • Loading branch information
deven committed May 12, 2024
1 parent b7880eb commit 12fa3a6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/PDF/Data.pm
Original file line number Diff line number Diff line change
Expand Up @@ -608,19 +608,16 @@ sub validate_xobjects {
}
}

# Validate a single form XObject.
# Validate a single XObject.
sub validate_xobject {
my ($self, $path, $xobject) = @_;

# Make sure the form XObject is a stream.
# Make sure the XObject is a stream.
is_stream($xobject) or croak join(": ", $self->{-file} || (), "Error: $path must be a content stream!\n");
$xobject->{-data} //= "";

# Make sure the Subtype is set to /Form.
$xobject->{Subtype} eq "/Form" or croak join(": ", $self->{-file} || (), "Error: $path\->{Subtype} must be /Form!\n");

# Validate the form XObject content stream.
$self->validate_content_stream($path, $xobject);
# Validate the content stream, if this is a form XObject.
$self->validate_content_stream($path, $xobject) if $xobject->{Subtype} eq "/Form";

# Validate resources, if any.
$self->validate_resources("$path\{Resources}", $xobject->{Resources}) if is_hash($xobject->{Resources});
Expand Down

0 comments on commit 12fa3a6

Please sign in to comment.