Word filter iterates over replacement strings #2572

sicut opened this Issue Dec 12, 2016 · 2 comments


None yet

4 participants

sicut commented Dec 12, 2016

Hey there,

I just encountered a problem in the word filter which broke a lot of posts because I didn't know that could happen.
If the "bad word" is being used more than two times in a post and if it is being used in the replaced term as well additionally to any myCode tags, the parser does some weird iterative/recurcive calls.

An example should explain that better:
bad word: poop
filter: [url=badword.redirect?poop]bad word[/url]
phrase: poop poop poop
expected result: bad word bad word bad word (all links)
actual result: bad word]bad word[/url] bad word bad word]bad word[/url]

It doesnt matter how mach text is between each filtered word, it still looks like that for each occurence.
I gave it some further testing and its being consistant if the replaced word is in the new term as well as any myCode tag ([b], [u] and so on). After the replaced word is being used more than once, the above scenario occurs.

Btw. that can be reproduced in the shoutbox (Inferno) as well.

Is there a known workaround for that or can that be fixed?

Thank you!



Please report issues on the forum, as explained in our CONTRIBUTING.md file

@euantorano euantorano closed this Dec 12, 2016
@Devilshakerz Devilshakerz reopened this Dec 13, 2016
@Devilshakerz Devilshakerz added this to the 1.8.10 milestone Dec 13, 2016

The regex search and replace operation maintains a length index, however a non-optimal loop at https://github.com/mybb/mybb/blob/mybb_1808/inc/class_parser.php#L640-L643 prevents it from functioning correctly (resulting in replaced strings being matched again);
this was most likely done to prevent patterns from overlapping (\W is captured and reinserted so cannot be used to match the next word).

@Devilshakerz Devilshakerz changed the title from [Word filter] replaced word iteration + myCode tag = bug(?) to Word filter iterates over replacement strings Dec 13, 2016
@Devilshakerz Devilshakerz added s:fixed and removed s:confirmed labels Dec 13, 2016
@dequeues dequeues closed this Dec 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment