Commit Graph

9234 Commits

Author SHA1 Message Date
Tim van der Meij
cf3a7425b6 Compatibility: refactor user agent detection
This patch moves the user agent checks to the top of the file to reduce
duplication and to provide a clear overview of which user agent we are
detecting.

Moreover, we extract inline user agent checks as well and use existing
checks in more places. Finally, we fix the indenting in one place for
consistency.
2016-11-22 22:42:01 +01:00
Tim van der Meij
0b0e18f05c Compatibility: disable range request for iOS
Fixes #7815.
2016-11-22 22:19:20 +01:00
Tim van der Meij
787d887a2f Merge pull request #7793 from Snuffleupagus/ViewHistory-storage-key-name
Rename the `ViewHistory` localStorage (and sessionStorage) key from `database` to `pdfjs.history`, and migrate existing data on read (issue 7760)
2016-11-21 21:16:44 +01:00
Jonas Jenwald
0af42f1ca7 Rename the ViewHistory localStorage (and sessionStorage) key from database to pdfjs.history, and migrate existing data on read (issue 7760)
For consistency, I also renamed the `FIREFOX/MOZCENTRAL` sessionStorage key, but given that sessionStorage is a lot less permanent than localStorage it didn't seem necessary to migrate any existing values.

Fixes 7760.
2016-11-21 21:03:37 +01:00
Jonas Jenwald
8a1ed8ab1f Update l10n files 2016-11-21 17:23:22 +01:00
Tim van der Meij
99b5416ba0 Merge pull request #7830 from Snuffleupagus/paintOnSvg-unsupported
Return a mock object in `paintOnSvg` when SVG rendering is not supported, to prevent `TypeError`s in the addons
2016-11-21 17:09:20 +01:00
Jonas Jenwald
9872660a95 Return a mock object in paintOnSvg when SVG rendering is not supported, to prevent TypeErrors in the addons
Currently if you try to enable SVG rendering in the addons, a `TypeError` is thrown by the browser since we have code that depends on what `paintOnCanvas`/`paintOnSvg` (should) return.
2016-11-19 13:32:17 +01:00
Yury Delendik
9c3419de94 Merge pull request #7826 from Snuffleupagus/PDFPageView_paintOnSvg-FIREFOX-prevent-unreachable-code-after-return-statement-warning
Prevent "unreachable code after return statement" warnings from `PDFPageView_paintOnSvg` in the addons
2016-11-18 14:20:47 -06:00
Jonas Jenwald
7272bb4894 Prevent "unreachable code after return statement" warnings from PDFPageView_paintOnSvg in the addons
Follow-up to PR 7738.
2016-11-18 21:18:27 +01:00
Tim van der Meij
eaf9bff4e4 Merge pull request #7738 from yurydelendik/svg-page
Adds SVG rendering capabilities to the main viewer.
2016-11-18 20:10:12 +01:00
Yury Delendik
f7d6f3a739 Adds SVG rendering capabilities to the PDFViewer. 2016-11-18 13:03:49 -06:00
Yury Delendik
c9a0955c9c Refactors PDFPageView_draw. 2016-11-18 12:57:11 -06:00
Yury Delendik
f6a8d9c4dd Merge pull request #7789 from yurydelendik/toolbar
Refactor toolbar.
2016-11-18 12:53:51 -06:00
Yury Delendik
a4402c84de Refactor toolbar (and secondary toolbar). 2016-11-18 12:51:15 -06:00
Tim van der Meij
043cea251d Merge pull request #7819 from Snuffleupagus/issue-7804
For commands with with too few arguments, clear out `args` if it's an Array instead of replacing it with `null` in `EvaluatorPreprocessor_read` (issue 7804)
2016-11-18 19:04:30 +01:00
Jonas Jenwald
7f678e3af1 Update l10n files 2016-11-17 12:03:31 +01:00
Jonas Jenwald
a930f9af15 For commands with with too few arguments, clear out args if it's an Array instead of replacing it with null in EvaluatorPreprocessor_read (issue 7804)
For `PartialEvaluator_getTextContent`, the same `args` Array should be re-used for every `EvaluatorPreprocessor_read` call. Hence we want to ensure that it's not accidentally replaced with `null` in `EvaluatorPreprocessor_read`, since otherwise corrupt PDF files (with too few arguments for certain commands) will cause errors in `PartialEvaluator_getTextContent`.

Perhaps a micro-optimization, but this patch also changes two `!args` comparisons to `args === null`, since that should be a tiny bit more efficient.
2016-11-16 10:20:29 +01:00
Jonas Jenwald
7f6a607ea5 Merge pull request #7803 from mukulmishra18/master
Fix #7701: additional check for http/https protocols to fix unsafe he…
2016-11-14 13:04:25 +01:00
Mukul Mishra
6ce2be98b7 Fix #7701: additional check for http/https protocols to fix unsafe header request.
add missing ! and removed trailing whitespaces.
2016-11-14 11:39:10 +05:30
Jonas Jenwald
7ec8adc712 Merge pull request #7801 from Snuffleupagus/preprocessor2-remove-comment-except-copyright
Enable removing of all comments (except for Copyright notices) when preprocessing code, and reduce the indentation level
2016-11-11 22:22:30 +01:00
Jonas Jenwald
4f1cccb138 Enable removing of all comments (except for Copyright notices) when preprocessing code, and reduce the indentation level 2016-11-11 22:05:17 +01:00
Jonas Jenwald
a139c75774 Merge pull request #7800 from Snuffleupagus/compatibility-Safari-regex
Replace the Safari detection in `checkRangeRequests` in compatibility.js with a regular expression
2016-11-11 17:57:29 +01:00
Jonas Jenwald
db2ce3ff64 Replace the Safari detection in checkRangeRequests in compatibility.js with a regular expression
According to e.g. issue 7754, it appears that the current `isSafari` check is failing in newer version of the browser. Despite the fact that checking the userAgent is an anti-pattern, which should be avoided, it's currently the simplest solution.
2016-11-11 17:15:24 +01:00
Jonas Jenwald
c23f124051 Merge pull request #7794 from Snuffleupagus/JavaScript-white-listed-actions
[api-minor] Add support for a couple of white-listed `JavaScript` actions that contains valid URLs (issue 3897, bug 843699)
2016-11-09 10:29:05 +01:00
Tim van der Meij
2f5170f28f Merge pull request #7792 from Snuffleupagus/bug-1315608
Make the `customScaleOption` disabled to prevent it being keyboard accessible (bug 1315608)
2016-11-08 21:55:51 +01:00
Jonas Jenwald
6d8a404a9c [api-minor] Add support for a couple of white-listed JavaScript actions that contains valid URLs (issue 3897, bug 843699)
By only allowing very specific type of `JavaScript` actions, and also utilizing the existing `URL` validation, this patch shouldn't pose too much risk.

Fixes one of the points in issue 3897 (with the PDF file taken from issue 3438).
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=843699 (probably, since that bug doesn't contain a test-case).
2016-11-08 16:48:27 +01:00
Jonas Jenwald
a97bc16fbc Make the customScaleOption disabled to prevent it being keyboard accessible (bug 1315608)
Given that the `customScaleOption` should already be hidden, provided that the browser supports that, this patch also prevents it from being accessible via the keyboard.
As far as my testing goes in various browsers, this doesn't seem to have any ill effects, and note that we're already explicitly ignoring the `custom` value in the `select` event handler.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1315608.
2016-11-08 12:04:55 +01:00
Jonas Jenwald
340c6638c5 Merge pull request #7781 from timvandermeij/viewer-responsiveness
Viewer: improve responsiveness and clean up CSS
2016-11-07 17:38:23 +01:00
Tim van der Meij
f95915fc73 Viewer: amend .sidebarOpen responsiveness rules with rules for
`.sidebarMoving`
2016-11-07 16:23:50 +01:00
Tim van der Meij
b428463ecc Merge pull request #7786 from SuriyaaKudoIsc/patch-3
Add HTTPS support for Demo
2016-11-05 15:45:08 +01:00
Suriyaa Kudo
1446e0e64f Add HTTPS support 2016-11-04 15:55:56 +01:00
Jonas Jenwald
b4100ba651 Merge pull request #7698 from Snuffleupagus/bug-1308536
Ignore reserved commands when parsing operands in `CFFParser_parseDict`, instead of just rejecting the entire font (bug 1308536)
2016-11-03 23:53:14 +01:00
Tim van der Meij
28ef012727 Viewer: improve responsiveness and clean up CSS
This patch resolves the responsiveness issues for the toolbar in the
viewer. Depending on the language (for example the Dutch language),
elements could overlap when the viewport size is reduced.

The main issue here is that the CSS rules are unnecessarily complex and
handle lots of different cases (LTR/RTL, displacements for specific
viewport widths, et cetera). By removing this complexity and letting the
browser handle the responsiveness, we not only get simpler CSS rules and
HTML mark-up, but the responsiveness issues are mostly fixed at the same
time. We no longer have to position the elements manually (by setting
their `left` attribute value) anymore.
2016-11-03 22:56:46 +01:00
Tim van der Meij
1d82521b4c Merge pull request #7782 from Snuffleupagus/page-labels-more-validation
Use `stringToPDFString` to sanitizing bad "Prefix" entries in Page Label dictionaries, and add more validation
2016-11-03 22:16:39 +01:00
Tim van der Meij
fe3c12bd16 Merge pull request #7778 from srslafazan/defensive-check-for-mousewheel-handler
Additional check to ensure pdfViewer object is defined before handleMouseWheel event accesses its property isInPresentationMode
2016-11-03 22:03:44 +01:00
Shain Lafazan
7fec8de502 Additional check to ensure pdfViewer object is defined before handleMouseWheel event accesses its property isInPresentationMode 2016-11-03 12:25:16 -07:00
Jonas Jenwald
0844a72b4d Add a bit more validation to Catalog_readPageLabels, to ensure that the Page Labels are well formed 2016-11-03 20:08:06 +01:00
Jonas Jenwald
2d8d8b5e53 Use stringToPDFString to sanitizing bad "Prefix" entries in Page Label dictionaries
It seems that certain bad PDF generators can create badly encoded "Prefix" entries for Page Labels, one example being http://ukjewishfilm.org/wp-content/uploads/2015/09/Jewish-Film-Festival-Programme-ONLINE.pdf.

Unfortunately I didn't come across such a PDF file while adding the API support for Page Labels, but with them now being used in the viewer I just found this issue. With this patch, we now display the Page Labels in the same way as Adobe Reader.
2016-11-03 19:48:08 +01:00
Jonas Jenwald
9dc6463933 Ignore reserved commands when parsing operands in CFFParser_parseDict, instead of just rejecting the entire font (bug 1308536)
According to the CFF specification, see http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf#page=11, certain commands are currently reserved.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1308536.
2016-11-03 12:50:40 +01:00
Tim van der Meij
9f8d67475e Merge pull request #7775 from timvandermeij/widget-annotation-name
Widget annotation: implement field name according to the specification
2016-11-02 22:43:17 +01:00
Tim van der Meij
1d96854019 Widget annotation: implement field name according to the specification
The original code is difficult to read and, more importantly, performs
actions that are not described in the specification. It replaces empty
names with a backtick and an index, but this behavior is not described
in the specification. While the specification is not entirely clear
about what should happen in this case, it does specify that the `T`
field is optional and that multiple field dictionaries may have the same
fully qualified name, so to achieve this it makes the most sense to
ignore missing `T` fields during construction of the field name. This is
the most specification-compliant solution and, judging by opened issue #6623, also the required and expected behavior.
2016-11-02 21:44:44 +01:00
Tim van der Meij
6e22b32372 Merge pull request #7745 from Snuffleupagus/Launch-actions
[api-minor] Add basic support for `Launch` actions (issue 1778, issue 3897, issue 6616)
2016-11-01 21:12:08 +01:00
Jonas Jenwald
9295114bdd Merge pull request #7774 from timvandermeij/lint
Improve lint coverage and correct code style violations
2016-11-01 16:53:51 +01:00
Tim van der Meij
5194e68134 Lint: correct code style violations
Manual observations and working with other linting tools found these.
2016-11-01 15:04:21 +01:00
Tim van der Meij
978b214c92 Lint: do not ignore external/importL10n as it is one of our components 2016-11-01 14:43:38 +01:00
Tim van der Meij
c719762099 Lint: update .jshintignore
Remove folders that no longer exist and ignore folders with binary/PDF
files.
2016-11-01 14:39:35 +01:00
Tim van der Meij
29fc2f9908 Merge pull request #7773 from Snuffleupagus/update-swedish-l10n
[l10n] Add Swedish translations for a couple of new/changed localization IDs
2016-11-01 13:32:41 +01:00
Jonas Jenwald
40d2d3f569 [l10n] Add Swedish translations for a couple of new/changed localization IDs
I got tired of staring at a bunch of localization warnings every time that I open the console, hence this patch adds the missing translations to the Swedish locale.
2016-11-01 10:09:47 +01:00
Tim van der Meij
c8158dc672 Merge pull request #7771 from timvandermeij/l10n-updates
Localization updates
2016-10-31 23:44:55 +01:00
Tim van der Meij
775b294bb9 L10n: import upstream translations 2016-10-31 23:35:05 +01:00