2007-03-02, 05:19 PM
I just noticed that if you have two smilies with the following code:
:-? and :-?? ... and when :-?? is used, it gets converted in the following fashion: (assume ":-?" = thinking.gif, and ":-??" = whaaat.gif)
So it seems to be replacing again when it finds ":-?" in title attribute. I know it's my fault (or the MyBB Merge converters fault for using the code as the name), but it still tells something.
I don't like the idea of using str_replace at all, as many of the time it produces unexpected results. Maybe using a space before, or after the smilie is a good idea. Something like this: (just a rough example, not tested, but delivers my idea)
I think MyBB promotes the idea of more well-formed smilie codes and differentiation between codes and names, but give me a break, no one can keep guessing what will break the functionality.
:-? and :-?? ... and when :-?? is used, it gets converted in the following fashion: (assume ":-?" = thinking.gif, and ":-??" = whaaat.gif)
<img src="http://url.com/images/smilies/whaaat.gif" style="vertical-align: middle;" border="0" alt="<img src="http://url.com/images/smilies/thinking.gif" style="vertical-align: middle;" border="0" alt=":-?" title=":-?" />?" title="<img src="http://url.com/images/smilies/thinking.gif" style="vertical-align: middle;" border="0" alt=":-?" title=":-?" />?" />
So it seems to be replacing again when it finds ":-?" in title attribute. I know it's my fault (or the MyBB Merge converters fault for using the code as the name), but it still tells something.
I don't like the idea of using str_replace at all, as many of the time it produces unexpected results. Maybe using a space before, or after the smilie is a good idea. Something like this: (just a rough example, not tested, but delivers my idea)
$var = preg_replace("#(^|\s){$smilie_code_cleaned}(\s|$)#", '\\1{$replacement}\\2", $var);
I think MyBB promotes the idea of more well-formed smilie codes and differentiation between codes and names, but give me a break, no one can keep guessing what will break the functionality.