Fix remove_markup leaking footnote text on a nested self-closing tag (#3520) - #3653
Open
vineethsaivs wants to merge 1 commit into
Open
Fix remove_markup leaking footnote text on a nested self-closing tag (#3520)#3653vineethsaivs wants to merge 1 commit into
vineethsaivs wants to merge 1 commit into
Conversation
RE_P1 matched `<ref...>...(</ref>|/>)`, so a `<ref>...</ref>` footnote that contained a nested self-closing tag (e.g. `<nowiki/>` or `<br/>`) terminated the match at the nested tag's `/>`, leaving the rest of the footnote (often a URL) in the output of filter_wiki. Match either a self-closing ref (`<ref .../>`) or a paired ref terminated only by `</ref>`, so nested self-closing tags inside the footnote no longer cut the match short. The tag-name guard still avoids matching tags like `<references/>`. Fixes piskvorky#3520 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
nice, this is cleaner than trying to patch the old non-greedy ran it against a few edge cases and they all hold:
lgtm. |
Author
|
Thanks for the thorough review and for checking those edge cases, especially the attribute-value slash ( |
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.
Fixes #3520.
filter_wikileft footnote text in its output when a<ref>...</ref>block contained a nested self-closing tag:RE_P1wasr'<ref([> ].*?)(</ref>|/>)'. The/>alternative was meant to match a self-closing ref tag, but with the non-greedy.*?it matched the/>of a nested self-closing tag (<nowiki/>,<br/>) inside the footnote, ending the match early and leaving the rest of the footnote (often a URL) in the text.The new pattern matches either a self-closing ref (
<ref .../>) or a paired ref terminated only by</ref>:Nested self-closing tags inside the footnote no longer cut the match short. Self-closing refs (
<ref name="r"/>) and plain paired refs are still removed, and the tag-name guard still avoids matching unrelated tags such as<references/>.Added a regression test (
TestWikiCorpus.test_filter_wiki_ref_with_nested_self_closing_tag) that fails ondevelopand passes with this change.Disclosure: prepared with AI assistance; reviewed by me and I can explain every line.