Skip to content

Preserve quoted greater-than characters in XML/HTML attributes - #8518

Closed
hakarrr wants to merge 2 commits into
mitmproxy:mainfrom
hakarrr:fix/xml-quoted-delimiters
Closed

hakarrr wants to merge 2 commits into
mitmproxy:mainfrom
hakarrr:fix/xml-quoted-delimiters

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Description

The XML/HTML content view currently treats every > as the end of an opening tag, including delimiters inside quoted attribute values. For example:

<p title="1 > 0">text</p>

is formatted as <p title="1 >0">text</p>, changing the attribute value. Nested elements can also acquire indentation and newlines inside their attributes.

Track single/double quote state while scanning ordinary tags so only an unquoted > closes the tag. Keep the existing comment and CDATA handling, and preserve incomplete markup without raising an error. This remains a linear scan and does not introduce an XML parser dependency.

Tests

  • Added 12 cases covering single/double quotes, repeated and mixed quote delimiters, nested and self-closing tags, incomplete tags, comments, and CDATA. The six initial regression cases fail on unchanged main.
  • Focused XML/HTML tests: 20 passed, 100% statement coverage for _view_xml_html.py (171 statements).
  • All content view tests: 130 passed.
  • uv run tox -e lint, mypy (288 source files), and filename matching: passed.
  • uv run pytest test/mitmproxy/ -q: 2014 passed, 2 skipped, 1 failure because this environment cannot create a TUN device. The same test_tun_mode failure reproduces on unchanged main. Re-running with that test deselected: 2013 passed, 2 skipped, 2 deselected.

Tested with the frozen dependency lock on Python 3.14.8.

hakarrr and others added 2 commits October 25, 2026 18:40
Keep greater-than characters inside quoted attribute values in the opening tag instead of treating them as a tag boundary.

Co-authored-by: generaltony007 <[email protected]>
Cover single and double quotes, mixed quotes, nested tags, self-closing and incomplete tags, comments, and CDATA without changing their handling.

Co-authored-by: generaltony007 <[email protected]>
@hakarrr

hakarrr commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Could you review this quoted-attribute delimiter fix when you have time? It preserves greater-than characters inside quoted XML/HTML attributes while retaining comment, CDATA and incomplete-markup handling. The current test, lint, type, coverage and build checks passed; deployment jobs are skipped. Please let me know if any changes are needed before this can be considered for merge. Thanks.

@hakarrr

hakarrr commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

A queue question, grouped here rather than posting the same follow-up on all nine PRs: are these fixes still in scope for review, or are there any you would prefer me to close?

Besides this XML/HTML delimiter fix, the open changes are #8522, #8523, #8525, #8529, #8531, #8533, #8534 and #8535. If you prefer one at a time, which should take priority? If an approach is unwanted or has been superseded, I can close that PR rather than leave it in your queue.

I am checking the stale merge/CI blockers separately. This is not a claim that all nine are currently merge-ready.

@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer advise whether this XML/HTML quoted-attribute fix is still wanted and what the next step is for human review? Please let me know if you need changes or would prefer this PR closed. I'm not treating the earlier local validation as a claim that the current PR is merge-ready. Thanks.

@hakarrr hakarrr closed this Nov 17, 2026
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.

1 participant