News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Wysiwig and Safari invalide bbcode formating

Started by petitchevalroux, November 17, 2015, 05:42:47 AM

Previous topic - Next topic

petitchevalroux

Using the Wysiwg under Safari generate wrong bbcode when formatting multiples lines.

How to reproduce :
Under Safari Version 9.0.1 (11601.2.7.2):
1 - create a new post and add the following text :
line 1
line 2
line 3
line 4
2 - Select all the content and apply font courrier
3 - Select line 2 and line 4 and apply color red
4 - Hit the preview button

Output :
line 1
line 2
[/color]line 3
line 4

First fix :
In Subs-Editor.php function html_to_bbc in the following line :
if ($context['browser']['is_webkit'])
    $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br />', ''), $text);
Two things :
The dot is useless in the first pattern
The second pattern is wrong, I think the ~ are missing. Causing </div> to be replaced by <>.

I suggest :
if ($context['browser']['is_webkit'])
    $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?>~i', '~</div>~'), array('<br />', ''), $text);

Second fix :
$curCloseTags seems to be not handled properly when having multiple styles.
Using the following html as $text param for html_to_bbc($text) isolate the wrong behaviour:
<span style="font-family: courier; color: red;">line 3</span>
Output from html_to_bbc:
[font=courier][color=red]line 3[/font][/color]

In my specific example replacing:
$curCloseTags .= '[/color]';
With:
$curCloseTags = '[/color]' . $curCloseTags;
Fix the bug


I suggest prepending the closing tag instead of appending to all $curCloseTag as closing tags must be done in reverse order.

Need some advice here ;)


Steve

The most common advice you'll get is to not use that editor since it is known to have several bugs. It's being replaced in version 2.1.
DO NOT pm me for support!

petitchevalroux

Quote from: Steve on November 17, 2015, 09:29:07 AM
The most common advice you'll get is to not use that editor since it is known to have several bugs. It's being replaced in version 2.1.
No way to integrate the proposed fix in 2.0.x series ? Do I need to wait the 2.1 series ?

Kindred

We appreciate your efforts in tracking this down, and even providing the suggested fix.

we may (probably) include it in a future 2.0.x release...   no promises there.
However, a new release will not be made, until/unless there is a security issue or a major bug reported.
We typically do not make releases for minor bugs.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

petitchevalroux

Ok no problem, I just needed the answer to give an answer to my users ;)

Oldiesmann

There is a mod to add the editor from 2.1 to 2.0 as well, but I don't know how well it works. http://custom.simplemachines.org/mods/index.php?mod=3594
Michael Eshom
Christian Metal Fans

Advertisement: