Skip to content

Fix ASCII case-insensitive input types in :checked - #222

Open
boogu2005 wants to merge 1 commit into
scrapy:masterfrom
boogu2005:codex/checked-type-case
Open

boogu2005 wants to merge 1 commit into
scrapy:masterfrom
boogu2005:codex/checked-type-case

Conversation

@boogu2005

Copy link
Copy Markdown

:checked currently compares @type with the lowercase strings checkbox and radio. As a result, a checked input such as <input type="CHECKBOX" checked> is omitted, even though HTML enumerated attribute keywords are ASCII case-insensitive.

Normalize the input type with XPath's ASCII-only translate() before comparing it. Regression coverage exercises lowercase, uppercase and mixed-case types in both HTML and XHTML modes, and preserves unchecked inputs, unrelated or missing types, non-ASCII lookalikes, selected options and GenericTranslator behavior.

Validation on Python 3.12:

  • The new regression fails against the original implementation and passes with the fix.
  • pytest --cov=cssselect --cov-report=term-missing cssselect tests docs: 45 passed, 1 xfailed.
  • Ruff lint and format checks, Pylint and Mypy pass.

The case-insensitive keyword rule is defined in the HTML enumerated attributes specification.

This branch has not been deployed

No deployments
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