FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: normalize CRLF in CSS and XML/HTML prettifiers by juliosuas · Pull Request #8405 · mitmproxy/mitmproxy · GitHub

fix: normalize CRLF in CSS and XML/HTML prettifiers - #8405

Merged
mhils merged 2 commits into
mitmproxy:mainfrom
juliosuas:fix/contentview-crlf-line-endings
Aug 25, 2026
Merged

fix: normalize CRLF in CSS and XML/HTML prettifiers#8405
mhils merged 2 commits into
mitmproxy:mainfrom
juliosuas:fix/contentview-crlf-line-endings

Conversation

Copy link
Copy Markdown
Contributor

Fixes #8253.

What changed

CSS beautify() and the XML/HTML content view now normalize CRLF/CR to LF before formatting. On Windows, repository files are often checked out with CRLF, so the prettifiers produced output that did not match the LF fixtures.

Tests

Added explicit CRLF regression tests that do not depend on git autocrlf:

  • test_crlf_line_endings in test__view_css.py
  • test_crlf_line_endings in test__view_xml_html.py

pytest test/mitmproxy/contentviews/test__view_css.py test/mitmproxy/contentviews/test__view_xml_html.py — 22 passed.

AI assistance disclosure

OpenAI Codex / Cursor Grok assisted with locating the prettify entry points, adding line-ending normalization, and drafting the regression tests. I reviewed the diff and ran the tests above.

Windows checkouts feed CRLF into the CSS and XML/HTML content views,
which then fail to match the expected LF-formatted fixtures. Normalize
line endings before prettifying so the views are platform-independent.

Fixes #8253.

mhils commented Aug 25, 2026

Copy link
Copy Markdown
Member

Do I read this correctly that this is only an issue in tests? If yes, we should fix the tests.

Copy link
Copy Markdown
Contributor Author

Yes — the reported failures are checkout-dependent tests, not a content-view runtime bug. Thanks for catching that.

I updated the PR to keep the CSS and XML/HTML fixture directories on LF via .gitattributes, and removed both the production normalization and the CRLF behavior tests.

Validation on the updated head:

  • uv run pytest test/mitmproxy/contentviews/test__view_css.py test/mitmproxy/contentviews/test__view_xml_html.py — 20 passed
  • uv run tox -e lint — passed

mhils enabled auto-merge (squash) August 25, 2026 23:37

mhils commented Aug 25, 2026

Copy link
Copy Markdown
Member

Thanks!

mhils merged commit 2ac5b08 into mitmproxy:main Aug 25, 2026
28 checks passed
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSS and XML/HTML prettifiers produce incorrect output on Windows due to CRLF line endings

2 participants


Back | FazBrowse Home | New Git URL