mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
LibPDF: Fix assertion when destination page is an index
This isn't correct per spec, but it happens in practice, e.g. 0000847.pdf, 0000327.pdf, 0000124.pdf from 0000.zip from https://pdfa.org/new-large-scale-pdf-corpus-now-publicly-available/
This commit is contained in:
parent
fbd00d9c8e
commit
8922574133
1 changed files with 9 additions and 1 deletions
|
@ -451,7 +451,15 @@ PDFErrorOr<Destination> Document::create_destination_from_parameters(NonnullRefP
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return Destination { type, page_number_by_index_ref.get(page_ref.as_ref_index()), parameters };
|
||||
// The spec requires page_ref to be an indirect reference to a page object,
|
||||
// but in practice it's sometimes a page index.
|
||||
Optional<u32> page_number;
|
||||
if (page_ref.has<int>())
|
||||
page_number = page_ref.get<int>();
|
||||
else
|
||||
page_number = page_number_by_index_ref.get(page_ref.as_ref_index());
|
||||
|
||||
return Destination { type, page_number, parameters };
|
||||
}
|
||||
|
||||
PDFErrorOr<Optional<NonnullRefPtr<Object>>> Document::get_inheritable_object(DeprecatedFlyString const& name, NonnullRefPtr<DictObject> object)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue