PHP 4.0 Bug #8271: Using include() on file with javascript after session_start() corrupts output

From: Date: Fri, 15 Dec 2000 09:18:35 +0000
Subject: PHP 4.0 Bug #8271: Using include() on file with javascript after session_start() corrupts output
Groups: php.dev 
Request: Send a blank email to php-dev+get-41433@lists.php.net to get a copy of this message
From: bobm-php@burner.com Operating system: Windows NT Server 4 PHP version: 4.0.3pl1 PHP Bug Type: IIS related Bug description: Using include() on file with javascript after session_start() corrupts output 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. -- Edit Bug report at: http://bugs.php.net/?id=8271&edit=1

« previous php.dev (#41433) next »