2019-03-27, 06:37 PM
In MyBB 1.8.20 if the modal template was edited (or just saved) in the ACP, the following error is displayed in the browser console:
because the modal template content in headerinclude contains line breaks before and after the backslashes:
Steps to reproduce:
Go to your ACP, edit and save "modal" Template, reload your forum, check browser console.
It seems templates saved via ACP have different line breaks than the templates imported from XML files.
Proposed fix:
In global.php (lines 941-945) replace:
with:
"SyntaxError: ' ' string literal contains an unescaped line break".
because the modal template content in headerinclude contains line breaks before and after the backslashes:
var templates = {
modal: '<div class=\"modal\">
\
<div style=\"overflow-y: auto; max-height: 400px;\">
\
<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" class=\"tborder\">
\
<tr>
\
<td class=\"thead\" colspan=\"2\"><strong>__message__</strong></td>
\
</tr>
\
<tr>
\
<td colspan=\"2\" class=\"trow1\">
\
<div style=\"text-align: center\" class=\"modal_buttons\">__buttons__</div></td>
\
</tr>
\
</table>
\
</div>
\
</div>',
Steps to reproduce:
Go to your ACP, edit and save "modal" Template, reload your forum, check browser console.
It seems templates saved via ACP have different line breaks than the templates imported from XML files.
Proposed fix:
In global.php (lines 941-945) replace:
$jsTemplates = array();
foreach (array('modal', 'modal_button') as $template) {
eval('$jsTemplates["'.$template.'"] = "'.$templates->get($template, 1, 0).'";');
$jsTemplates[$template] = str_replace("\n", "\\\n", addslashes($jsTemplates[$template]));
}
with:
$jsTemplates = array();
foreach (array('modal', 'modal_button') as $template) {
eval('$jsTemplates["'.$template.'"] = "'.$templates->get($template, 1, 0).'";');
$jsTemplates[$template] = str_replace(array("\n","\r"), array("\\\n", ""), addslashes($jsTemplates[$template]));
}