Mybb: The 'double quotes in font lists' browser-independent SCEditor bug

Created on 21 Nov 2020  Â·  4Comments  Â·  Source: mybb/mybb

As opposed to my previous two recent SCEditor bug reports, the 'redundant tags on paste of unformatted text' browser-dependent SCEditor bug and the 'reduced size on paste of unformatted text' browser-dependent SCEditor bug, this bug report references solely Hovatek's thread MyCode parse error ( [font="droid sans", sans-serif] ). Along with those two prior bug reports, this one is heavily based on my post #9 in Hovatek's thread, from the first horizontal line onwards.

Specific to this bug report (and note that as opposed to the previous two bugs which were browser-dependent, this bug is browser-independent):

The 'double quotes in font lists' browser-independent SCEditor bug

Description: Sometimes, in scenarios the criteria of which I haven't yet rigorously identified, when pasting text into the WYSIWYG editor, its specified font is actually a comma-separated list of two or more fonts, and at least one of the fonts in that comma-separated list is enclosed in double quotes. When the post is posted, the associated MyBB font tag(s) is/are not rendered by MyBB's PHP parser, because that parser doesn't support double-quotes within the comma-separated list of fonts of a MyCode font tag.

How to reproduce: In any browser, bring up a new editor window through a page such as a New Reply page. Select Source mode. Paste the following MyCode into the editor, after first replacing the curly braces with square braces (since I am posting this on a MyBB forum, I can't paste valid MyCode tags as they would then be rendered - or not, as per this bug!):

{font=Test, "Test two"}Blah{/font}

Switch out of Source mode and then back into it. Confirm that the code has not changed. Then submit or preview the post. Notice that in the rendered post, the raw font tag shows up unrendered.

Impact: Moderate-severe. There can at times be so many of these unrendered font tags that the post once posted is effectively unreadable.

A working solution: Simply replace in the file jscript/bbcodes_sceditor.js the following code from within the "format" method relating to the "font" bbcode:

            return '[font=' + this.stripQuotes(font) + ']' + content + '[/font]';

with this:

            if (font[0] == '"' && font[font.length-1] == '"' && (font.match(/"/g) || []).length == 2) {
                font = font.substr(1, font.length-2);
            }
            font = font.replace(/"/g, "'");
            return '[font=' + font + ']' + content + '[/font]';

Now, when text is pasted into the editor in WYSIWYG mode, or when switching into Source mode, double quotes within lists of fonts are replaced with single quotes. Problem solved.

Additionally, it might be worth integrating into core code the code from my basic plugin attached to post #4 in Hovatek's thread. That code handles posts that have already been posted with double-quotes in their font tags, such that even with the above fix, those font tags display unrendered in the absence of the plugin's code.

Original thread: The 'double quotes in font lists' browser-independent SCEditor bug

1.8 confirmed bug

Most helpful comment

Since we don't have the resources to unnecessarily maintaining the SCEditor in full, I'd say it is good enough if the issue can be fixed from the MyBB package.

All 4 comments

Note: issues specific to SCEditor should probably go in our forked repository rather than here.

On Sat, 21 Nov 2020, at 20:06, Ben wrote:

As opposed to my previous two recent SCEditor bug reports, the
'redundant tags on paste of unformatted text' browser-dependent
SCEditor bug and the 'reduced size on paste of unformatted text'
browser-dependent SCEditor bug, this bug report references solely
Hovatek's thread MyCode parse error ( [font="droid sans", sans-serif]
). Along with those two prior bug reports, this one is heavily based on
my post #9 https://github.com/mybb/mybb/pull/9 in Hovatek's thread,
from the first horizontal line onwards.

Specific to this bug report (and note that as opposed to the previous
two bugs which were browser-dependent, this bug is browser-independent):

The 'double quotes in font lists' browser-independent SCEditor bug

Description: Sometimes, in scenarios the criteria of which I haven't
yet rigorously identified, when pasting text into the WYSIWYG editor,
its specified font is actually a comma-separated list of two or more
fonts, and at least one of the fonts in that comma-separated list is
enclosed in double quotes. When the post is posted, the associated MyBB
font tag(s) is/are not rendered by MyBB's PHP parser, because that
parser doesn't support double-quotes within the comma-separated list of
fonts of a MyCode font tag.

How to reproduce: In any browser, bring up a new editor window through
a page such as a New Reply page. Select Source mode. Paste the
following MyCode into the editor, after first replacing the curly
braces with square braces (since I am posting this on a MyBB forum, I
can't paste valid MyCode tags as they would then be rendered - or not,
as per this bug!):

{font=Test, "Test two"}Blah{/font}

Switch out of Source mode and then back into it. Confirm that the code
has not changed. Then submit or preview the post. Notice that in the
rendered post, the raw font tag shows up unrendered.

Impact: Moderate-severe. There can at times be so many of these
unrendered font tags that the post once posted is effectively
unreadable.

A working solution: Simply replace in the file
jscript/bbcodes_sceditor.js the following code from within the "format"
method relating to the "font" bbcode:

return '[font=' + this.stripQuotes(font) + ']' + content + '[/font]';
with this:

if (font[0] == '"' && font[font.length-1] == '"' && (font.match(/"/g) || []).length == 2) { font = font.substr(1, font.length-2); } font = font.replace(/"/g, "'"); return '[font=' + font + ']' + content + '[/font]';
Now, when text is pasted into the editor in WYSIWYG mode, or when
switching into Source mode, double quotes within lists of fonts are
replaced with single quotes. Problem solved.

Additionally, it might be worth integrating into core code the code
from my basic plugin attached to post #4
https://github.com/mybb/mybb/pull/4 in Hovatek's thread. That code
handles posts that have already been posted with double-quotes in their
font tags, such that even with the above fix, those font tags display
unrendered in the absence of the plugin's code.

Original thread: The 'double quotes in font lists' browser-independent
SCEditor bug https://community.mybb.com/thread-229727.html

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mybb/mybb/issues/4182, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAFW24PFIWCSJ2CVTAHSCDLSRAMUBANCNFSM4T57UTRA.

Note: issues specific to SCEditor should probably go in our forked repository rather than here.

@euantorano: Because we override the relevant BBCode format method ('font') in this repository's jscripts/bbcodes_sceditor.js file, the fix is necessary in that file regardless of whether we also apply a corresponding fix to the SCEditor fork.

I have a working fix for jscripts/bbcodes_sceditor.js, but am not sure whether it's worth porting to our SCEditor fork too.

Similar comments apply to #4184, except that in that case, of the three relevant BBCode format methods ('size', 'font', and 'color'), we only override the first two, so my working fix adds an override of the 'color' method.

Since we don't have the resources to unnecessarily maintaining the SCEditor in full, I'd say it is good enough if the issue can be fixed from the MyBB package.

Yes, I’d be happy with fixing it in the MyBB base, especially if your have some working code :)

On Wed, 25 Nov 2020, at 06:11, Omar Gonzalez wrote:

Since we don't have the resources to unnecessarily maintaining the
SCEditor in full, I'd say it is good enough if the issue can be fixed
from the MyBB package.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mybb/mybb/issues/4182#issuecomment-733489862, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAFW24OVHJFVZ6SESBXDOC3SRSNYBANCNFSM4T57UTRA.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

euantorano picture euantorano  Â·  4Comments

RikoDEV picture RikoDEV  Â·  3Comments

euantorano picture euantorano  Â·  4Comments

Ben-MyBB picture Ben-MyBB  Â·  5Comments

effone picture effone  Â·  5Comments