diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index d8db37ddfe..b751103601 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -230,6 +230,8 @@ p a {
[Fix] Display searchable subforums of invisible parents in advanced search forum selection (Bug #11395)
[Fix] Allow line breaks in custom BBCodes (Bug #10758)
[Fix] Ordered BBcode parsing functions in the same way everywhere where they are used
+ [Fix] Prevent {URL} token in custom BBCodes from make_clickable messing (Bug #14151)
+ [Sec] Added alternative tokens to custom BBCodes which are safe for CSS/Javascript and changed TEXT token to entitise opening and closing parantheses.
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index ce0d12b356..235028fc3c 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -295,16 +295,22 @@ class acp_bbcodes
// @todo Make sure to change this too if something changed in message parsing
$tokens = array(
'URL' => array(
- '!([a-z0-9]+://)?([^< "\r\n\t\]]*?)!ie' => "(('\$1') ? '\$1\$2' : 'http://\$2')"
+ '!(?:(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))!ie' => "\$this->bbcode_specialchars(('\$1') ? '\$1' : 'http://\$2')"
),
'LOCAL_URL' => array(
- '!([^:]+/[^< "\r\n\t\]]*?)!' => '$1'
+ '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')"
),
'EMAIL' => array(
- '!([a-z0-9]+[a-z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-z0-9]+[a-z0-9\-\._]*\.[a-z]+))!i' => '$1'
+ '!([a-z0-9]+[a-z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-z0-9]+[a-z0-9\-\._]*\.[a-z]+))!i' => "\$this->bbcode_specialchars('$1')"
),
'TEXT' => array(
- '!(.*?)!es' => "str_replace(\"\\r\\n\",\"\\n\", str_replace('\\\"', '\"', str_replace('\\'', ''', trim('\$1'))))"
+ '!(.*?)!es' => "str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', ''', '(', ')'), trim('\$1'))"
+ ),
+ 'SIMPLETEXT' => array(
+ '!([a-zA-Z0-9-+.,_ ]+)!' => "$1"
+ ),
+ 'IDENTIFIER' => array(
+ '!([a-zA-Z0-9-_]+)!' => "$1"
),
'COLOR' => array(
'!([a-z]+|#[0-9abcdef]+)!i' => '$1'
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 4b8ad62a51..c877d56e2b 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -332,7 +332,7 @@ class bbcode
// In order to use templates with custom bbcodes we need
// to replace all {VARS} to corresponding backreferences
// Note that backreferences are numbered from bbcode_match
- if (preg_match_all('/\{(URL|EMAIL|TEXT|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m))
+ if (preg_match_all('/\{(URL|LOCAL_URL|EMAIL|TEXT|SIMPLETEXT|IDENTIFIER|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m))
{
foreach ($m[0] as $i => $tok)
{
diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php
index ebbbf61c44..2f995dc91d 100644
--- a/phpBB/language/en/acp/posting.php
+++ b/phpBB/language/en/acp/posting.php
@@ -49,14 +49,14 @@ $lang = array_merge($lang, array(
'BBCODE_TAG_TOO_LONG' => 'The tag name you selected is too long.',
'BBCODE_TAG_DEF_TOO_LONG' => 'The tag definition that you have entered is too long, please shorten your tag definition.',
'BBCODE_USAGE' => 'BBCode usage',
- 'BBCODE_USAGE_EXAMPLE' => '[hilight={COLOR}]{TEXT}[/hilight]
[font={TEXT1}]{TEXT2}[/font]',
+ 'BBCODE_USAGE_EXAMPLE' => '[hilight={COLOR}]{TEXT}[/hilight]
[font={SIMPLETEXT1}]{SIMPLETEXT2}[/font]',
'BBCODE_USAGE_EXPLAIN' => 'Here you define how to use the BBCode. Replace any variable input by the corresponding token (%ssee below%s).',
'EXAMPLE' => 'Example:',
'EXAMPLES' => 'Examples:',
'HTML_REPLACEMENT' => 'HTML replacement',
- 'HTML_REPLACEMENT_EXAMPLE' => '<span style="background-color: {COLOR};">{TEXT}</span>
<span style="font-family: {TEXT1};">{TEXT2}</span>',
+ 'HTML_REPLACEMENT_EXAMPLE' => '<span style="background-color: {COLOR};">{TEXT}</span>
<span style="font-family: {SIMPLETEXT1};">{SIMPLETEXT2}</span>',
'HTML_REPLACEMENT_EXPLAIN' => 'Here you define the default HTML replacement. Do not forget to put back tokens you used above!',
'TOKEN' => 'Token',
@@ -66,7 +66,9 @@ $lang = array_merge($lang, array(
'TOO_MANY_BBCODES' => 'You cannot create any more BBCodes. Please remove one or more BBCodes then try again.',
'tokens' => array(
- 'TEXT' => 'Any text, including foreign characters, numbers, etc…',
+ 'TEXT' => 'Any text, including foreign characters, numbers, etc… You should not use this token in HTML tags. Instead try to use IDENTIFIER or SIMPLETEXT.',
+ 'SIMPLETEXT' => 'Characters from the latin alphabet (A-Z), numbers, spaces, commas, dots, minus, plus, hyphen and underscore',
+ 'IDENTIFIER' => 'Characters from the latin alphabet (A-Z), numbers, hyphen and underscore',
'NUMBER' => 'Any series of digits',
'EMAIL' => 'A valid e-mail address',
'URL' => 'A valid URL using any protocol (http, ftp, etc… cannot be used for javascript exploits). If none is given, "http://" is prefixed to the string.',