Repository navigation
Conversation
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Origin: B) AI found a possible change because I asked it do so
My contribution includes AI-generated content, as disclosed below:
This is the same fix as #10182, which was closed after the question there went unanswered. To answer it:
PdfParser.get_literal_string(). Inre_lit_str_token, group 5 is an unescaped\r\n,\ror\n, andturns each of them into a single
\n. This follows PDF 32000-1:2008 section 7.3.4.2: an end-of-line marker in a literal string without a preceding backslash "shall be treated as a byte value of (0Ah), irrespective of whether the end-of-line marker was a CARRIAGE RETURN (0Dh), a LINE FEED (0Ah), or both". It only applies to(...)literal strings; hex strings are unaffected, and names already write\ras#0D.It matters because
pdf_repr()writesstrvalues as UTF-16BE inside a literal string, without escaping\r. Any character with a 0x0D byte comes back different:Every Malayalam and Sinhala character has 0x0D as its high byte, so a subject like "മലയാളം" comes back as "ਮਲਯਾਲ਼ਂ", and "ഊ" (U+0D0A) loses a byte and raises
UnicodeDecodeErrorwhen read. qpdf shows the same corruption on files written before this change.Changes proposed in this pull request:
\ras\\rinpdf_repr()for bytespdf_reprassertion, and a test that saves a PDF with these values and reads them back