[pull] master from mozilla:master#449
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 : )