pdf.js/test
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
..
chromium 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
features Remove usage of mozFillRule 2017-01-29 23:24:44 +01:00
font Resolve deprecation warnings for Jasmine 2018-11-17 23:31:22 +01:00
pdfs Fallback gracefully when encountering corrupt PDF files with empty /MediaBox and /CropBox entries 2019-08-09 10:18:13 +02:00
resources Replace String.prototype.substr() occurrences with String.prototype.substring() 2018-09-28 11:41:07 +02:00
stats Convert some usage of indexOf to startsWith/includes where applicable 2019-01-18 17:57:41 +01:00
ttx Update fonttools location and version (issue 6223) 2015-07-17 12:51:09 +02:00
unit Fallback gracefully when encountering corrupt PDF files with empty /MediaBox and /CropBox entries 2019-08-09 10:18:13 +02:00
.eslintrc Fix badly formatted .eslintrc 2018-11-23 13:49:58 +01:00
.gitignore Ignore test snapshots directory. 2013-03-15 11:24:08 -07:00
add_test.js Replace String.prototype.substr() occurrences with String.prototype.substring() 2018-09-28 11:41:07 +02:00
annotation_layer_builder_overrides.css Implement creation/modification date for annotations 2019-05-05 14:51:03 +02:00
downloadutils.js Convert some usage of indexOf to startsWith/includes where applicable 2019-01-18 17:57:41 +01:00
driver.js Enable the eslint-plugin-no-unsanitized ESLint plugin to disallow unsafe usage of e.g. innerHTML 2019-06-23 13:50:30 +02:00
test_manifest.json Fallback gracefully when encountering corrupt PDF files with empty /MediaBox and /CropBox entries 2019-08-09 10:18:13 +02:00
test_slave.html Use the SimpleLinkService when running "annotations" reference tests 2017-09-12 15:24:46 +02:00
test.js Enable the consistent-return ESLint rule 2019-05-11 14:27:21 +02:00
testutils.js Switch to using ESLint, instead of JSHint, for linting 2016-12-16 21:06:36 +01:00
text_layer_test.css Use span instead of div in the text layer 2018-11-18 15:54:08 +01:00
webbrowser.js Convert some usage of indexOf to startsWith/includes where applicable 2019-01-18 17:57:41 +01:00
webserver.js Fixed test/webserver to handle paths correctly on Windows 2019-07-07 02:42:50 +05:30