php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8321 insert of double quotes in javascript
Submitted: 2000-12-19 08:56 UTC Modified: 2000-12-22 17:41 UTC
From: jbourguignon at ecritel dot net Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.3pl1 OS: Redhat linux 6.0
Private report: No CVE-ID: None
 [2000-12-19 08:56 UTC] jbourguignon at ecritel dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-19 09:09 UTC] jbourguignon at ecritel dot net
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
 [2000-12-22 17:41 UTC] sas@php.net
We have refined the behaviour of the URL rewriter in 4.0.4, so please give it a try.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 18:01:32 2024 UTC