Skip to content

Ignore unmatched image dimension end tags - #602

Open
terminalchai wants to merge 1 commit into
kurtmckee:mainfrom
terminalchai:fix/stray-dimension-end-tags
Open

terminalchai wants to merge 1 commit into
kurtmckee:mainfrom
terminalchai:fix/stray-dimension-end-tags

Conversation

@terminalchai

Copy link
Copy Markdown

Ignore unmatched image dimension end tags during loose parsing.

feedparser.parse("</height>") and feedparser.parse("</width>") currently raise TypeError because pop() returns None when there is no corresponding open element. Return immediately in the two dimension handlers when that happens. Parsing can then return its normal malformed-feed result, without inventing a zero dimension or overwriting a dimension that was already parsed.

Addresses the height/width cases in #599. Other malformed-input cases in that issue are outside this change.

Add eight regression cases covering standalone end tags, stray tags inside an image, duplicate end tags following a valid dimension, and unrelated image-title text. All eight cases failed with TypeError before the guards were added and pass afterwards. Include a Fixed changelog fragment.

Validation on Windows, Python 3.11:

  • Full suite: 4,305 passed, 8 skipped.
  • New regression cases: 8 passed.
  • Black, isort, and flake8 checks pass on the changed Python files.
  • Project-wide mypy: no issues in 33 source files.
  • git diff --check passes.

Prepared with AI assistance and reviewed against the report, existing parser behavior, and regression results.

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