The version of the split_pagename function in CVS right now has two defects:
(1) It adds spaces even to page names which don't match WikiNameRegexp.
(i.e. "[don't-split-my-iMac]" -> "[don't-split-my-i Mac]")
(2) It eats spaces that it has previously added before the letters "A"
and "I". ("MaryHasALamb" -> "Mary HasA Lamb"). This is because the
"?:" construct, while it doesn't make backrefs, is included in the
match span which is replaced. The "?<=" or "zero-width positive
lookbehind assertion" is the correct thing to use.
This patch fixes these problems. It is also available from
<http://orbis-tertius.net/joe/code/phpwiki-regex-fix.patch>.
Joe
Index: phpwiki/lib/stdlib.php
diff -u phpwiki/lib/stdlib.php:1.1 phpwiki/lib/stdlib.php:1.3
--- phpwiki/lib/stdlib.php:1.1 Sun Sep 30 11:28:00 2001
+++ phpwiki/lib/stdlib.php Sun Sep 30 14:24:33 2001
@@ -468,8 +468,10 @@
*/
function split_pagename ($page) {
- if (preg_match("/\s/", $page))
- return $page; // Already split --- don't split any more.
+ global $WikiNameRegexp;
+
+ if (!preg_match("/$WikiNameRegexp/", $page))
+ return $page; // only split WikiWords
// FIXME: this algorithm is Anglo-centric.
static $RE;
@@ -479,7 +481,7 @@
// of their tails.
$RE[] = '/([[:lower:]])((?<!Mc|De|Di)[[:upper:]]|\d)/';
// This the single-letter words 'I' and 'A' from any following capitalized words.
- $RE[] = '/(?: |^)([AI])([[:upper:]])/';
+ $RE[] = '/(?<= |^)([AI])([[:upper:]])/';
// Split numerals from following letters.
$RE[] = '/(\d)([[:alpha:]])/';
|