Bug #8271 Updated: Using include() on file with javascript after session_start() corrupts output
| From: | sniper@php.net | Date: | Sat, 12 May 2001 01:19:57 +0000 |
| Subject: | Bug #8271 Updated: Using include() on file with javascript after session_start() corrupts output | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-54950@lists.php.net to get a copy of this message | ||
ID: 8271
Updated by: sniper
Reported By: bobm-php@burner.com
Old-Status: Duplicate
Status: Closed
Bug Type: *Session related
Operating system:
PHP Version: 4.0.3pl1
Assigned To:
Comments:
This is fixed in releases >= 4.0.4pl1
Previous Comments:
---------------------------------------------------------------------------
[2001-01-19 20:21:26] cynic@php.net
duplicate of #8311
---------------------------------------------------------------------------
[2000-12-15 04:18:35] bobm-php@burner.com
Using IIS 4.02.0720 and PHP4.0.3p1 as a DLL; No additional modules.
If I include() a file with Javascript in it _after_ having done a session_start(), the resulting
file spit out with include() contains a bunch of errant quotation marks at odd places in the
Javascript, causing it to fail in the browser. If I don't ever start a session, it works fine.
Additional tests done: Reading the html directly via IIS works fine; Reading it through IIS as a
.php works fine; include()ed without session_start() works fine.
Consider two files:
[File: test.php]
<?
session_start();
include( "test.html" );
?>
[File: test.html]
<html>
<head>
<title>Crosspoint Clients</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 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];}}
}
function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
{
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
---8<---
If you dial up test.php through IIS, you will wind up with some quotes thrown in before the closing
braces of some of the Javascript functions, as well as duplicate quotes or inserted quotes in the
functions themselves. Comment out the session_start() in test.php and they go away.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=8271&edit=2