Repository navigation
fix(html): read a repeated attribute as its first value in the output checks - #674
Merged
Merged
Conversation
… checks A browser keeps the first of two attributes with the same name on one tag. The citry_ui checks of rendered fills read `dict(attrs)`, which keeps the last, so `<span tabindex="0" tabindex="-1">` passed the Listbox option check while the browser makes the span focusable. - `LongReferenceSafeParser` hands the start tag handlers of subclasses that read attributes each repeated name once, with its first value. The repeated `id` warning now counts only the first `id` of an element, and the Vue mount host check reads a repeated `id` the same way, so `<div id="app" ID="x">` is the host with one attribute. - The citry_ui checks read their tags through their own `first_attribute_occurrences`, because Citry UI also runs on Citry releases whose parser keeps every occurrence. - `LongReferenceSafeParser` holds back a lone `&` at the end of a chunk until the next chunk arrives, so a long decimal reference split right after the `&` no longer raises `ValueError`. That error made Citry skip its preload links for such a page. - The citry_ui check messages write control characters in a tag name as escapes such as `\x1b`. The citry_ui changelog also gets the entry for #610's stricter reading of numeric references in attribute values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
added a commit
that referenced
this pull request
Nov 14, 2026
…ight merged changes (#682) Add one record under docs/security/reviews/ for each of the eight published 0.8.0 advisories (GHSA-4hj5, -8xvf, -7qpw, -g658, -x6rm, -h524, -xmx5, -xg8c) and for each of the pull requests that Mechanism 7, step 7 owes one: #610, #640, #651, #652, #653, #658, #674 and #675. Each record says only what the public pull request, the published advisory, the merged code and its tests show, and lists what was not checked. The reviews README describes how a record for a published advisory differs from a pull request record. The Mechanism 7 list in CLAUDE.md gains the two places that GHSA-7qpw added: parser rules browsers differ on, and the page's declared encoding. Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
A browser keeps the first of two attributes with the same name on one tag:
<div a="1" a="2">hasa="1". Several Citry UI components check the HTML they receive as slot content (a fill) after it renders. They read each tag's attributes withdict(attrs), which keeps the last value for a repeated name, so a check could judge a tag by a value the browser ignores. This PR makes them read repeated attributes as the browser does, and fixes two smaller problems found while reviewing #610.LongReferenceSafeParser(citry/util/html.py) is theHTMLParsersubclass that Citry's checks of rendered HTML build on. It now gives a subclass's start tag handler one entry per attribute name, with the first value. Only subclasses that read attribute values get this. That covers the development warning for a repeatedid(_page_ids.py) and the check that finds the element Vue mounts on (_vue/serialization.py). The Citry UI checks (CDisclosure,CImage,CListbox,CTree,CCommandPalette) also call their ownfirst_attribute_occurrences(citry_ui/components/_validation.py). Citry UI declarescitry>=0.7.0, and Citry releases before 0.9.0 give a handler every occurrence of a repeated name.&no longer fails. The parser reads a page in chunks, and rewrites a numeric character reference with thousands of digits before Python converts it. A chunk that ended right after the&hid the reference from that rewrite, andValueErrorfollowed. The parser now waits for the next chunk when a chunk ends in a lone&, as it already did for&#and digits. The error made Citry skip its preload links for such a page.\x1b.popover="manual"is now refused), plus an entry for the repeated-attribute fix. The root changelog extends the Read numeric references in attribute values as the browser does #610idwarning entry and adds the preload fix.Tests
test_output_parsers.py: each changed Citry UI check refuses a tag whose first value is one it does not accept, and accepts the tag with the two values swapped. Each case runs twice: with the current core parser, and with the core parser's first-value step turned off, which behaves like Citry releases before 0.9.0. Control characters in tag names come out escaped.test_attribute_numeric_references.py:LongReferenceSafeParsergives the first value with and without a reference in the tag; theidwarning and the Vue mount check read only the firstid.test_long_character_references.py: the input is split at every position except inside the 5,000-digit runs of zeros (where it splits every 1,000th position), including right after&and&#.I ran each new test against the code without its fix, and each one fails there.
Left out
These build and test tools read Citry's own output with
dict(attrs)ordict(tag.attrs)and make no decision about user pages, so this PR leaves them as they are:scripts/vue_render_parity/check.py,scripts/generate_html_attribute_values.py,docs_site/_internal/base_path.py,docs_site/_internal/assemble.py.Two Rust lookups in
citry_html_transformalso don't use the browser's first-value rule, and I left them for a separate change:marker.rsreads thec-render-idof a<template>placeholder, which the server replaces with the child's HTML before the page is sent.transformer.rshandles thetrack_added_attributes_for_tags_with_this_attributeoption, whichcitrydoes not use.🤖 Generated with Claude Code