Closed ErikMinekus closed 10 years ago
Emoticons need whitespace on the left and right side to parse correctly. Try placing a space after the smiley to see if it works.
https://github.com/milesj/decoda/blob/master/src/Decoda/Hook/EmoticonHook.php#L87
This is a hard requirement so that smileys don't convert proper characters, like :/
in http:/
.
Ah I see, that works. Make sense, thanks!
Sorry, maybe I was a bit too hasty. Of course I already have a lot of content which doesn't have a space or newline before [/quote], so isn't it possible to add the closing bracket to the left and the opening bracket to the right of the regex? Or would that give too many false positives?
That might be a viable solution. Could you try applying it to all your examples? See if any issues arise?
Should be tested with smile contains opening and/or closing bracket.
Yes of course, but tests only cover small snippets. Applying it to a large set of posts with complex BB code could help reveal weird edge cases.
Having no luck with this. I tried adding []
to the regex pattern with no luck. It seems the $smiliesRegex
is causing conflicts.
https://github.com/milesj/decoda/blob/master/src/Decoda/Hook/EmoticonHook.php#L87
This is the regex I tried: $pattern = sprintf('/(?P<left>^|\n|\s|\])(?:%s)(?P<right>\[|\n|\s|$)/is', $smiliesRegex);
I got it to work by making $smiliesRegex
a capturing group:
$pattern = sprintf('/(?P<left>^|\n|\s|\%s)(?P<smiley>%s)(?P<right>\%s|\n|\s|$)/is',
$this->getParser()->getConfig('close'),
$smiliesRegex,
$this->getParser()->getConfig('open'));
And then in _emoticonCallback
I used that instead of $matches[0]
:
$smiley = trim($matches['smiley']);
But I have not yet had the time to test it full scale.
Cool, I'll give that a try. I only spent like 5 minutes on it before getting distracted, hah.
I have not found any issues with this yet. I tested it on a bunch of posts, and with things like:
[quote] :cool:[/quote]
[quote] :)[/quote]
[quote] :[[/quote]
[quote] :[/[/quote]
[quote]]:[/[/quote]
And it's all working.
Thanks to @alquerci and I, we pushed some changes up. Want to give master a shot before I tag it?
Seems to be working great. Stuff like [quote]]:[/[/quote] does not work anymore, but that's fine, it would give too many false positives.
Yeah, don't believe I would want to support such invalid syntax anyways, hah.
Thanks to @alquerci I believe we have something working. Can you re-try again with master? https://github.com/milesj/decoda
Thanks a lot, still works well. I tested with this crazy text:
[b] :([/b]
[QUOTE] ];[QUOTE] :/[QUOTE]Some text[/QUOTE]
:[/[/QUOTE]
More [i]text[/i];)
:[[/QUOTE]
All emoticons were parsed correctly.
Perfect! I'll close this and tag a version soon.
Code:
Output:
As you can see the :) inside the quote is rendered as text instead of an image, which seems to have to do with persistContent being false in QuoteFilter.