Skip to content

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

Closed

Description

@hhh714

Problem Description

Bug Description

On Windows, the CSS and XML/HTML content view prettifiers fail to format
correctly because Windows uses CRLF (\r\n) line endings, which are not
normalized before processing.

Steps to Reproduce

  1. Clone the repository on Windows
  2. Run: pytest test/mitmproxy/contentviews/test__view_css.py
  3. Run: pytest test/mitmproxy/contentviews/test__view_xml_html.py

Expected Behavior

All tests pass.

Actual Behavior

4 tests fail with assertion errors showing mismatched line endings.

Fix

Add line ending normalization at the start of the prettify functions:
data = data.replace("\r\n", "\n").replace("\r", "\n")

A PR with the fix is ready.

System Information


Checklist

Activity

  1. added
    kind/triage
    on Jun 1, 2026
  2. added a commit that references this issue on Aug 26, 2026
    2ac5b08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions