php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8898 #!/path/php at top of CGI script appears in output (Netscape Enterprise Server)
Submitted: 2001-01-25 05:24 UTC Modified: 2002-06-18 18:18 UTC
From: pete dot lee at ubs dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.4pl1 OS: Solaris 2.6
Private report: No CVE-ID: None
 [2001-01-25 05:24 UTC] pete dot lee at ubs dot com
Solaris 2.6; Netscape Enterprise Server 3.6.
Php interpreter built for installation outside Webserver document tree, with leading #! line in CGI script used to activate interpreter. This line appears as first line of the generated HTML. 

N.E.S. config statements:
 In mime.types:
  type=magnus-internal/cgi exts=php4
 In obj.conf:
  <Object name="default">
  .
  .
  Service fn="send-cgi" type="magnus-internal/cgi"
  .
  </Object>

This appears to be same situation reported for other webservers in bug reports 8506 and 8782.

sapi/cgi/cgi_main.c has code to check and skip leading #! line, but it is controlled by previous "if" clause which is present to set up reading interpreter input from script file in cgi environment. Making #! checks whenever input is from file fixes problem under CGI and is OK as well using same interpreter in standalone mode.

Suggested diff based on 4.0.4pl1 source (in effect just deletes an "else"):

*** sapi/cgi/cgi_main.c.orig	Sun Dec  3 02:09:13 2000
--- sapi/cgi/cgi_main.c	Wed Jan 24 16:39:34 2001
***************
*** 719,725 ****
  			return FAILURE;
  		}
  		file_handle.filename = argv0;
! 	} else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) {
  		/* #!php support */
  		c = fgetc(file_handle.handle.fp);
  		if (c == '#') {
--- 719,726 ----
  			return FAILURE;
  		}
  		file_handle.filename = argv0;
! 	}
! 	if (file_handle.handle.fp && file_handle.handle.fp!=stdin) {
  		/* #!php support */
  		c = fgetc(file_handle.handle.fp);
  		if (c == '#') {



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-25 09:03 UTC] pete dot lee at ubs dot com
Have belatedly noticed that M. Verrue made same suggestion in report 8782.
Mea culpa.
pl
 [2001-01-25 12:29 UTC] cynic@php.net
marked the other one (#8782) as dupe, this one has a diff
 [2001-08-31 11:53 UTC] sander@php.net
Marking this one as a duplicate, and copying the diff to 9041. Everybody happy?
 [2002-06-18 18:18 UTC] sniper@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 14:01:28 2019 UTC