Skip to content

Commit 8f8121d

Browse files
committed
Correctly treat smileys with square parentheses at start of message
1 parent 7470721 commit 8f8121d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Nickvergessen/TrimMessage/PhpbbBbcodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function filter_bbcode_tag($bbcode_tag, $strip_information = true, $strip
498498
protected function replace_square_brackets_in_smilies()
499499
{
500500
// Replace all [ that are inside of <> because they belong to smilies
501-
if (utf8_strpos($this->message, '<'))
501+
if (utf8_strpos($this->message, '<') !== false)
502502
{
503503
$this->bracket_replacement = '{' . md5($this->message) . '}';
504504
while (utf8_strpos($this->message, $this->bracket_replacement) !== false)

src/Nickvergessen/TrimMessage/Tests/TrimTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function trim_message_data()
4646
'bbcode_uid' => '2sda49fx',
4747
),
4848
array(
49-
'message' => '<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h',
49+
'message' => '<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h foo bar',
5050
'bbcode_uid' => '2sda49fx',
5151
),
5252
);
@@ -208,8 +208,12 @@ public function trim_message_data()
208208
* Breaking withing smiley with dot and square parentheses
209209
*/
210210
array(
211-
'message_set' => 8, 'length' => 12, 'trimmed' => false,
212-
'expected' => '<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h',
211+
'message_set' => 8, 'length' => 20, 'trimmed' => false,
212+
'expected' => '<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h foo bar',
213+
),
214+
array(
215+
'message_set' => 8, 'length' => 10, 'trimmed' => true,
216+
'expected' => '<!-- s[foo.bar] --><img src="{SMILIES_PATH}/icon_e_geek.gif" alt="[foo.bar]" title="Geek" /><!-- s[foo.bar] -->h [...]',
213217
),
214218
);
215219

0 commit comments

Comments
 (0)