Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement escaping for Strings #9

Merged
merged 1 commit into from Oct 6, 2021
Merged

Conversation

rianmcguire
Copy link
Contributor

We discovered a bug where unbalanced parentheses in a \Title string value would cause an invalid PDF to be generated.

Before:

$ echo '<title>abc(</title>' | weasyprint - test.pdf
$ qpdf --check test.pdf
checking test.pdf
PDF Version: 1.7
File is not encrypted
File is not linearized
WARNING: test.pdf (object 2 0, offset 92): EOF while reading token
WARNING: test.pdf (object 2 0, offset 858): unexpected EOF
WARNING: test.pdf (object 2 0, offset 858): parse error while reading object
WARNING: test.pdf (object 2 0, offset 858): expected endobj
WARNING: test.pdf (object 2 0, offset 858): EOF after endobj

After:

$ echo '<title>abc(</title>' | weasyprint - test.pdf
$ qpdf --check test.pdf
checking test.pdf
PDF Version: 1.7
File is not encrypted
File is not linearized
No syntax or stream encoding errors found; the file may still contain
errors that qpdf cannot detect

@liZe
Copy link
Member

liZe commented Oct 6, 2021

Thanks a lot for this PR!

We’ll probably use a regex instead of replace, for performance and readability, but we’ll definitely keep the idea. And thanks a lot for the extra tests!

@liZe liZe merged commit a32fcc6 into CourtBouillon:master Oct 6, 2021
liZe added a commit that referenced this pull request Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants