Commit Graph

9542 Commits

Author SHA1 Message Date
Yury Delendik
25873e92f0 Enable babel translation to enable ES module support. 2017-03-27 07:25:09 -05:00
Jonas Jenwald
02370f952a Merge pull request #8184 from Rob--W/rethrow-missing-data-if-needed
Rethrow MissingDataException when needed
2017-03-22 18:21:21 +01:00
Rob Wu
49af56f730 Rethrow MissingDataException when needed
In core/document.js: `PDFDocument.prototype.parse` accesses a dictionary
property, which could throw if the underlying data is not yet available.

In core/obj.js: `get Catalog.prototype.metadata` calls
`stream.getBytes`, which can throw MissingDataException too when the
stream is a ChunkedStream.
2017-03-22 14:55:59 +01:00
Rob Wu
086021b21e Merge pull request #8183 from Snuffleupagus/documentInfo-MissingDataException
Ensure that `PDFDocument.documentInfo` doesn't fail during document load, when the entire XRef table hasn't been fetched yet (issue 8180)
2017-03-22 14:46:08 +01:00
Jonas Jenwald
8527d27eae Ensure that PDFDocument.documentInfo doesn't fail during document load, when the entire XRef table hasn't been fetched yet (issue 8180)
Similar to other `try-catch` statements in `/core` code, we must re-throw `MissingDataException` to prevent issues with missing data during document loading.
Note that I'm not sure if/how we can test this, which is why the patch doesn't include any test(s).

Fixes 8180.
2017-03-22 14:14:38 +01:00
Jonas Jenwald
e2e13df4a5 Merge pull request #8164 from Snuffleupagus/issue-7828
Don't read past the EOI marker for JPEG images with non-default restart interval (issue 7828)
2017-03-20 22:17:28 +01:00
Jonas Jenwald
cfc45e556c Merge pull request #8170 from Snuffleupagus/issue-8169
Try to recover when encountering JPEG markers with too short marker lengths (issue 8169)
2017-03-20 20:34:22 +01:00
Jonas Jenwald
d6d0f778aa Don't read past the EOI marker for JPEG images with non-default restart interval (issue 7828)
*After browsing through (a version of) the JPEG specification, see https://www.w3.org/Graphics/JPEG/itu-t81.pdf, I hope that this patch makes sense.*

Note that while issue 7828 became a problem after PR 7661, it isn't really a regression from than PR. The explanation is rather that we're now relying on `core/jpg.js` instead of the Native Image decoder in more situations than before, which thus exposed an *existing* issue in our JPEG decoder.
Another factor also seems to be that in many JPEG images, the DRI (Define Restart Interval) marker isn't present, in which case this bug won't manifest either.

According to https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=89 (at the bottom of the page):
"NOTE – The final restart interval may be smaller than the size specified by the DRI marker segment, as it includes only the number of MCUs remaining in the scan."
Furthermore, according to https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=39 (in the middle of the page):
"[...] If restart is enabled and the restart interval is defined to be Ri, each entropy-coded segment except the last one shall contain Ri MCUs. The last one shall contain whatever number of MCUs completes the scan."

Based on the above, it thus seem to me that we should simply ensure that we're not attempting to continue to parse Scan data once we've found all MCUs (Minimum Coded Unit) of the image.

Fixes 7828.
2017-03-20 17:16:33 +01:00
Jonas Jenwald
be1a6f294f Try to recover when encountering JPEG markers with too short marker lengths (issue 8169)
The issue with the JPEG image in question, is that the COM (Comment) marker has an incorrect length entry.

Fixes 8169.
2017-03-20 17:05:51 +01:00
Yury Delendik
b2ed788ea3 Merge pull request #8172 from Snuffleupagus/bug-1345294
Upstream the changes from bug 1345294 - nsIPrefBranch should have methods to get/set unicode strings
2017-03-20 09:38:07 -05:00
Jonas Jenwald
ebae24cacc Upstream the changes from bug 1345294 - nsIPrefBranch should have methods to get/set unicode strings
Note that in order to not break compatibility for the Firefox addon, the preprocessor is used.

Re: [bug 1345294](https://bugzilla.mozilla.org/show_bug.cgi?id=1345294) and also [this commit](https://hg.mozilla.org/mozilla-central/rev/5a8192a650e9).
2017-03-20 07:36:36 +01:00
Tim van der Meij
3ff872b796 Merge pull request #8174 from Snuffleupagus/eslint-yoda-follow-up
Adjust the `yoda` ESLint rule to apply to inequalities as well
2017-03-19 23:49:47 +01:00
Jonas Jenwald
da326a3137 Update l10n files 2017-03-19 13:46:11 +01:00
Jonas Jenwald
a7c19d9cbb Adjust the yoda ESLint rule to apply to inequalities as well
I happened to notice that some inequalities had the wrong order, and was surprised since I thought that the `yoda` rule should have caught that.
However, reading http://eslint.org/docs/rules/yoda#options a bit more closely than previously, it's quite obvious that the `onlyEquality` option does *exactly* what its name suggests. Hence I think that it makes sense to adjust the options such that only ranges are allowed instead.
2017-03-19 13:27:14 +01:00
Tim van der Meij
f0c45f0336 Merge pull request #8168 from Snuffleupagus/issue-8117
Normalize the `BBox` entry in Tiling Pattern dictionaries (issue 8117)
2017-03-16 23:29:44 +01:00
Jonas Jenwald
098a56270d Normalize the BBox entry in Tiling Pattern dictionaries (issue 8117)
According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3982967, the `BBox` entry should have the form `[left, bottom, right, top]`.
Since some PDF generators apparently violates the specification, we normalize the `BBox` to ensure that the pattern is (correctly) rendered.

Fixes 8117.
2017-03-16 21:43:11 +01:00
Yury Delendik
2b17188998 Merge pull request #8154 from mysterlune/pdfjslib_req_vs_window
Change to conditions that `pdfjsLib`
2017-03-13 10:47:37 -05:00
Tim van der Meij
14b91a479e Merge pull request #8156 from Snuffleupagus/findbar-missing-titles
Add (and adjust) a couple of findbar `title` attributes, in `viewer.html`, that doesn't agree with the `l10n/en-US/viewer.properties` file
2017-03-12 16:15:09 +01:00
Jonas Jenwald
fa341169a2 Add (and adjust) a couple of findbar title attributes, in viewer.html, that doesn't agree with the l10n/en-US/viewer.properties file
The point of this patch is to fix a couple of inconsistencies in `viewer.html`, compared to the locale files, such that the viewer would work correctly even without the `l10n/` files present.
*Note:* Since this isn't changing any of the locale files, we should *not* need to update any of the string names.

Looking through the history of the findbar code, it seems that the `findPrevious`/`findNext` buttons have never had a `title` set (note PR 2168, which was the initial findbar implementation).
Furthermore, the `placeholder` of the `findInput` didn't agree 100% with locale file either, so this is also adjusted.
2017-03-12 09:59:44 +01:00
River Lune
3aeef8402b Changing the order of logical conditions to prefer 'window' in the case where webpack is not used.
Updating brace style.

Updating to throw new error vs. throwing a string.
2017-03-11 19:28:45 -08:00
Jonas Jenwald
224613a511 Merge pull request #8135 from jasonjensen/issue8097
Handle cff fonts with erroneous stackSize (issue 8097)
2017-03-11 09:55:00 +01:00
Tim van der Meij
d471e3568d Merge pull request #8151 from Snuffleupagus/rm-toolbarButton-group-CSS
Remove unnecessary `.toolbarButton.group` CSS class
2017-03-10 22:27:57 +01:00
Jonas Jenwald
8f96909e97 Remove unnecessary .toolbarButton.group CSS class
I noticed that we have a `.toolbarButton.group` CSS class, which is currently applied to some buttons in the viewer. Since it attempts to adjust the `margin-right` property, I was initially a bit puzzled as to why there wasn't different rules for LTR/RTL locales.

However, checking the viewer with the DevTools inspector, in both LTR and RTL locales, I quickly found that the rule in question is *always* being overridden by other CSS rules.
It thus seem to me that while this rule was probably useful at some point, it has been dead for years and could now be removed.
2017-03-10 13:49:24 +01:00
Tim van der Meij
fc5810c97a Merge pull request #8144 from timvandermeij/issue-8143
Widget annotations: do not crash if `Parent` is not a dictionary during field name construction (issue 8143)
2017-03-10 00:40:13 +01:00
Tim van der Meij
936d3c0698
Widget annotations: do not crash if Parent is not a dictionary
during field name construction (issue 8143)
2017-03-09 23:51:52 +01:00
Tim van der Meij
6908f1491d Merge pull request #8132 from timvandermeij/findbar-responsiveness
Viewer: enable find functionality for small devices
2017-03-09 23:03:20 +01:00
Jonas Jenwald
b151666c53
Viewer: consistently wrap find bar elements for small screen sizes
This patch ensures that the find bar is not extended to the window width
when element wrapping occurs on small screens.
2017-03-08 23:55:13 +01:00
Tim van der Meij
87a30a7ee1
Viewer: enable find functionality for small devices
The find functionality is currently not available for small devices
because the find dialog is not responsive. This patch fixes that.

To achieve this goal, the HTML is changed to always show the find
button. To prevent issues because of the addition of an extra button for
small views, the previous/next page buttons are hidden if the view
becomes small. These buttons are not useful anyway because on small
devices navigation is usually done via scrolling. The find functionality
is much more useful to have in this case. Moreover, we wrap the existing
elements into separate `div`s so that the browser can position the
elements itself when the view becomes smaller and logically connected
elements stay together when this happens.

In the CSS, extra rules for the find bar have been added to ensure that
the dialog's doorhanger is always below the find button. All findbar
`div`s are forced to be 32 pixels high to prevent the find message text
being aligned under the checkboxes. Finally, the find message is only
visible when there is actually text to display. This prevents wrapping
issues because, by default, the label has padding and margin even if
there is no text.
2017-03-08 23:54:28 +01:00
Jonas Jenwald
c79e5b3f17
Viewer: replace find label with placeholder/tooltip
This is common in the rest of the UI and helps us prevent responsiveness
issues for different length strings in different locales.
2017-03-08 23:54:14 +01:00
Tim van der Meij
a544a3b4a4 Merge pull request #8138 from Snuffleupagus/bug-1345253
Get rid of `element.removeChild(element.firstChild)` usage (bug 1345253)
2017-03-08 22:29:53 +01:00
Jonas Jenwald
468ed1b9a1 Ensure that the outlineWithDeepNesting CSS class is removed when resetting PDFOutlineViewer, to prevent incorrect alignment if a new document is opened 2017-03-08 17:41:11 +01:00
Jonas Jenwald
e07cb8638e Get rid of element.removeChild(element.firstChild) usage (bug 1345253)
Instead of just upstreaming the changes from [bug 1345253](https://bugzilla.mozilla.org/show_bug.cgi?id=1345253) as-is, it seemed better to simply get rid of the loops altogether and use the same approach as in `PDFViewer`/`PDFThumbnailViewer`.
2017-03-08 17:29:50 +01:00
Jason O. Jensen
d230784ac3 Handle cff fonts with erroneous stackSize 2017-03-06 19:28:46 -05:00
Tim van der Meij
754c4bd0ab Merge pull request #8130 from Snuffleupagus/gulp-lib-rm-web-compatibility
Don't include `web/compatibility.js` in the output for `gulp lib` (PR 8120 follow-up)
2017-03-04 21:27:28 +01:00
Jonas Jenwald
af44ef15f7 Don't include web/compatibility.js in the output for gulp lib (PR 8120 follow-up)
First of all, `compatibility.js` is already available in `lib/shared/compatibility.js`. Second of all, as can be seen in 9142301f35 (diff-9432ebaa58e10ab02874fcb86f689caa), the `lib/web/compatibility.js` file cannot work since the `require` statement isn't compatible with the output of `gulp lib`.
2017-03-04 18:34:28 +01:00
Tim van der Meij
4e3e97be8e Merge pull request #8129 from Snuffleupagus/getInheritedPageProp-undefined
Return `undefined` instead of `Dict.empty` from `Page.getInheritedPageProp` for non-existent properties to prevent possible future bugs
2017-03-04 16:18:24 +01:00
Yury Delendik
c290561488 Merge pull request #8120 from yurydelendik/lib
Publishes processed sources into pdfjs-dist/lib
2017-03-04 08:48:36 -06:00
Jonas Jenwald
9bed87f5dc Return undefined instead of Dict.empty from Page.getInheritedPageProp for non-existent properties to prevent possible future bugs
*This is something that I noticed while working on PR 8126, which is (more) fallout from PR 6065.*

In general, it's actually *not* correct to return `Dict.empty` as the default value for non-existent properties. Please note that a prior PR, see https://github.com/mozilla/pdf.js/pull/5957#issuecomment-103112698, asked for that behaviour but I don't think that's right.

Obviously for properties that are (or should) be `Dict`s it makes sense, however certain properties can be e.g. Strings or Arrays instead. In the latter case, returning `Dict.empty` is just plain wrong, and it's quite fascinating that this hasn't caused any errors in practice. (The existing validation in the various getters has actually saved us here.)

Also, when looking at this code again, it seemed unnecessary to duplicate the `MAX_LOOP_COUNT` check since we could just return immediately instead.
2017-03-04 13:08:39 +01:00
Tim van der Meij
1eb96d7ca9 Merge pull request #8128 from timvandermeij/csp-headers
Network: use the current location to prevent errors when using CSP headers
2017-03-04 00:01:50 +01:00
Yury Delendik
39e8ad24f7 Creates 'lib' for the 'dist' build target. 2017-03-03 16:37:58 -06:00
Yury Delendik
e7cc07cc11 Moves checkProblematicCharRanges to font_spec.js 2017-03-03 16:33:35 -06:00
Job van der Weiden
a05115d2ec
Network: use the current location to prevent errors when using CSP headers
When using content security headers to restrict connections to the same origin,
you may not make connections to `example.com`. This feature detection also
works with a request to the current location.
2017-03-03 23:18:51 +01:00
Jonas Jenwald
24e5b6ee6c Merge pull request #8126 from Snuffleupagus/issue-8125
Ensure that we don't ignore `0` values in `Page.getInheritedPageProp` (issue 8125)
2017-03-03 22:01:59 +01:00
Jonas Jenwald
4a0ff5dbf7 Ensure that we don't ignore 0 values in Page.getInheritedPageProp (issue 8125)
It appears that I accidentally broke this in PR 6065, sorry about that!

The issue in this particular PDF file is that there's `/Rotate` entries on different levels of the `/Pages` tree. We're supposed to use the `/Rotate` entry in the `/Page` dict (which is `0`), but because of an incorrect condition we instead ended up with the one from the `/Pages` dict (which is `180`).

Fixes 8125.
2017-03-03 12:27:40 +01:00
Jonas Jenwald
9163a6fba4 Merge pull request #8112 from Snuffleupagus/JS-action-newWindow
Support the `newWindow` flag in white-listed `app.launchURL` JavaScript actions (PR 7794 follow-up)
2017-03-01 21:24:34 +01:00
Yury Delendik
d0d9843a0e Merge pull request #8087 from yurydelendik/pdf_viewer_req
Allows to pull pdf.js from pdf_viewer using require().
2017-02-28 20:51:18 -06:00
Tim van der Meij
522281c01d Merge pull request #8116 from Snuffleupagus/download_manager-preprocessor
Get rid of a couple `eslint-disable` statements in `web/download_manager.js` by instead relying on the preprocessor dead-code removal added in PR 7942
2017-02-28 22:03:47 +01:00
Tim van der Meij
b75d53a7fa Merge pull request #8115 from Snuffleupagus/CONTRIBUTING-rm-mailing-list
[CONTRIBUTING.md] Remove any mention of the mailing list, and the weekly meetings
2017-02-28 21:52:00 +01:00
Jonas Jenwald
37d596e00d Get rid of a couple eslint-disable statements in web/download_manager.js by instead relying on the preprocessor dead-code removal added in PR 7942 2017-02-28 12:41:43 +01:00
Jonas Jenwald
b0fbfc85f0 [CONTRIBUTING.md] Remove any mention of the mailing list, and the weekly meetings
Given that the mailing list has now been closed, see [bug 1340296](https://bugzilla.mozilla.org/show_bug.cgi?id=1340296), and that there's no weekly meetings any more, we probably shouldn't mention either of those in CONTRIBUTING.md.
Instead, let's just suggest the IRC channel as a means of communication here.
2017-02-28 12:12:57 +01:00