2020-10-07, 04:38 PM
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:
with this:
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.
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.