Elxis CMS Forum

Support => Technical support => Topic started by: toumimi on August 11, 2009, 17:28:35

Title: Function mosWarning
Post by: toumimi on August 11, 2009, 17:28:35
Hi,
I suggest an amelioration for function mosWarning in includes/core/elxis.php

Code: [Select]
function mosWarning($warning, $title='Elxis Warning') {
global $mosConfig_live_site;
$isrtl = (_GEM_RTL) ? 'LEFT' : 'RIGHT';
$tip = "<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . $warning . "', CAPTION, ' &nbsp; ".$title."', BELOW, ".$isrtl.");\" onmouseout=\"return nd();\"><img src=\"" . $mosConfig_live_site . "/includes/js/ThemeOffice/warning.png\" border=\"0\" alt=\"".$title."\" /></a>";
return $tip;
}

A saw a problem in french language : quotes are escaped in the language files but when included into javascript function onmouseover="return overlib('___',_,_,_)", quotes must be escaped too.
I know we can solve it by modifying language file, but since language string can be used anywhere else (not into single quotes), a slash should appear and it's not better.

Please consider to escape string warning, taking into account already escaped messages ( ' => \'   and  \' -> \'  not  \\' )

EDIT : example of modification which works for me (not tested with every strings but is should work) :
$warning = str_replace('\'','\\\'',str_replace('\\\'','\'',$warning));
  => Unescaped single quotes (if any slash)
  => Escape single quotes by adding a slash before

Tell me what you think about that...
Florian
Title: Re: Function mosWarning
Post by: toumimi on August 13, 2009, 16:33:28
Nobody saw it before ?
It can be a problem if we can't see a warning info if it contains a non-escaped quote ...

Florian
Title: Re: Function mosWarning
Post by: datahell on August 18, 2009, 00:06:30
We do not recommended adding single quotes inside language strings that are used by javascript. That's why there is no single quotes, in english language files. But for those having single quotes your solution is good. I will add it in Elxis. Thanks.
Title: Re: Function mosWarning
Post by: toumimi on August 18, 2009, 17:04:50
Thanks for your consideration  ;)