diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php
index 2d4a4171af..865b0662f9 100644
--- a/phpBB/phpbb/textreparser/base.php
+++ b/phpBB/phpbb/textreparser/base.php
@@ -43,7 +43,7 @@ abstract class base implements reparser_interface
if (!isset($record['enable_bbcode'], $record['enable_smilies'], $record['enable_magic_url']))
{
$record += array(
- 'enable_bbcode' => !empty($record['bbcode_uid']),
+ 'enable_bbcode' => $this->guess_bbcodes($record),
'enable_smilies' => $this->guess_smilies($record),
'enable_magic_url' => $this->guess_magic_url($record),
);
@@ -58,6 +58,13 @@ abstract class base implements reparser_interface
$record[$field_name] = $this->guess_bbcode($record, $bbcode);
}
+ // Magic URLs are tied to the URL BBCode, that's why if magic URLs are enabled we make sure
+ // that the URL BBCode is also enabled
+ if ($record['enable_magic_url'])
+ {
+ $record['enable_url_bbcode'] = true;
+ }
+
return $record;
}
@@ -74,7 +81,7 @@ abstract class base implements reparser_interface
{
// Look for the closing tag, e.g. [/url]
$match = '[/' . $bbcode . ':' . $record['bbcode_uid'];
- if (stripos($record['text'], $match) !== false)
+ if (strpos($record['text'], $match) !== false)
{
return true;
}
@@ -84,8 +91,8 @@ abstract class base implements reparser_interface
{
// Look for the closing tag inside of a e element, in an element of the same name, e.g.
// [/url]
- $match = '[/' . $bbcode . ']' . $bbcode . '>';
- if (stripos($record['text'], $match) !== false)
+ $match = '[/' . $bbcode . ']' . strtoupper($bbcode) . '>';
+ if (strpos($record['text'], $match) !== false)
{
return true;
}
@@ -94,6 +101,33 @@ abstract class base implements reparser_interface
return false;
}
+ /**
+ * Guess whether any BBCode is in use in given record
+ *
+ * @param array $record
+ * @return bool
+ */
+ protected function guess_bbcodes(array $record)
+ {
+ if (!empty($record['bbcode_uid']))
+ {
+ // Test whether the bbcode_uid is in use
+ $match = ':' . $record['bbcode_uid'];
+ if (strpos($record['text'], $match) !== false)
+ {
+ return true;
+ }
+ }
+
+ if (substr($record['text'], 0, 2) == '\\[/\\w+\\])', $match);
+ }
+
+ return false;
+ }
+
/**
* Guess whether magic URLs are in use in given record
*
@@ -103,7 +137,7 @@ abstract class base implements reparser_interface
protected function guess_magic_url(array $record)
{
// Look for or for a URL tag that's not immediately followed by
- return (strpos($record['text'], '') !== false || preg_match('(]++>(?!))', strpos($row['text'])));
+ return (strpos($record['text'], '') !== false || preg_match('(]++>(?!))', $record['text']));
}
/**
@@ -114,7 +148,7 @@ abstract class base implements reparser_interface
*/
protected function guess_smilies(array $record)
{
- return (strpos($row['text'], 'http://example.org]]>
abcd1234
+
+ 6
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+ 7
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+ 8
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+ 9
+ 1
+ 1
+ 0
+
+ abcd1234
+
1000
1
diff --git a/tests/text_reparser/fixtures/privmsgs.xml b/tests/text_reparser/fixtures/privmsgs.xml
index 9ca49a2af8..4049b9890a 100644
--- a/tests/text_reparser/fixtures/privmsgs.xml
+++ b/tests/text_reparser/fixtures/privmsgs.xml
@@ -59,6 +59,46 @@
+
+ 6
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+
+
+ 7
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+
+
+ 8
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+
+
+ 9
+ 1
+ 1
+ 0
+
+ abcd1234
+
+
+
1000
1
diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php
index 7dd90f21d0..405341e2fc 100644
--- a/tests/text_reparser/test_row_based_plugin.php
+++ b/tests/text_reparser/test_row_based_plugin.php
@@ -62,31 +62,59 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t
5,
array(
array(
- 'id' => 1,
+ 'id' => '1',
'text' => 'This row should be [b]ignored[/b]',
),
array(
- 'id' => 2,
+ 'id' => '2',
'text' => '[b]Not bold[/b] :) http://example.org',
),
array(
- 'id' => 3,
+ 'id' => '3',
'text' => '[b]Bold[/b] :) http://example.org',
),
array(
- 'id' => 4,
+ 'id' => '4',
'text' => '[b]Not bold[/b] :) http://example.org',
),
array(
- 'id' => 5,
+ 'id' => '5',
'text' => '[b]Not bold[/b] :) http://example.org',
),
array(
- 'id' => 1000,
+ 'id' => '1000',
'text' => 'This row should be [b]ignored[/b]',
),
)
),
+ array(
+ 6,
+ 7,
+ array(
+ array(
+ 'id' => '6',
+ 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]',
+ ),
+ array(
+ 'id' => '7',
+ 'text' => '[flash=123,345]http://example.org/flash.swf[/flash]',
+ ),
+ )
+ ),
+ array(
+ 8,
+ 9,
+ array(
+ array(
+ 'id' => '8',
+ 'text' => '
[img]http://example.org/img.png[/img]',
+ ),
+ array(
+ 'id' => '9',
+ 'text' => '[img]http://example.org/img.png[/img]',
+ ),
+ )
+ ),
);
}
}