Skip to content

fix: prepend charset meta tag to HTML in save()#823

Open
mrapacz wants to merge 2 commits intoposit-dev:mainfrom
mrapacz:fix-unicode-save-charset
Open

fix: prepend charset meta tag to HTML in save()#823
mrapacz wants to merge 2 commits intoposit-dev:mainfrom
mrapacz:fix-unicode-save-charset

Conversation

@mrapacz
Copy link
Copy Markdown

@mrapacz mrapacz commented Mar 14, 2026

Summary

Headless browsers (like Chrome) can misidentify the encoding of an HTML fragment and corrupt Unicode characters.

Fix: Added a one-liner change as suggested by @rich-iannone, prepending raw html with <meta charset='utf-8'> to make the webdriver recognize encoding and render characters correctly in the resulting image file.

Related GitHub Issues and PRs

Checklist

  • I understand and agree to the Code of Conduct.
  • I have followed the Style Guide for Python Code as best as possible for the submitted code.
  • I have added pytest unit tests for any new functionality.
    N/A - There was no test that would catch this beforehand and I wasn't sure testing 'when we prepend a string with another string, we should test that the prefix is there' warrants a new unit test. But if you think it does, let me know and I'll be happy to add it :)

@mrapacz mrapacz force-pushed the fix-unicode-save-charset branch from e8b68bd to 005a01d Compare March 14, 2026 19:09
Headless browsers (like Chrome) can misidentify the encoding of an HTML
fragment and corrupt Unicode characters. Prepending <meta charset='utf-8'>
ensures that the characters are rendered correctly in the resulting image
file.
@mrapacz mrapacz force-pushed the fix-unicode-save-charset branch from 005a01d to f336ebe Compare March 14, 2026 19:11
@mrapacz mrapacz marked this pull request as ready for review March 14, 2026 19:12
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.32%. Comparing base (8c661f6) to head (5041b06).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #823   +/-   ##
=======================================
  Coverage   92.32%   92.32%           
=======================================
  Files          48       48           
  Lines        6056     6056           
=======================================
  Hits         5591     5591           
  Misses        465      465           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants