diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 1c1821fc8b..453d4c1c6d 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -115,6 +115,7 @@
[Change] Allow years in future be selected for date custom profile field (Bug#14519)
[Fix] Don't display "Avatars Disabled" message on edit groups in UCP (Bug #14636)
[Change] Require confirm for deleting inactive users. (Bug #14641)
+ [Fix] Match custom BBCodes in the same way during first and second pass - patch provided by IBBoard (Bug #14268)
1.ii. Changes since 3.0.RC4
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index 1b5de909c3..21370036ee 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -331,6 +331,17 @@ class acp_bbcodes
)
);
+ $sp_tokens = array(
+ 'URL' => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)',
+ 'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
+ 'EMAIL' => '([a-zA-Z0-9]+[a-zA-Z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-zA-Z0-9]+[a-zA-Z0-9\-\._]*\.[a-zA-Z]+))',
+ 'TEXT' => '(.*?)',
+ 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
+ 'IDENTIFIER' => '([a-zA-Z0-9-_]+)',
+ 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)',
+ 'NUMBER' => '([0-9]+)',
+ );
+
$pad = 0;
$modifiers = 'i';
@@ -376,7 +387,7 @@ class acp_bbcodes
$fp_match = str_replace(preg_quote($token, '!'), $regex, $fp_match);
$fp_replace = str_replace($token, $replace, $fp_replace);
- $sp_match = str_replace(preg_quote($token, '!'), '(.*?)', $sp_match);
+ $sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match);
$sp_replace = str_replace($token, '${' . ($n + 1) . '}', $sp_replace);
}
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 6610a5c441..ef73762582 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -80,6 +80,7 @@ class bbcode
$bitfield = new bitfield($this->bbcode_bitfield);
$bbcodes_set = $bitfield->get_all_set();
+ $undid_bbcode_specialchars = false;
foreach ($bbcodes_set as $bbcode_id)
{
if (!empty($this->bbcode_cache[$bbcode_id]))
@@ -100,6 +101,14 @@ class bbcode
if (sizeof($preg['search']))
{
+ // we need to turn the entities back into their original form to allow the
+ // search patterns to work properly
+ if (!$undid_bbcode_specialchars)
+ {
+ $message = str_replace(array(':', '.'), array(':', '.'), $message);
+ $undid_bbcode_specialchars = true;
+ }
+
$message = preg_replace($preg['search'], $preg['replace'], $message);
$preg = array('search' => array(), 'replace' => array());
}