From c80086299014f878533662571ffd2205bb70aa95 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Thu, 28 Aug 2014 15:57:49 +0200 Subject: [PATCH 1/8] Fix word detection with non-ASCII characters. Use the unicode character property \pL together with look-behind and look-ahead assertions rather than '\b' escape sequences (which do not work with non-ASCII characters). --- LinkTitles.body.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/LinkTitles.body.php b/LinkTitles.body.php index 02a6a4b..a837eb3 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -104,8 +104,13 @@ global $wgLinkTitlesSmartMode; global $wgCapitalLinks; - ( $wgLinkTitlesWordStartOnly ) ? $wordStartDelim = '\b' : $wordStartDelim = ''; - ( $wgLinkTitlesWordEndOnly ) ? $wordEndDelim = '\b' : $wordEndDelim = ''; + // Use unicode character properties rather than \b escape sequences + // to detect whole words containing non-ASCII characters as well. + // Note that this requires the use of the '/u' switch, and you need + // to have PHP with a PCRE library that was compiled with + // --enable-unicode-properties + ( $wgLinkTitlesWordStartOnly ) ? $wordStartDelim = '(?= 0 ) && ( $count > 0 )) { break; @@ -227,7 +232,7 @@ // even indexes will point to text that is not enclosed by brackets $arr[$i] = preg_replace_callback( '/(?= 0 ) && ( $count > 0 )) { break; From 2915c6c798dd05dc03f9117fb29b5215251d348d Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Thu, 28 Aug 2014 16:07:36 +0200 Subject: [PATCH 2/8] Fix region exclusion with multiple lines. Added the 's' modifier so that the regex that detects not-to-be-linked regions that span several lines (e.g., multiline
 section).
---
 LinkTitles.body.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/LinkTitles.body.php b/LinkTitles.body.php
index a837eb3..f41c73c 100755
--- a/LinkTitles.body.php
+++ b/LinkTitles.body.php
@@ -147,7 +147,7 @@
 				'style=".+?"|class=".+?"|' .                // styles and classes (e.g. of wikitables)
 				'\[' . $urlPattern . '\s.+?\]|'. $urlPattern .  '(?=\s|$)|' . // urls
 				'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' .        // email addresses
-				')/i';
+				')/is';
 
 			// Build a blacklist of pages that are not supposed to be link 
 			// targets. This includes the current page.

From 3c930eb90ab429ef9a073886617eed29c5872f6e Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Fri, 29 Aug 2014 07:57:30 +0200
Subject: [PATCH 3/8] Do not touch piped links in template parameters.

---
 LinkTitles.body.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/LinkTitles.body.php b/LinkTitles.body.php
index f41c73c..c130fac 100755
--- a/LinkTitles.body.php
+++ b/LinkTitles.body.php
@@ -117,9 +117,9 @@
 
 			if ( $wgLinkTitlesSkipTemplates )
 			{
-				$templatesDelimiter = '{{.+?}}|';
+				$templatesDelimiter = '{{[^}]+}}|';
 			} else {
-				$templatesDelimiter = '{{[^|]+?}}|{{.+\||';
+				$templatesDelimiter = '{{[^|}]+}}|{{[^|]+\||';
 			};
 
 			LinkTitles::$currentTitle = $title;

From cfeafc775144448d6dafd3e8573944b62d960bf0 Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Fri, 29 Aug 2014 12:13:38 +0200
Subject: [PATCH 4/8] Prevent linking inside multiline templates.

---
 LinkTitles.body.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/LinkTitles.body.php b/LinkTitles.body.php
index c130fac..f2e2dea 100755
--- a/LinkTitles.body.php
+++ b/LinkTitles.body.php
@@ -147,7 +147,7 @@
 				'style=".+?"|class=".+?"|' .                // styles and classes (e.g. of wikitables)
 				'\[' . $urlPattern . '\s.+?\]|'. $urlPattern .  '(?=\s|$)|' . // urls
 				'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' .        // email addresses
-				')/is';
+				')/ism';
 
 			// Build a blacklist of pages that are not supposed to be link 
 			// targets. This includes the current page.

From 0ced2cff44e362e483763b45e9e269514af59a27 Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Fri, 29 Aug 2014 14:16:46 +0200
Subject: [PATCH 5/8] Do not re-link links inside curly braces.

---
 LinkTitles.body.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/LinkTitles.body.php b/LinkTitles.body.php
index f2e2dea..9d13363 100755
--- a/LinkTitles.body.php
+++ b/LinkTitles.body.php
@@ -119,7 +119,7 @@
 			{
 				$templatesDelimiter = '{{[^}]+}}|';
 			} else {
-				$templatesDelimiter = '{{[^|}]+}}|{{[^|]+\||';
+				$templatesDelimiter = '{{[^|]*?(?:(?:\[\[[^]]+]])?)[^|]*?(?:\||(?:}}))|';
 			};
 
 			LinkTitles::$currentTitle = $title;

From 5a8e54eab27b110cd8d42ffb55dc6cf35b1ad593 Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Wed, 3 Sep 2014 15:06:30 +0200
Subject: [PATCH 6/8] Do not link template parameters.

---
 LinkTitles.body.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/LinkTitles.body.php b/LinkTitles.body.php
index 9d13363..bd484d3 100755
--- a/LinkTitles.body.php
+++ b/LinkTitles.body.php
@@ -119,7 +119,15 @@
 			{
 				$templatesDelimiter = '{{[^}]+}}|';
 			} else {
-				$templatesDelimiter = '{{[^|]*?(?:(?:\[\[[^]]+]])?)[^|]*?(?:\||(?:}}))|';
+				// Match template names (ignoring any piped [[]] links in them) 
+				// along with the trailing pipe and parameter name or closing 
+				// braces; also match sequences of '|wordcharacters=' (without 
+				// spaces in them) that usually only occur as parameter names in 
+				// transclusions (but could also occur as wiki table cell contents).
+				// TODO: Find a way to match parameter names in transclusions, but 
+				// not in table cells or other sequences involving a pipe character 
+				// and equal sign.
+				$templatesDelimiter = '{{[^|]*?(?:(?:\[\[[^]]+]])?)[^|]*?(?:\|(?:\w+=)?|(?:}}))|\|\w+=|';
 			};
 
 			LinkTitles::$currentTitle = $title;

From 8896a61c08525675956661827dfb21f1622d5a8b Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Wed, 3 Sep 2014 15:12:19 +0200
Subject: [PATCH 7/8] Change release script to amend commit.

Requires further work to properly handle the Git branching model as
described by http://nvie.com/posts/a-successful-git-branching-model
---
 release.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/release.sh b/release.sh
index 7f0cda0..c852b76 100755
--- a/release.sh
+++ b/release.sh
@@ -19,7 +19,7 @@ tar cvzf $FILENAME gpl-*.txt README.md NEWS *.php --exclude '*~' --transform 's,
 if [[ $? -eq 0 ]]; then
 	# Add the tarball to the repository, commit it, then tag the commit and push to origin.
 	git add $FILENAME
-	git commit -m "Release version $1"
+	git commit -m --amend
 	git tag -a $1 -m "Version $1."
 	git push
 	git push --tags

From cf0cf61516c9a50e591750a2a48e1491ba8c196a Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Wed, 3 Sep 2014 15:13:22 +0200
Subject: [PATCH 8/8] Prepare release 3.0.1.

---
 LinkTitles.php | 2 +-
 NEWS           | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/LinkTitles.php b/LinkTitles.php
index c82e704..6eb9214 100755
--- a/LinkTitles.php
+++ b/LinkTitles.php
@@ -195,7 +195,7 @@
     'name'           => 'LinkTitles',
     'author'         => '[https://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]', 
     'url'            => 'https://www.mediawiki.org/wiki/Extension:LinkTitles',
-    'version'        => '3.0.0',
+    'version'        => '3.0.1',
     'descriptionmsg' => 'linktitles-desc'
     );
 
diff --git a/NEWS b/NEWS
index dc65b83..76ce5e5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+LinkTitles 3.0.1: 2014-09-03
+* Fix several bugs in template handling.
+* Ignore 
 and similar sections that span multiple lines.
+
 LinkTitles 3.0.0: 2014-06-13
 * Dramatically improved performance (especially apparent during batch
   processing).