Skip to content

Latest commit

 

History

History
23 lines (14 loc) · 1.11 KB

File metadata and controls

23 lines (14 loc) · 1.11 KB

mwparserfromhell: Empty-Title Wikilink Filtering

Upstream PR: earwig/mwparserfromhell#362

Bug

Empty-title wikilinks such as [[]], [[|]], [[|foo]], and [[|||]] were returned by filter_wikilinks(). That was surprising for callers that ask for usable wikilinks, but simply dropping the nodes from the parse tree would remove information downstream tools may need for repair.

Contract

The parser should preserve invalid wikilink nodes in the generic parse tree, while wikilink-specific filters should skip empty-title links consistently.

Fix

The empty-title skip moved into the shared _indexed_ifilter() path for forcetype is Wikilink. That keeps filter_wikilinks(), filter(forcetype=Wikilink), and ifilter(forcetype=Wikilink) semantically aligned while preserving the original node.

Verification

  • Focused regression tests -> 5 passed
  • tests/test_parser.py tests/test_wikicode.py -> 31 passed
  • Full test suite -> 2010 passed, 1 skipped
  • ruff check and ruff format --check on changed files -> passed
  • git diff --check -> passed