goldyhmr237 / web-optimizator

Automatically exported from code.google.com/p/web-optimizator
0 stars 0 forks source link

[JS Parsing] Issue with JS generated HTML code being corrupted. #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. SMF 1.1.8
2. Tinyportal beta4
3. Activate the Shoutbox

What is the expected output? What do you see instead?
The output is partiatly trashed (\n \t visibles, irresponsible JS). There
is some JS code which produce HTML code on the fly,  the later is
incorrectly parsed resulting in corrupted HTML code.

HTML Code generated after :
<script language="JavaScript" type="text/javascript">
            var smileys = [
                [
                    [":vader","vader.gif","Vader"],
                    ["O:-)","angel.gif","Angel"],
                    [":cthulhu:","coolcthulhu.gif","Le grand Cthulhu"],
                    [":whip:","whip.gif","Fouet"],
                    [":hanged:","hanged.gif","Pendu"],
                    [":juggle:","juggle.gif","Jongleur"],
                    [":mad:","mad.gif","Fou"],
                    [":behead:","behead.gif","Guillotine"],
                    [":furious:","furious3.gif","Furieux"],
                    [":stupid:","stupid.gif","Gump"],
                    [":indian:","indian_chief.gif","Indien"],
                    [":gossip:","gossip.gif","Blah blah"],
                    [":xmas:","xmas.gif","Ho ! Ho ! Ho !"],
                    [":argue:","argue.gif",""],
                    [":greedy:","greedy.gif","Pognon..."],
                    [":sunny:","sunny.gif","Soleil"],
                    [":biker:","biker.gif","YMCA"],
                    [":baby:","baby.gif","Ouinnn !!! Ouinnn !!!"],
                    [":builder:","builder.gif","YMCA"],
                    [":cowboy:","cowboy.gif","Cowboy"],
                    [":love:","love.gif","Love"],
                    [":fireman:","fireman.gif","Pompier"],
                    [":book:","book2.gif","Lecture"],
                    [":computer:","computer.gif","Ordinateur"],
                    [":clown:","clown.gif","Clown"],
                    [":shaitan:","devil.gif","Demon"],
                    [":cop:","policeman.gif","Policier"],
                    [":army:","army.gif","Militaire"],
                    [":captain:","captain.gif","Captain America"],
                    [":flash:","flash.gif","Flash"],
                    [":superman:","superman.gif",""],
                    [":alien:","alien.gif","Un Alien"],
                    [":dead:","dead.gif","Mort"],
                    [":toilet:","toilet.gif",""],
                    [":king:","crown.gif",""],
                    [":ane:","dunce2.gif",""],
                    [":balloon:","balloon.gif",""],
                    [":bandana:","bandana.gif",""],
                    [":bigcry:","bigcry.gif",""],
                    [":bomb:","bomb.gif",""],
                    [":lips:","lips.gif","Pulpeuse"],
                    [":think:","thinking2.gif","Pensif"],
                    [":sniper:","rifle.gif","Sniper"],
                    [":guitar:","guitarist.gif","Guitare"]]];
            var smileyPopupWindow;

            function moreSmileys()
            {
                var row, i;

                if (smileyPopupWindow)
                    smileyPopupWindow.close();

                smileyPopupWindow = window.open("", "add_shout_smileys",
"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=480,height=220
,resizable=yes");
                smileyPopupWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>');
                smileyPopupWindow.document.write('\n\t<head><link type="text/css"
href="/web-optimizer/cache/css/830508a5de.css" rel="stylesheet" /><script
type="text/javascript"
src="/web-optimizer/cache/js/68583f72a0.js"></script>\n\t\t<title>&Eacute;motic&
ocirc;nes
additionnels</title>\n\t\t\n\t</head>');
smileyPopupWindow.document.write('\n\t<body style="margin:
1ex;">\n\t\t<table width="100%" cellpadding="5" cellspacing="0" border="0"
class="tborder">\n\t\t\t<tr class="titlebg"><td align="left">Choisir un
&eacute;motic&ocirc;ne</td></tr>\n\t\t\t<tr class="windowbg"><td
align="left">');
for (row = 0; row < smileys.length; row++)
{
for (i = 0; i < smileys[row].length; i++)
{
smileys[row][i][2] = smileys[row][i][2].replace(/"/g, '&quot;');
smileyPopupWindow.document.write('<a href="javascript:void(0);"
onclick="window.opener.replaceText(&quot; ' + smileys[row][i][0] + '&quot;,
window.opener.document.forms.tp_shoutbox.tp_shout); window.focus(); return
false;"><img src="http://www.XXX.com/SMF/Smileys/set12/' +
smileys[row][i][1] + '" alt="' + smileys[row][i][2] + '" title="' +
smileys[row][i][2] + '" style="padding: 4px;" border="0" /></a> ');
}
smileyPopupWindow.document.write("<br />");
}
smileyPopupWindow.document.write('</td></tr>\n\t\t\t<tr><td align="center"
class="windowbg"><a href="javascript:window.close();\">Fermer la
fen&ecirc;tre</a></td></tr>\n\t\t</table>\n\t</body>\n</html>');
smileyPopupWindow.document.close();
}
// ]]></script>

What version of the product are you using? On what operating system?
0.48

Please provide any additional information below.

Original issue reported on code.google.com by butc...@gmail.com on 26 May 2009 at 11:21

GoogleCodeExporter commented 9 years ago
Please provide initial JS code (starting from 'smileyPopupWindow = ').
First of all raw HTML code in JS code is not standard-complaint (XHTML). There 
should
be DOM methods or something simliar.
Secondly you can replace < with \x3c (and double quotes) -- this situation will 
be
parsed correctly.
Thirdly you can move this code out of <head> to let Web Optimizer find <head>
properly and parse it.

Original comment by sunny.dr...@gmail.com on 27 May 2009 at 6:42

GoogleCodeExporter commented 9 years ago

Original comment by sunny.dr...@gmail.com on 27 May 2009 at 6:42

GoogleCodeExporter commented 9 years ago
So, closing as related to not standard-complaint code?

Original comment by sunny.dr...@gmail.com on 6 Jun 2009 at 5:19