1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00
Commit graph

20109 commits

Author SHA1 Message Date
Jonas Jenwald
e1760aab8d Use the stopEvent helper function everywhere possible 2024-11-28 13:25:56 +01:00
calixteman
22babd722f
Merge pull request #19109 from calixteman/click_when_dragging
[Editor] Disallow to have multiple pointers while dragging an editor
2024-11-27 20:26:45 +01:00
Calixte Denizet
e695d04ca2 [Editor] Disallow to have multiple pointers while dragging an editor
It'll let the user dragging with two fingers.
2024-11-27 19:41:13 +01:00
Jonas Jenwald
fd31e728f7 Disable the browser-tests in Google Chrome on the bots
Given that `browsertest` repeatedly timeout in Google Chrome, and considering that Firefox is the primary development target, we stop running them on the bots to avoid having to repeatedly deal with this.

Note that we already disabled these tests *on Windows* almost three years ago, because of stability issues; see PR 14392.
2024-11-27 17:59:51 +01:00
calixteman
052b001f0e
Merge pull request #19111 from calixteman/fix_highlight_test_with_kb
Fix the highlight integration test when highlighting with the keyboard
2024-11-27 16:10:38 +01:00
Calixte Denizet
5d77a64e1f Fix the highlight integration test when highlighting with the keyboard
These tests were failing with Puppeteer 23.9.0.
2024-11-27 15:38:33 +01:00
Jarklee
2200f0523c Fix #serializeBoxes bug inconsistent with deserialize function for highlight editor.
Add test for quadPoints order while serializing.
2024-11-27 14:19:31 +07:00
calixteman
079eb24621
Merge pull request #19100 from Rob--W/test-trailing-whitespace-fixup
Drop trailing whitespace from test/unit/api_spec.js
2024-11-25 09:32:02 +01:00
Rob Wu
131d4650a5 Drop trailing whitespace from test/unit/api_spec.js
test/unit/api_spec.js is the only JS file in the tree with trailing
whitespace. Because `trim_trailing_whitespace = true` in .editorconfig,
any editor supporting EditorConfig would trim whitespace when the file
is changed, which results in test failures.

This commit fixes the issue by trimming the trailing whitespace and
adjusting the test expectations.
2024-11-24 23:37:16 +01:00
Tim van der Meij
725ae4998c
Fix the type definition of the fingerprints getter in src/display/api.js
The `Array` type takes one parameter that describes the possible types
of the inner  elements. This parameter may exist of pipes to indicate
multiple possible types. However, the current type definition provides
multiple parameters; this is incorrect syntax, and TypeScript 5.7+ now
fails on this due to stricter syntax validation.

This commit fixes the issue by changing the type definition to the
proper syntax, which together with the accompanying comment about the
contents of the fingerprints array should document it sufficiently.
2024-11-24 21:53:45 +01:00
Tim van der Meij
d45a61b579
Merge pull request #19091 from Snuffleupagus/getPdfManager-async
Convert the `getPdfManager` function to be asynchronous
2024-11-24 15:36:29 +01:00
Tim van der Meij
8ae5b4e442
Merge pull request #19096 from Rob--W/test-server-hardening
Fix path traversal issue in createTemporaryNodeServer
2024-11-24 15:30:22 +01:00
calixteman
9017e80d5a
Merge pull request #19095 from calixteman/issue17190
Rescale the image data when they're really too large
2024-11-24 14:30:37 +01:00
Jonas Jenwald
f911635b58
Merge pull request #19028 from Snuffleupagus/issue-12744
Ensure that the response-origin of range requests match the full request (issue 12744)
2024-11-24 10:37:07 +01:00
Jonas Jenwald
6a015588b9 Ensure that the response-origin of range requests match the full request (issue 12744)
The following cases are excluded in the patch:
 - The Firefox PDF Viewer, since it has been fixed on the platform side already; please see https://bugzilla.mozilla.org/show_bug.cgi?id=1683940

 - The `PDFNodeStream`-implementation, used in Node.js environments, since after recent changes that code only supports `file://`-URLs.

Also updates the `PDFNetworkStreamFullRequestReader.read`-method to await the headers before returning any data, similar to the implementation in `src/display/fetch_stream.js`.

*Note:* The relevant unit-tests are updated to await the `headersReady` Promise before dispatching range requests, since that's consistent with the actual usage in the `src/`-folder.
2024-11-24 10:08:29 +01:00
Calixte Denizet
1ef670411a Rescale the image data when they're really too large
It fixes #17190.
2024-11-23 22:42:30 +01:00
Rob Wu
17da8ee8fa Fix path traversal issue in createTemporaryNodeServer
The test-only createTemporaryNodeServer helper featured a path traversal
vulnerability. This enables attackers with network access to the device
to read arbitrary files while unit tests are running that activate this
test server.

This patch fixes the issue by validation of paths.

To test this vulnerability before the patch:

1. Run the test-only server:

```
node -e 'console.log(require("./test/unit/test_utils.js").createTemporaryNodeServer().port)
```

2. From another terminal, send the following request (modify the port to
   the port reported in the previous step):

```
curl --path-as-is http://localhost:45755/../../package.json
```

Before the patch, the second step would traverse the directory, and
return results from the root of the PDF.js repository, instead of files
within test/pdfs/.

With the patch, the server refuses the request with HTTP status 400.
2024-11-23 21:32:24 +01:00
Jonas Jenwald
8ec399d7e1 Convert the getPdfManager function to be asynchronous
This is fairly old code, and by making the function `async` we can handle initialization errors "automatically" without the need for try-catch statements.
2024-11-22 17:49:43 +01:00
calixteman
1f6cc85134
Merge pull request #19088 from calixteman/no_movementXY
[Editor] Avoid to use event.movementX/Y when resizing an editor
2024-11-22 16:59:54 +01:00
Calixte Denizet
c08b5b2a94 [Editor] Avoid to use event.movementX/Y when resizing an editor
Those propertie can have some non-expected values so use screenX/Y instead.
2024-11-22 14:55:53 +01:00
calixteman
086cb6630e
Merge pull request #19087 from calixteman/no_scroll_when_dragging
[Editor] Avoid to scroll when dragging an editor on a touch screen
2024-11-22 09:53:49 +01:00
calixteman
5133e6b666
Merge pull request #19085 from calixteman/simplify_drawer
[Editor] Simplify the draw layer code
2024-11-22 09:16:48 +01:00
Calixte Denizet
aef150d38a [Editor] Avoid to scroll when dragging an editor on a touch screen 2024-11-21 22:54:07 +01:00
calixteman
5b600e8f84
Merge pull request #19086 from calixteman/issue19083
Use the V entry as an option when no options in a choice widget
2024-11-21 18:40:04 +01:00
Calixte Denizet
3c343acbb6 [Editor] Simplify the draw layer code
and tweak a bit the highlight one (e.g. it's useless to have 64 bits floating point numbers
when 32 bits ones are enough).

It's a required step for the refactoring of the ink tool (in order to use the draw layer).
It avoids to call several functions acting on the same SVG element.
2024-11-21 17:50:35 +01:00
Calixte Denizet
b0b0de98e7 Use the V entry as an option when no options in a choice widget
It fixes #19083.

It isn't really a fix but more a workaround (we should correctly implement the
choice widget as a mix of text input+select).
2024-11-21 17:27:34 +01:00
Jonas Jenwald
445b7ece61
Merge pull request #19084 from Snuffleupagus/getUuid-shorten
Simplify the `getUuid` helper function
2024-11-21 15:17:14 +01:00
Jonas Jenwald
c290a12ce1 Simplify the getUuid helper function
We can remove most feature testing from this helper function, with the exception of `randomUUID` since that's only available in "secure contexts", and also remove the fallback code-path.
Note that this code was only added for Node.js compatibility, and it's no longer necessary now that the minimum support version is `20`; see also https://developer.mozilla.org/en-US/docs/Web/API/Crypto#browser_compatibility

Finally, this patch also adds a basic unit-test for the helper function.
2024-11-21 13:11:10 +01:00
Tim van der Meij
07765e993e
Merge pull request #19069 from calixteman/stamp_test
Fix 'must load a SVG, delete it and undo' integration test
2024-11-19 20:42:12 +01:00
Tim van der Meij
c31ccc6847
Merge pull request #19071 from Snuffleupagus/no-single-promise-in-promise-methods
Enable the `unicorn/no-single-promise-in-promise-methods` ESLint plugin rule
2024-11-19 20:33:33 +01:00
Tim van der Meij
e8fbb602c5
Merge pull request #19064 from timvandermeij/fix-intermittent
Fix the "must check that an infinite loop is not triggered" integration test
2024-11-19 20:31:49 +01:00
Jonas Jenwald
b38b12d48a Enable the unicorn/no-single-promise-in-promise-methods ESLint plugin rule
Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-single-promise-in-promise-methods.md
2024-11-19 11:39:02 +01:00
Calixte Denizet
eefaca07c3 Fix 'must load a SVG, delete it and undo' integration test
We wait for the canvas before trying to serialize the annotation in order to make sure the image has been loaded.
2024-11-18 21:25:59 +01:00
Jonas Jenwald
f4061190fa
Merge pull request #19068 from nicolo-ribaudo/json-imports
Use JSON imports instead of PDFJSDev.json
2024-11-18 16:37:37 +01:00
Nicolò Ribaudo
a8592d86a9
Use JSON imports instead of PDFJSDev.json
JSON imports are now supported by all tools used in PDF.js' build
process. The `chromecom.js` file is bundled by webpack and
import attributes are thus removed, so browser compatibility for this
new syntax is not relevant.
2024-11-18 16:21:12 +01:00
calixteman
658a0a16c1
Merge pull request #18669 from calixteman/stylint_update
Update svglint to 3.1.0
2024-11-18 15:11:57 +01:00
Calixte Denizet
1c5d93cf2d Update svglint to 3.1.0
The new release contains:
 - https://github.com/simple-icons/svglint/pull/110
 - https://github.com/simple-icons/svglint/pull/111

which allow us to slightly simplify our code.
2024-11-18 15:00:07 +01:00
Tim van der Meij
973b67f047
Fix the "must check that an infinite loop is not triggered" integration test
This integration test fails intermittently, locally at least in Chrome
with Puppeteer 23.4.0+, with the following errors:

```
In chrome: Expected '123Hello' to equal 'Hello123'.
In chrome: Expected '123Hello' to equal '123'.
```

This happens because the test before it left queued sandbox events
behind. We don't close the document between tests, so those get run
when we click the textbox in this test and that interferes with our
selection/typing actions. This commit fixes the issue by flushing the
queued sandbox events in the first test, which makes sure that state
no longer leaks through to the next test and thus improves isolation.

Morever, similar to commit 3adf8b6 we use safer assertions to avoid
further intermittent failures, and we replace the `page.$eval` call
with a simpler Home button push like we already do in e.g. the test
helpers. This combined makes the code shorter and simpler.
2024-11-17 21:23:04 +01:00
Tim van der Meij
3219d4905d
Merge pull request #19061 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-11-17 19:59:15 +01:00
Tim van der Meij
21137963b2
Merge pull request #19062 from timvandermeij/gitpod
Remove obsolete Gitpod files
2024-11-17 19:57:53 +01:00
Tim van der Meij
e18cf97733
Update translations to the most recent versions 2024-11-17 19:55:28 +01:00
Tim van der Meij
50d79736f5
Update dependencies to the most recent versions 2024-11-17 19:55:28 +01:00
Tim van der Meij
093485d491
Remove obsolete Gitpod files
In PR #11300 Gitpod support got introduced, but we re-evaluated that
decision in #11732. In PR #11800 the support was partially reverted,
but the actual Gitpod files were kept to not outright break potential
workflows because at the time we were not sure if, and if so how often,
Gitpod was actually used for contributing to PDF.js.

However, in addition to the concerns mentioned in #11732 after five
years we haven't seen any contributions that clearly originated from
Gitpod, and the files have not been updated after e.g. PR #11807 and
PR #17913 because it's not a workflow that we maintain or are able
to test (nor have we seen Gitpod community contributions for this).

This commit therefore removes the remaining Gitpod files to reduce
maintainance burden for PDF.js. Note that users of Gitpod can still
contribute to PDF.js via the platform; we just don't provide/manage
workspace files from this repository anymore.
2024-11-17 19:52:48 +01:00
calixteman
8a8b69f456
Merge pull request #19054 from calixteman/issue18630
When saving some annotations with the same name, set the value in the parent
2024-11-17 18:00:48 +01:00
Tim van der Meij
e2bbcb544a
Merge pull request #19045 from Snuffleupagus/api-rm-isChrome
[api-minor] Disable `ImageDecoder` usage by default in Chromium browsers
2024-11-17 16:32:48 +01:00
Tim van der Meij
fc0484904e
Merge pull request #19059 from Snuffleupagus/DOMFilterFactory-rm-_hcmCache
Improve clean-up of `#_hcmCache`-data in `DOMFilterFactory.prototype.destroy`
2024-11-17 16:31:37 +01:00
Calixte Denizet
2da586527f When saving some annotations with the same name, set the value in the parent
It fixes #18630.
2024-11-17 15:55:20 +01:00
Jonas Jenwald
4c57ec4da7 Improve clean-up of #_hcmCache-data in DOMFilterFactory.prototype.destroy
- Use optional chaining when clearing various data-structures, since that's slightly shorter.

 - Ensure that checking for the existence of `#_hcmCache`-data won't cause it to be initialized. (Note how `this.#hcmCache` is actually a getter.)

 - Actually reset the `#_hcmCache`-data when that's appropriate, e.g. when closing the PDF document.
2024-11-17 15:31:42 +01:00
Jonas Jenwald
bc91985941
Merge pull request #19051 from Snuffleupagus/Dict-Map
Convert the `Dict`-implementation to use a `Map` internally
2024-11-17 12:59:02 +01:00
Jonas Jenwald
823e700b3b
Merge pull request #19057 from Snuffleupagus/extendCMap-avoid-lookup
Avoid redundant CMap-value lookup in `extendCMap` (PR 5101 follow-up)
2024-11-17 12:49:20 +01:00