mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
Report both nested <ref> and <references> as an error
Before, this regular expression was looking for incomplete wikitext like this: <ref>unclosed <ref>closed</ref> With this change, wikitext like this will trigger the same error: <ref>unclosed <references /> incomplete</ref> This should be much, much more rare. But I feel it's reasonable to mark this as an error, instead of just rendering the broken inner tag in plain text. This patch also replaces `.*?>` with `[^>]*+>`. Both do the exact same. Instead of doing an "ungreedy search for the first possible closing bracket", which might cause backtracking, the new syntax consumes all non-brackets before expecting one. This is guaranteed to never backtrack (guaranteed by the extra +), and potentially faster because of this. Change-Id: Ic76a52cd111b28e4522f095ce3984e3583f602c1
This commit is contained in:
parent
aa12b53e3e
commit
7c1849d7b0
|
@ -206,8 +206,8 @@ class Cite {
|
|||
}
|
||||
|
||||
if ( preg_match(
|
||||
'/<ref\b.*?>/i',
|
||||
preg_replace( '#<(\w++).*?>.*?</\1\s*>|<!--.*?-->#s', '', $text )
|
||||
'/<ref(erences)?\b[^>]*+>/i',
|
||||
preg_replace( '#<(\w++)[^>]*+>.*?</\1\s*>|<!--.*?-->#s', '', $text )
|
||||
) ) {
|
||||
// (bug T8199) This most likely implies that someone left off the
|
||||
// closing </ref> tag, which will cause the entire article to be
|
||||
|
|
Loading…
Reference in a new issue