Correctly handle <abbr> followed by ISBN
authorAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 24 Mar 2010 13:42:37 +0000 (13:42 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 24 Mar 2010 13:42:37 +0000 (13:42 +0000)
Bug 22905.  Patch based on one submitted by Solitarius.  Basically, we
were assuming that anything matching <a.*?</a> was a link and ignoring
it so as to avoid nested links, but that matched the HTML from

<abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]

so the ISBN didn't work.  Parser test committed, fails without the
Parser.php change.

CREDITS
RELEASE-NOTES
includes/parser/Parser.php
maintenance/parserTests.txt

diff --git a/CREDITS b/CREDITS
index a07930a..a4c38ad 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -115,6 +115,7 @@ following names for their contribution to the product.
 * ST47
 * Scott Colcord
 * Simon Walker
+* Solitarius
 * Stefano Codari
 * Str4nd
 * svip
index dc45614..f3a1ec6 100644 (file)
@@ -55,6 +55,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 18664) Relative URIs in interwiki links cause failed redirects
 * (bug 19270) Relative URIs in interwiki links break interwiki transclusion
 * (bug 22903) Revdelete log entries now show in the user preferred language.
+* (bug 22905) Correctly handle <abbr> followed by ISBN
 
 == API changes in 1.17 ==
 * (bug 22738) Allow filtering by action type on query=logevent
index 9260a80..3b6d613 100644 (file)
@@ -970,7 +970,7 @@ class Parser
                $urlChar = self::EXT_LINK_URL_CLASS;
                $text = preg_replace_callback(
                        '!(?:                           # Start cases
-                               (<a.*?</a>) |               # m[1]: Skip link text
+                               (<a[ \t\r\n>].*?</a>) |     # m[1]: Skip link text
                                (<.*?>) |                   # m[2]: Skip stuff inside HTML elements' . "
                                (\\b(?:$prots)$urlChar+) |  # m[3]: Free external links" . '
                                (?:RFC|PMID)\s+([0-9]+) |   # m[4]: RFC or PMID, capture number
index 544b1f6..aed2f05 100644 (file)
@@ -6498,6 +6498,15 @@ ISBN ISBN 1234567890
 </p>
 !! end
 
+!! test
+Bug 22905: <abbr> followed by ISBN followed by </a>
+!! input
+<abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
+!! result
+<p><abbr>(fr)</abbr> <a href="/wiki/Special:BookSources/2753300917" class="internal mw-magiclink-isbn">ISBN 2753300917</a> <a href="http://www.example.com" class="external text" rel="nofollow">example.com</a>
+</p>
+!! end
+
 !! test
 Double RFC
 !! input