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

Error when filling a value with parentheses #2268

Closed
KanorUbu opened this issue Oct 25, 2023 · 4 comments · Fixed by #2269
Closed

Error when filling a value with parentheses #2268

KanorUbu opened this issue Oct 25, 2023 · 4 comments · Fixed by #2269
Labels
workflow-forms From a users perspective, forms is the affected feature/workflow

Comments

@KanorUbu
Copy link
Contributor

KanorUbu commented Oct 25, 2023

Using parenthesis causes "content stream" to be displayed

Environment

$ python -m platform
Linux-6.2.0-34-generic-x86_64-with-glibc2.35

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==3.16.4, crypt_provider=('cryptography', '41.0.1'), PIL=9.3.0

Code + PDF

from pypdf import PdfReader, PdfWriter
pdf_reader = PdfReader('test_pdf_form.pdf')
pdf_writer = PdfWriter()
pdf_writer.clone_document_from_reader(pdf_reader)
pdf_writer.update_page_form_field_values(pdf_writer.pages[0], {'test_multifield': 'Line1 (test\n brace)Line2'},  auto_regenerate=False)
pdf_writer.write('/tmp/test.pdf')

Example pdf test_pdf_form.pdf

Result

Capture d’écran du 2023-10-25 11-53-39

Solution

Add a escape on parentheses in update_page_form_field_values or _update_text_field

@stefan6419846
Copy link
Collaborator

Do you want to submit a corresponding PR?

@KanorUbu
Copy link
Contributor Author

Yes, I have just proposed a PR

MartinThoma pushed a commit that referenced this issue Oct 28, 2023
@MartinThoma MartinThoma added the workflow-forms From a users perspective, forms is the affected feature/workflow label Oct 28, 2023
@MartinThoma
Copy link
Member

Fixed in #2269

@KanorUbu In future, please add Fixes #2269 or Closes #2269 to the text of the PR. Then the issue gets automatically linked / closed once the PR is merged :-)

MartinThoma added a commit that referenced this issue Oct 29, 2023
## What's new

### Security (SEC)
-  Infinite recursion when using PdfWriter(clone_from=reader) (#2264) by @Alexhuszagh

### New Features (ENH)
-  Add parameter to select images to be removed (#2214) by @pubpub-zz

### Bug Fixes (BUG)
-  Correctly handle image mode 1 with FlateDecode (#2249) by @stefan6419846
-  Error when filling a value with parentheses #2268 (#2269) by @KanorUbu
-  Handle empty root outline (#2239) by @pubpub-zz

### Documentation (DOC)
-  Improve merging docs (#2247) by @stefan6419846

### Developer Experience (DEV)
-  Test Python 3.7 with cryptopgraphy provider as well (#2276) by @stefan6419846
-  Run CI with windows-latest (#2258) by @MartinThoma
-  Use pytest-xdist (#2254) by @MartinThoma
-  Attribute correct authors in the release notes (#2246) by @stefan6419846

### Maintenance (MAINT)
-  Apply pre-commit hooks (#2277) by @MartinThoma
-  Update requirements + mypy fixes (#2275) by @MartinThoma
-  Explicitly provide Any for IO generic argument (#2272) by @nilehmann

### Testing (TST)
-  Fix test_image_without_pillow in windows environment (#2257) by @pubpub-zz

### Code Style (STY)
-  Remove unused import by @MartinThoma

[Full Changelog](3.16.4...3.17.0)
@KanorUbu
Copy link
Contributor Author

@MartinThoma I'll think about doing it next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-forms From a users perspective, forms is the affected feature/workflow
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants