From c74eb46f20d51aef7d79d02a8490702930a7b939 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Mon, 18 Dec 2006 01:12:19 +0000 Subject: [PATCH] (bug 8110) Make magic ISBN linking stricter: only match ten-digit sequences (plus optional ISBN-13 prefix) with no immediately following alphanumeric character, disallow multiple consecutive internal redirects. This required fixing a number of broken parser tests that had used a too-short ISBN. --- RELEASE-NOTES | 3 +++ includes/Parser.php | 6 +++++- maintenance/parserTests.txt | 43 ++++++++++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 83400e3aa1..b3a94682ac 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -338,6 +338,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN mysteriously otherwise (detection code copied from install-utils.inc) * (bug 8295) Change handling of
tags in doBlockLevels() to match that of
+* (bug 8110) Make magic ISBN linking stricter: only match ten-digit sequences + (plus optional ISBN-13 prefix) with no immediately following alphanumeric + character, disallow multiple consecutive internal redirects == Languages updated == diff --git a/includes/Parser.php b/includes/Parser.php index 9a0331da9e..97a1f13ae6 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1038,7 +1038,11 @@ class Parser | # Skip link text <.*?> | # Skip stuff inside HTML elements (?:RFC|PMID)\s+([0-9]+) | # RFC or PMID, capture number as m[1] - ISBN\s+(\b[0-9Xx\ \-]+) # ISBN, capture number as m[2] + ISBN\s+(\b # ISBN, capture number as m[2] + (?: 97[89] [\ \-]? )? # optional 13-digit ISBN prefix + (?: [0-9] [\ \-]? ){9} # 9 digits with opt. delimiters + [0-9Xx] # check digit + \b) )!x', array( &$this, 'magicLinkCallback' ), $text ); wfProfileOut( __METHOD__ ); return $text; diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index a9c9db2b6f..923f466c08 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -2917,9 +2917,9 @@ Thumbnail image caption with a free URL !! test BUG 1887: A ISBN with a thumbnail !! input -[[Image:foobar.jpg|thumb|ISBN 12354]] +[[Image:foobar.jpg|thumb|ISBN 1235467890]] !! result - + !! end @@ -5753,9 +5753,9 @@ __FORCETOC__ !! test ISBN code coverage !! input -ISBN 983 987 +ISBN 978-0-1234-56 789 !! result -

ISBN 983 987 +

ISBN 978-0-1234-56 789

!! end @@ -5770,12 +5770,10 @@ ISBN !! test Double ISBN -!! options -disabled # Disabled until Bug 6560 resolved !! input -ISBN ISBN 1234 +ISBN ISBN 1234567890 !! result -

ISBN ISBN 1234 +

ISBN ISBN 1234567890

!! end @@ -6099,6 +6097,35 @@ ISBN foo !! end +!! test +ISBN length +!! input +ISBN 123456789 + +ISBN 1234567890 + +ISBN 12345678901 +!! result +

ISBN 123456789 +

ISBN 1234567890 +

ISBN 12345678901 +

+!! end + + +!! test +ISBN with trailing year (bug 8110) +!! input +ISBN 1-234-56789-0 - 2006 + +ISBN 1 234 56789 0 - 2006 +!! result +

ISBN 1-234-56789-0 - 2006 +

ISBN 1 234 56789 0 - 2006 +

+!! end + + !! test Pages in namespace (Magic word disabled currently) !! input -- 2.20.1