|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8271 Using include() on file with javascript after session_start() corrupts output
Submitted: 2000-12-15 04:18 UTC Modified: 2001-05-11 21:19 UTC
From: bobm-php at burner dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.3pl1 OS: Windows NT Server 4
Private report: No CVE-ID: None
 [2000-12-15 04:18 UTC] bobm-php at burner dot 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]

  include( "test.html" );

[File: test.html]

<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];}


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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-19 20:21 UTC]
duplicate of #8311
 [2001-05-11 21:19 UTC]
This is fixed in releases >= 4.0.4pl1

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Feb 09 07:05:47 2023 UTC