php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33392 unable to override SCRIPT_FILENAME for input source
Submitted: 2005-06-18 06:11 UTC Modified: 2005-06-20 05:09 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php dot 5 dot magnum3065 at spamgourmet dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.0.4 OS: Debian GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php dot 5 dot magnum3065 at spamgourmet dot com
New email:
PHP Version: OS:

 

 [2005-06-18 06:11 UTC] php dot 5 dot magnum3065 at spamgourmet dot com
Description:
------------
When the SCRIPT_FILENAME environment variable is set this is given precedence over all other ways of providing the input source.  

I am trying to use the PHP executable to provide syntax highlighting of PHP source within a web application (not PHP-based).  However since the PHP executable is called from within the CGI application, the SCRIPT_FILENAME variable is set to the CGI file.  So, rather than highlighting the content I've tried passing through stdin, as well as a filename parameter to the executable, PHP processes the CGI file.

This filename provided as a command line parameter should be given precedence, and if "-" is given as the filename, the content should be processed from stdin.

Reproduce code:
---------------
From a bash command line:

$ echo "Content I want highlighted" > process_me.txt
$ echo "This gets output instead" > not_me.txt
$ export SCRIPT_FILENAME=not_me.txt/
$ php -qs process_me.txt


Expected result:
----------------
<code><span style="color: #000000">
Content I want highlighted<br /></span>


Actual result:
--------------
<code><span style="color: #000000">
This gets output instead<br /></span>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-18 06:12 UTC] php dot 5 dot magnum3065 at spamgourmet dot com
Oops, the trailing slash on not_me.txt/ is a typo.
 [2005-06-18 06:59 UTC] php dot 5 dot magnum3065 at spamgourmet dot com
Upon further investigation it appears that the SCRIPT_FILENAME variable is actually required if any of the following are set: SERVER_NAME, SERVER_SOFTWARE, REQUEST_METHOD, PATH_TRANSLATED, GATEWAY_INTERFACE.
 [2005-06-18 15:08 UTC] sniper@php.net
Write a script and pass the filename as parameter. 
See:
http://www.php.net/manual/en/function.highlight-file.php
 [2005-06-18 21:50 UTC] php dot 5 dot magnum3065 at spamgourmet dot com
This is for the Trac issue tracking tool: http://projects.edgewall.com/trac

We can't use a PHP script to do the highlighting since the application itself is not written in PHP.  However some of our users would like to use PHP's syntax highlighting for their source files.  So, we're trying to use the PHP executable to perform the highlighting.  Unfortunately the _implict_ filename specified by the SCRIPT_FILENAME environment variable is given prescedence over the _explicit_ filename passed as an argument to the executable.  This order of prescedence is difficult to work around since it requires unsetting a half dozen environment variables before running the PHP executable.  It would be more intuitive to use the SCRIPT_FILENAME only when a filename is not explicitly specified (including calling PHP like "php -- -" to specify reading the input from stdin).
 [2005-06-18 23:09 UTC] sniper@php.net
You're just trying to use the wrong tools (or right tool wrong way). Use the PHP CLI binary instead. There is no bug in the CGI binary..

 [2005-06-20 05:09 UTC] php dot 5 dot magnum3065 at spamgourmet dot com
Ok, that makes sense.  Our system has been updated to require the CLI version of the PHP executable.

The distinction between these seems to be a bit vauge since the CGI executable can actually function quite similarly to the CLI version when the CGI environment variables are not set.  The fact that it seems like the two can't actually be built simultaneously is also a bit confusing.  Fortunately it seems like most binary distributions of PHP have both versions available.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC