diff --git a/LinkTitles.body.php b/LinkTitles.body.php index 01c0678..3a84b76 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -80,8 +80,18 @@ $myTitle = $article->getTitle()->getText(); ( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'DESC' : $sort_order = ''; + + // Build a regular expression that will capture existing wiki links ("[[...]]"), + // wiki headings ("= ... =", "== ... ==" etc.), + // urls ("http://example.com", "[http://example.com]", "[http://example.com Description]", + // and email addresses ("mail@example.com"). + // Since there is a user option to skip headings, we make this part of the expression + // optional. Note that in order to use preg_split(), it is important to have only one + // capturing subpattern (which precludes the use of conditional subpatterns). ( $wgLinkTitlesParseHeadings ) ? $delimiter = '' : $delimiter = '=+.+?=+|'; - $delimiter = '/(' . $delimiter . '\[\[.*?\]\])/i'; + $urlPattern = '[a-z]+?\:\/\/(?:\S+\.)+\S+(?:\/.*)?'; + $delimiter = '/(' . $delimiter . '\[\[.*?\]\]|\[' . + $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i'; // Build an SQL query and fetch all page titles ordered // by length from shortest to longest. @@ -111,7 +121,7 @@ $safeTitle = str_replace( '/', '\/', $title ); for ( $i = 0; $i < count( $arr ); $i+=2 ) { // even indexes will point to text that is not enclosed by brackets - $arr[$i] = preg_replace( '/\b(' . $safeTitle . ')\b/i', '[[$1]]', $arr[$i] ); + $arr[$i] = preg_replace( '/(? 'LinkTitles', 'author' => '[http://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]', 'url' => 'http://www.mediawiki.org/wiki/Extension:LinkTitles', - 'version' => '1.0.0', + 'version' => '1.1.0', 'descriptionmsg' => 'linktitles-desc' ); diff --git a/NEWS b/NEWS index c792833..8ac96ff 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +LinkTitles 1.1.0: 2012-05-24 +* No longer parses urls and email addresses. + LinkTitles 1.0.0: 2012-05-22 * Added new option to parse or not parse headings * Added new option to parse pages on saving edits diff --git a/release/LinkTitles-1.1.0.tar.gz b/release/LinkTitles-1.1.0.tar.gz new file mode 100644 index 0000000..9122f74 Binary files /dev/null and b/release/LinkTitles-1.1.0.tar.gz differ