23369 Commits

Author SHA1 Message Date
Tim van der Meij
93c2ae4896
Merge pull request #21718 from calixteman/fix/file-param-encoding
Don't re-encode the `file` parameter in the viewer
2026-08-06 21:59:41 +02:00
Tim van der Meij
f43ce86470
Merge pull request #21719 from Snuffleupagus/loadType3Data-async
Convert `TranslatedFont.prototype.loadType3Data` to an asynchronous method
2026-08-06 21:52:45 +02:00
Jonas Jenwald
71a3c6a896
Merge pull request #21721 from Snuffleupagus/canvas-SCALE_MATRIX-lazy
Move `SCALE_MATRIX` into `CanvasGraphics` and initialize its `DOMMatrix` lazily (issue 21720)
2026-08-06 14:21:01 +02:00
Jonas Jenwald
ac5aa273f2 Move SCALE_MATRIX into CanvasGraphics and initialize its DOMMatrix lazily (issue 21720)
While this shouldn't affect performance negatively, it does however (ever so slightly) increase the bundle size of the Firefox PDF Viewer.
If that's not desirable, since it's only needed in order to improve Node.js compatibility, we could also just WONTFIX the issue.
2026-08-06 13:26:41 +02:00
Jonas Jenwald
1b4055e958
Merge pull request #21716 from Snuffleupagus/_initializeAutoPrint-jsActions-Map
Update `PDFViewerApplication._initializeAutoPrint` to handle `getJSActions` returning a Map (PR 21664 follow-up)
2026-08-06 11:05:47 +02:00
Jonas Jenwald
1f0659ef9d
Merge pull request #21715 from Snuffleupagus/src-core-annotation-MathClamp
Use the `MathClamp` helper in the `src/core/annotation.js` file
2026-08-06 11:04:41 +02:00
Jonas Jenwald
74fe316f31 Convert TranslatedFont.prototype.loadType3Data to an asynchronous method
The Type3 glyphs are parsed in series, which was implemented by chaining the `getOperatorList` promises together one after another.
Thanks to modern JavaScript this can be simplified a little bit, since we can just `await` within the loop instead.
2026-08-05 23:01:28 +02:00
Calixte Denizet
0ac3b88686 Don't re-encode the file parameter in the viewer
`parseQueryString`, i.e. `URLSearchParams`, has already percent-decoded the
parameter, hence re-encoding it with `encodeURIComponent` and only restoring
the slashes leaves e.g. "?", "&" and "%" escaped. This breaks relative URLs
with a query string, e.g. `?file=%2Fget.jsp%3Fid%3D1%26x%3D2`, and relative
URLs with a percent-encoded path.

The value is now used as-is, except for a "#" in a relative URL which is
still escaped: since the viewer takes its own hash parameters from the
*viewer* URL, a "#" in the `file` parameter is assumed to be part of the
filename (see #19990).

It fixes #20137.
2026-08-05 20:22:55 +02:00
Jonas Jenwald
3f5b472db2 Update PDFViewerApplication._initializeAutoPrint to handle getJSActions returning a Map (PR 21664 follow-up)
This was overlooked in PR 21664, since the code-path in question isn't invoked when scripting is enabled (which is the default value).
2026-08-05 16:48:43 +02:00
Jonas Jenwald
71c5839b03 Use the MathClamp helper in the src/core/annotation.js file 2026-08-05 15:22:15 +02:00
Tim van der Meij
5f181fd8b0
Merge pull request #21707 from calixteman/fix/pdf-editor-copy-new-annotations
Give copied annotations distinct references
2026-08-04 21:30:19 +02:00
calixteman
5ca8134cc1
Merge pull request #21710 from calixteman/eslint-regexp-rules
Enable a few more `eslint-plugin-regexp` rules
2026-08-04 21:05:05 +02:00
Tim van der Meij
8e3a1fd4ad
Merge pull request #21699 from calixteman/fix/pdf-editor-field-parent-cycle
Avoid an infinite loop on cyclic field Parent chains
2026-08-04 20:58:25 +02:00
calixteman
a93bd42724
Enable a few more eslint-plugin-regexp rules
The remaining rules from the plugin's "Best Practices" category that the
recommended config leaves off, plus the two it only warns about, all of
which the code already complies with.

`regexp/prefer-regexp-test` is left off, since `unicorn/prefer-regexp-test`
already covers it.
2026-08-04 20:58:02 +02:00
Tim van der Meij
729ddf907f
Merge pull request #21709 from calixteman/postscript-number-regex
Remove the ambiguity from the PostScript number regex
2026-08-04 20:52:03 +02:00
Tim van der Meij
7aac9fbc6c
Merge pull request #21712 from mozilla/dependabot/npm_and_yarn/fast-uri-3.1.5
Bump fast-uri from 3.1.4 to 3.1.5
2026-08-04 20:50:37 +02:00
Tim van der Meij
724950b457
Merge pull request #21708 from calixteman/regexp-no-super-linear-move
Enable the `regexp/no-super-linear-move` ESLint rule
2026-08-04 20:50:14 +02:00
Tim van der Meij
b75d2b62a3
Merge pull request #21700 from Snuffleupagus/Menu-constructor-shorten
Shorten the `Menu` constructor a tiny bit
2026-08-04 20:47:42 +02:00
Tim van der Meij
27744881e8
Merge pull request #21703 from mozilla/dependabot/github_actions/github/codeql-action/autobuild-4.37.3
Bump github/codeql-action/autobuild from 4.37.2 to 4.37.3
2026-08-04 20:46:35 +02:00
dependabot[bot]
31bf4a09e3
Bump fast-uri from 3.1.4 to 3.1.5
Bumps [fast-uri](https://github.com/fastify/fast-uri) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/fastify/fast-uri/releases)
- [Commits](https://github.com/fastify/fast-uri/compare/v3.1.4...v3.1.5)

---
updated-dependencies:
- dependency-name: fast-uri
  dependency-version: 3.1.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 18:46:28 +00:00
Tim van der Meij
1e824bd4e1
Merge pull request #21704 from mozilla/dependabot/github_actions/github/codeql-action/init-4.37.3
Bump github/codeql-action/init from 4.37.2 to 4.37.3
2026-08-04 20:46:19 +02:00
Tim van der Meij
cc1e80cea4
Merge pull request #21705 from mozilla/dependabot/github_actions/github/codeql-action/analyze-4.37.3
Bump github/codeql-action/analyze from 4.37.2 to 4.37.3
2026-08-04 20:46:03 +02:00
Tim van der Meij
ba02df40c1
Merge pull request #21701 from mozilla/dependabot/npm_and_yarn/undici-7.29.0
Bump undici from 7.28.0 to 7.29.0
2026-08-04 20:44:58 +02:00
calixteman
16f5691df7
Remove the ambiguity from the PostScript number regex
`\d+\.?\d*` can split a run of digits in as many ways as it is long, so
it would backtrack polynomially if anything following it could reject.
The optional exponent can't, hence no bug today, but `\d+(?:\.\d*)?`
accepts the same numbers unambiguously.
2026-08-04 18:48:25 +02:00
calixteman
fc01f7d033
Enable the regexp/no-super-linear-move ESLint rule
It flags the regexes whose search is quadratic in the input length, like
the autolinker and XFA-path ones fixed recently.

The three existing offenders: `\s*` matched the CSS indentation but also
the line terminators that make `^` match with the `m` flag (the
preprocessed CSS is unchanged), `(\d+)` made every digit of a number a
candidate start position, and `/T.*$/` could fail on the `$` and
backtrack since `.` doesn't match a line terminator.
2026-08-04 18:29:27 +02:00
Calixte Denizet
bf7c9258c9 Give copied annotations distinct references
When a viewer page was copied, each copy got its own annotationStorage
entry, but newAnnotationsByPage was keyed only by source page. As a
result, every output copy received all entries and reused their memoized
references.

Tag each entry with its rank among output copies of the same source page.
The display and worker compute this rank independently; inserted documents
preserve the order of copies. Keep unextracted entries at rank -1 so shared
stamp bitmaps remain available without being written. Without ranks, new
annotations are applied only to the first copy.
2026-08-04 17:32:43 +02:00
calixteman
e57a46436f
Merge pull request #21706 from calixteman/test-menu-first-last
Add integration tests for the Home/End keys in the `Menu` class
2026-08-04 16:16:41 +02:00
calixteman
12cde32086
Add integration tests for the Home/End keys in the Menu class
Follow-up to PR #21690: these tests check that pressing Home/End
correctly updates the last focused menu-item index, so that a following
ArrowUp/ArrowDown press doesn't move focus to an unexpected menu-item.
2026-08-04 15:02:01 +02:00
dependabot[bot]
8f7f98e19f
Bump github/codeql-action/analyze from 4.37.2 to 4.37.3
Bumps [github/codeql-action/analyze](https://github.com/github/codeql-action) from 4.37.2 to 4.37.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e0647621c2...e4fba868fa)

---
updated-dependencies:
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 12:16:57 +00:00
dependabot[bot]
93441b8451
Bump github/codeql-action/init from 4.37.2 to 4.37.3
Bumps [github/codeql-action/init](https://github.com/github/codeql-action) from 4.37.2 to 4.37.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e0647621c2...e4fba868fa)

---
updated-dependencies:
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 12:15:21 +00:00
dependabot[bot]
aff4b451e1
Bump github/codeql-action/autobuild from 4.37.2 to 4.37.3
Bumps [github/codeql-action/autobuild](https://github.com/github/codeql-action) from 4.37.2 to 4.37.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](e0647621c2...e4fba868fa)

---
updated-dependencies:
- dependency-name: github/codeql-action/autobuild
  dependency-version: 4.37.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 12:14:06 +00:00
dependabot[bot]
39b973801f
Bump undici from 7.28.0 to 7.29.0
Bumps [undici](https://github.com/nodejs/undici) from 7.28.0 to 7.29.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v7.28.0...v7.29.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 7.29.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-04 11:15:39 +00:00
Jonas Jenwald
1e2c571075 Shorten the Menu constructor a tiny bit
The fallback path used when the `menuItems` aren't provided/correct can be simplified, since the manual loop isn't necessary.
2026-08-04 12:41:46 +02:00
Jonas Jenwald
4806d8294e
Merge pull request #21695 from martinthomson/open-instructions
Document how to use the viewer to open files
2026-08-04 12:18:00 +02:00
Jonas Jenwald
72a76e585b
Merge pull request #21690 from Snuffleupagus/Menu-#goToInitial
Add a go to first/last menu-item helper method in the `Menu` class
2026-08-04 10:20:46 +02:00
calixteman
a7a99fdbd6
Avoid an infinite loop on cyclic field Parent chains
When an AcroForm has no Fields entry, #fixFields rebuilds it by walking
each widget's Parent chain up to its root field. A chain looping back on
itself made that walk spin forever and hung the worker.
2026-08-04 10:19:58 +02:00
Martin Thomson
ca44b47751 Document how to use the viewer to open files
This is not an option that appears in the Firefox integration,
so it is not obvious how to find it.
2026-08-04 09:40:34 +10:00
Jonas Jenwald
fc610d3e59 Add a go to first/last menu-item helper method in the Menu class
This fixes a bug when using the <kbd>Home</kbd> and <kbd>End</kbd> keyboard shortcuts to navigate through a `Menu` instance. These two buttons didn't update the `#lastIndex` field, which means that e.g. a following <kbd>ArrowDown</kbd> or <kbd>ArrowUp</kbd> press could make focus "jump" to an unexpected menu-item.

Also, the helper method reduces a little bit of code duplication in the event handlers.
2026-08-03 22:25:52 +02:00
calixteman
b4ba666b0c
Merge pull request #21694 from calixteman/improve_font_familly_san
Safely serialize CSS font family names
2026-08-03 21:12:10 +02:00
calixteman
4c4e8feafd
Merge pull request #21693 from calixteman/fix/quad-regex-autolinker
Bound the email parts in the autolinker regex
2026-08-03 18:03:43 +02:00
calixteman
f21fe34747
Safely serialize CSS font family names 2026-08-03 18:02:10 +02:00
calixteman
ba7bf7b26c
Merge pull request #21683 from calixteman/fix/quad-regex-writer
Don't write numbers in exponential notation when saving a pdf
2026-08-03 17:49:23 +02:00
calixteman
1da36fb6bf
Merge pull request #21686 from calixteman/fix/quad-regex-xfa-path
Anchor the regex used to extract the XFA path positions
2026-08-03 17:46:24 +02:00
calixteman
92d027eaeb
Anchor the regex used to extract the XFA path positions
Matching the name with a leading `.+` is quadratic in the length of
a component which doesn't end with a position, and every AcroForm
field name goes through this.
2026-08-03 17:07:48 +02:00
calixteman
5375bff642
Don't write numbers in exponential notation when saving a pdf
`toFixed(10)` switches to the exponential notation from 1e21 on, which isn't
valid PDF syntax, and removing the trailing zeros then dropped a digit of the
exponent: 1e30 was written "1e+3" and 1e100 "1e+1". Such a number, necessarily
an integer, is now written with all its digits.

The trailing zeros are removed with a backward scan, since `toFixed(10)` always
produces exactly 10 decimals. Below the 1e21 limit its output is at most 33
characters long, so the previous `$`-anchored regex wasn't a performance issue.
2026-08-03 16:59:12 +02:00
calixteman
b1f51818ae
Bound the email parts in the autolinker regex
The local part and the domain labels were unbounded, making the
search quadratic in the length of a run of characters preceding
an "@": scanning the text of a single page could take seconds.
2026-08-03 16:38:02 +02:00
Tim van der Meij
ae976b924b
Merge pull request #21671 from Snuffleupagus/getFieldObjects-Map
[api-minor] Convert `getFieldObjects` to return data in a Map
2026-08-02 22:37:22 +02:00
Tim van der Meij
ec691130e6
Merge pull request #21692 from calixteman/fix/quad-regex-xml-entities
Exclude "&" from the XML entity names
2026-08-02 22:24:11 +02:00
Jonas Jenwald
88716313d6 Bump library version to 6.3
See commit ce4ff55faaa83b39b0137dc458af6eea6f96235f
2026-08-02 21:27:09 +02:00
Jonas Jenwald
82624a5e50 [api-minor] Convert getFieldObjects to return data in a Map
Compared to regular Objects there's a number of advantages to using Maps:
 - They support proper iteration.
 - They have a simple way to check for the existence of data.
 - They have a simple/efficient way to check the number of elements.

If this functionality was added today, I cannot imagine that we'd choose an Object for this data.

In the Firefox PDF Viewer sending Maps to the scripting-implementation should be fine, since it uses the browser `Cu.cloneInto` functionality; see https://searchfox.org/firefox-main/source/toolkit/components/pdfjs/content/PdfSandbox.sys.mjs
However with QuickJS, used by the GENERIC viewer, all data needs to be stringified and Maps are converted into regular Objects (see also PR 21664). Hence the `objects` property, in the scripting-implementation, is converted back into a Map using the (renamed) `createMap` helper function.
2026-08-02 21:27:07 +02:00