pdf.js/test/unit
Jonas Jenwald d637b25e36 Fallback gracefully when encountering corrupt PDF files with empty /MediaBox and /CropBox entries
This is based on a real-world PDF file I encountered very recently[1], although I'm currently unable to recall where I saw it.
Note that different PDF viewers handle these sort of errors differently, with Adobe Reader outright failing to render the attached PDF file whereas PDFium mostly handles it "correctly".

The patch makes the following notable changes:
 - Refactor the `cropBox` and `mediaBox` getters, on the `Page`, to reduce unnecessary duplication. (This will also help in the future, if support for extracting additional page bounding boxes are added to the API.)
 - Ensure that the page bounding boxes, i.e. `cropBox` and `mediaBox`, are never empty to prevent issues/weirdness in the viewer.
 - Ensure that the `view` getter on the `Page` will never return an empty intersection of the `cropBox` and `mediaBox`.
 - Add an *optional* parameter to `Util.intersect`, to allow checking that the computed intersection isn't actually empty.
 - Change `Util.intersect` to have consistent return types, since Arrays are of type `Object` and falling back to returning a `Boolean` thus seem strange.

---

[1] In that case I believe that only the `cropBox` was empty, but it seemed like a good idea to attempt to fix a bunch of related cases all at once.
2019-08-09 10:18:13 +02:00
..
annotation_spec.js [api-minor] Implement quadpoints for annotations in the core layer 2019-07-28 20:36:21 +02:00
api_spec.js Fallback gracefully when encountering corrupt PDF files with empty /MediaBox and /CropBox entries 2019-08-09 10:18:13 +02:00
bidi_spec.js Convert the files in the /test/unit folder to ES6 modules 2017-04-30 00:34:02 +02:00
cff_parser_spec.js Add unique glyph names for CFF fonts. 2019-02-27 15:00:29 -08:00
clitests_helper.js Reduce the amount of console "spam", by ignoring info/warn calls, when running the unit-tests in Node.js/Travis 2018-06-03 00:28:40 +02:00
clitests.json Run the custom_spec unit-tests in Node.js/Travis (PR 10537 follow-up) 2019-02-26 22:40:55 +01:00
cmap_spec.js Rename the src/display/dom_utils.js file to src/display/display_utils.js 2019-02-23 16:30:16 +01:00
colorspace_spec.js Add caching to reduce the number of Ref objects 2019-05-26 12:23:37 +02:00
core_utils_spec.js Add caching to reduce the number of Ref objects 2019-05-26 12:23:37 +02:00
crypto_spec.js Convert the files in the /test/unit folder to ES6 modules 2017-04-30 00:34:02 +02:00
custom_spec.js Rename the src/display/dom_utils.js file to src/display/display_utils.js 2019-02-23 16:30:16 +01:00
display_svg_spec.js Restore the btoa/atob polyfills for Node.js 2018-01-13 01:31:05 +01:00
display_utils_spec.js Implement creation/modification date for annotations 2019-05-05 14:51:03 +02:00
document_spec.js Add a getDocId method to the idFactory, in Page instances, to avoid passing around PDFManager instances unnecessarily (PR 7941 follow-up) 2019-04-20 13:11:17 +02:00
encodings_spec.js Implement unit tests for the encodings and fix missing items 2017-12-24 18:14:40 +01:00
evaluator_spec.js Add a getDocId method to the idFactory, in Page instances, to avoid passing around PDFManager instances unnecessarily (PR 7941 follow-up) 2019-04-20 13:11:17 +02:00
fetch_stream_spec.js Ensure that ReadableStreams are cancelled with actual Errors 2019-08-01 16:40:46 +02:00
function_spec.js Update the ESLint dependencies, and also tweak the no-multiple-empty-lines rules 2018-01-03 13:32:57 +01:00
jasmine-boot.js Add fetch stream spec 2019-04-07 13:14:03 +02:00
message_handler_spec.js Ensure that ReadableStreams are cancelled with actual Errors 2019-08-01 16:40:46 +02:00
metadata_spec.js Implement a unit test for metadata parsing to ensure that it's not vulnerable to the billion laughs attack 2019-01-19 19:54:08 +01:00
murmurhash3_spec.js Convert the files in the /test/unit folder to ES6 modules 2017-04-30 00:34:02 +02:00
network_spec.js Ensure that ReadableStreams are cancelled with actual Errors 2019-08-01 16:40:46 +02:00
network_utils_spec.js decode filename when match an urlencode filename from contentDispositionFilename 2019-07-31 09:33:56 +08:00
node_stream_spec.js Ensure that ReadableStreams are cancelled with actual Errors 2019-08-01 16:40:46 +02:00
parser_spec.js Change the signature of the Parser constructor to take a parameter object 2019-06-23 16:01:45 +02:00
pdf_find_controller_spec.js Remove left-over console log from the find controller unit tests 2019-01-12 22:27:40 +01:00
pdf_find_utils_spec.js Add initial support for "Whole words" searching in the viewer 2018-09-10 11:59:29 +02:00
pdf_history_spec.js Fix a PDFHistory regression with document hashes of the nameddest=... form 2017-10-09 21:58:54 +02:00
primitives_spec.js Add caching to reduce the number of Ref objects 2019-05-26 12:23:37 +02:00
stream_spec.js Make the getBytes/peekBytes methods of Stream/DecodeStream/ChunkedStream able to return Uint8ClampedArrays 2018-06-12 11:01:32 +02:00
test_utils.js Add a getDocId method to the idFactory, in Page instances, to avoid passing around PDFManager instances unnecessarily (PR 7941 follow-up) 2019-04-20 13:11:17 +02:00
testreporter.js Reword test reporter message 2018-08-05 21:21:46 +02:00
type1_parser_spec.js Fix inconsistent spacing and trailing commas in objects in test/ files, so we can enable the comma-dangle and object-curly-spacing ESLint rules later on 2017-06-02 13:04:04 +02:00
ui_utils_spec.js Convert some usage of indexOf to startsWith/includes where applicable 2019-01-18 17:57:41 +01:00
unicode_spec.js Convert the files in the /test/unit folder to ES6 modules 2017-04-30 00:34:02 +02:00
unit_test.html Replaces RequireJS to SystemJS. 2017-02-27 08:32:39 -06:00
util_spec.js Move worker-thread only functions from src/shared/util.js and into a new src/core/core_utils.js file 2019-02-24 00:35:39 +01:00