Skip to content

[pull] master from mozilla:master#449

Merged
pull[bot] merged 8 commits into
code:masterfrom
mozilla:master
Jul 5, 2026
Merged

[pull] master from mozilla:master#449
pull[bot] merged 8 commits into
code:masterfrom
mozilla:master

Conversation

@pull

@pull pull Bot commented Jul 5, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

greymoth-jp and others added 8 commits July 4, 2026 21:37
…codeString

encodeString has the same surrogate-pair guard that encodeToXmlString had
before #21526: `unicode > 0xd7ff && (unicode < 0xe000 || unicode > 0xfffd)`.
That predicate is also true for U+FFFE and U+FFFF, which are single UTF-16
code units, not surrogate pairs. The extra `i++` then steps over the
character that follows them, so it is silently dropped from the
font-encoded output used when saving or printing a PDF.

For example, encoding a string that is U+FFFF followed by "A", with a font
that has a glyph for both, returns an encoded result ending in "A" on this
branch but drops the "A" on master.

Same fix as #21526: the correct test for a real surrogate pair is
`unicode > 0xffff`, since codePointAt only returns a value at or above
0x10000 for an actual pair. This keeps existing behavior for real surrogate
pairs (e.g. emoji) and the U+FFFD boundary, and only stops the character
after U+FFFE/U+FFFF from being dropped.

Added test/unit/fonts_spec.js, since Font.prototype.encodeString had no
direct unit test. It calls the method on a minimal fake `this` (only
toUnicode/cMap are read), since building a full Font requires a complete
properties/font-file setup that this bug doesn't depend on.
`getCharacterType` was a port of the old `WordBreaker::GetClass`,
which has been removed and replaced with ICU4X word segmentation.
Use `Intl.Segmenter` instead, testing each match boundary on the two
adjacent grapheme clusters in isolation like Firefox's find.

It fixes #21520.
…-fffff

Do not drop the character after U+FFFE or U+FFFF in Font.prototype.encodeString
…m` method

Using an intermediate variable seems completely unnecessary here.

Also, while unrelated, move a `HINTING_ENABLED` check to avoid pointless Array-length checks.
When the marked content `id` is defined it'll always be a string, hence wrapping it in a string when setting the attribute is pointless; note https://github.com/mozilla/pdf.js/blob/e148b154cdff4344db1bc263fe3b546b03eff5ae/src/core/evaluator.js#L3529-L3531
…d-string

Don't needlessly wrap the marked content `id`-attribute in a string
Lookup "lenIV" inline in the `Type1Parser.prototype.extractFontProgram` method
Use `Intl.Segmenter` for the entire-word search matching
@pull pull Bot locked and limited conversation to collaborators Jul 5, 2026
@pull pull Bot added the ⤵️ pull label Jul 5, 2026
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot merged commit bf924ff into code:master Jul 5, 2026
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
@pull pull Bot had a problem deploying to code-coverage July 5, 2026 20:03 Failure
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants