Skip to content

fix: handle emoji/special-character PDF paths in ASCII terminals#52

Open
ambicuity wants to merge 1 commit intoSUPAIDEAS:mainfrom
ambicuity:fix/issue-23-emoji-path-output
Open

fix: handle emoji/special-character PDF paths in ASCII terminals#52
ambicuity wants to merge 1 commit intoSUPAIDEAS:mainfrom
ambicuity:fix/issue-23-emoji-path-output

Conversation

@ambicuity
Copy link
Copy Markdown
Contributor

@ambicuity ambicuity commented Mar 27, 2026

Summary

  • fix CLI output encoding so successful encryption does not fail when terminal output is ASCII-only
  • safely render emoji/special-character paths using escaped fallback text when needed
  • add unit + integration tests for PYTHONIOENCODING=ascii with emoji file paths
  • update README Known Issues to reflect current behavior

Why

Issue #23 reports that special characters/emojis in file paths cause a minor complaint during execution.
Root cause: success logging attempted to print non-ASCII paths directly, which can raise UnicodeEncodeError in ASCII output environments and incorrectly return a failure exit code.

Validation

  • poetry run coverage run -m unittest discover tests
  • manual reproduction with real PDF + emoji paths under PYTHONIOENCODING=ascii now returns exit code 0 and writes output successfully

Closes #23

Copilot AI review requested due to automatic review settings March 27, 2026 17:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a CLI exit-code regression where printing success/error messages could raise UnicodeEncodeError in ASCII-only output environments when file paths include emoji/special characters, causing a false failure despite successful encryption.

Changes:

  • Add _stream_safe_text / _safe_print helpers and route CLI messaging through them to avoid encoding exceptions.
  • Add unit + integration coverage to validate ASCII-only stdout behavior with emoji paths.
  • Update README “Known Issues” to reflect current behavior (emoji paths supported; PDF-object warnings may still appear).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
passifypdf/encryptpdf.py Introduces encoding-safe printing for CLI success/error output to prevent UnicodeEncodeError from impacting exit codes.
tests/unittests/test_encryptpdf.py Adds a unit test that runs main() with ASCII-only stdout/stderr and verifies escaped output + success exit code.
tests/integrationtests/test_encryptpdf_integration.py Adds a subprocess integration test with PYTHONIOENCODING=ascii to ensure the CLI succeeds and produces an escaped path.
README.md Updates “Known Issues” to remove outdated emoji-path warning and document current behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Bug: Special characters and emojis in PDF file paths cause minor complaints

2 participants