PHP 4.0 Bug #8321 Updated: insert of double quotes in javascript

From: Date: Tue, 19 Dec 2000 14:09:47 +0000
Subject: PHP 4.0 Bug #8321 Updated: insert of double quotes in javascript
Groups: php.dev 
Request: Send a blank email to php-dev+get-41868@lists.php.net to get a copy of this message
ID: 8321 User Update by: jbourguignon@ecritel.net Status: Open Bug Type: *Session related Description: insert of double quotes in javascript I forgot something : when performed in Apache environment, a reload "fixes" the problem, ie the second call to the page is correct. This problem appeared with a MM_preloadimage()//v3 function inserted by dreamweaver so I guess others could meet the same problem. I got a javascript error as the code was broken by the intruding quotes. I "solved" my problem by renaming my array abc instead of a, meaning that the variable declaration is taken into account because an abc[i]; string is quoted execpt if declared in the script. Nota : I checked that the problem disappears when the page is a plain html file (index.html). Jerome Previous Comments: --------------------------------------------------------------------------- [2000-12-19 08:56:20] jbourguignon@ecritel.net Hi, When compiling php with --enable-trans-sid I get a rather strange behaviour : double quotes are inserted in javascript (between <script> and </script>) Here's my page : <html> <head> <script language="Javascript"> function MM_preloadImages() { var d=document; if(d.images) { if(!d.MM_p) d.MM_p=new Array(); var a = MM_preloadImages.arguments; var i; var j = d.MM_p.length; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0) { d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; } toto=a[i]; } } to=a[i]; to<a[i]; to=a[j]; to=b[i]; to=a; to=a[2]; to=a[]; to=a[2] to = a[ 2 ] ; to=a[ ]; to=b[] to=b to=ab to ab; to=b ; </script> oto=a[i]; </head> <body onload="javascript:toto=a[2];"> titi a[i]; </body> </html> All the to=... are here cos I tried to find out which "rule" the bug followed. It looks it has sthg to do with the "=" sign but I'm not positive :) Here's the result once parsed by PHP (this one was a command line one but we got the same with an Apache buil-in version) [root@smokyracle php-4.0.3pl1]# ./php index.php X-Powered-By: PHP/4.0.3pl1 Set-Cookie: PHPSESSID=18f7e65b019e224a86c02c036ff0bc8a; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-type: text/html <html> <head> <script language="Javascript"> function MM_preloadImages() { var d=document; if(d.images) { if(!d.MM_p) d.MM_p=new Array(); var a = MM_preloadImages.arguments; var i; var j = d.MM_p.length; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0) { d.MM_p[j]=new Image; d.MM_p[j++].src="a[i];" } toto="a[i];" } } to="a[i];" to<a[i]; to="a[j];" to="b[i];" to="a;" to="a[2];" to="a[];" to="a[2]" to = "a[" 2 ] ; to="a[" ]; to="b[]" to="b" to="ab" to ab; to="b" ; </script> oto=a[i]; </head> <body onload="javascript:toto=a[2];"> titi a[i]; </body> </html> I really don't think it's a feature :) Thank you Jerome --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8321

« previous php.dev (#41868) next »