diff --git a/LinkTitles.body.php b/LinkTitles.body.php index 5d712ac..fe13c7d 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -184,15 +184,19 @@ // see http://stackoverflow.com/questions/10672286 $arr = preg_split( $delimiter, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); + // Escape certain special characters in the page title to prevent + // regexp compilation errors + $escapedTitle = preg_quote(LinkTitles::$safeTitle, '/'); + // Depending on the global configuration setting $wgCapitalLinks, // the title has to be searched for either in a strictly case-sensitive // way, or in a 'fuzzy' way where the first letter of the title may // be either case. if ( $wgCapitalLinks ) { - $searchTerm = '((?i)' . LinkTitles::$safeTitle[0] . '(?-i)' . - substr(LinkTitles::$safeTitle, 1) . ')'; + $searchTerm = '((?i)' . $escapedTitle[0] . '(?-i)' . + substr($escapedTitle, 1) . ')'; } else { - $searchTerm = '(' . LinkTitles::$safeTitle . ')'; + $searchTerm = '(' . $escapedTitle . ')'; } for ( $i = 0; $i < count( $arr ); $i+=2 ) { @@ -218,7 +222,7 @@ for ( $i = 0; $i < count( $arr ); $i+=2 ) { // even indexes will point to text that is not enclosed by brackets $arr[$i] = preg_replace_callback( '/(?= 0 ) && ( $count > 0 )) { break; diff --git a/LinkTitles.php b/LinkTitles.php index f906c8e..1d25626 100755 --- a/LinkTitles.php +++ b/LinkTitles.php @@ -49,7 +49,7 @@ 'name' => 'LinkTitles', 'author' => '[https://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]', 'url' => 'https://www.mediawiki.org/wiki/Extension:LinkTitles', - 'version' => '2.2.1', + 'version' => '2.2.2', 'descriptionmsg' => 'linktitles-desc' ); diff --git a/NEWS b/NEWS index 6be9591..670797f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +LinkTitles 2.2.2: 2013-08-09 +* Prevent crashes due to special characters in page titles. + LinkTitles 2.2.1: 2013-07-22 * Make the extension work with sqlite databases. diff --git a/release/LinkTitles-2.2.2.tar.gz b/release/LinkTitles-2.2.2.tar.gz new file mode 100644 index 0000000..f5d9959 Binary files /dev/null and b/release/LinkTitles-2.2.2.tar.gz differ