php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6795 Problem with the value of $PATH_TRANSLATED
Submitted: 2000-09-17 19:49 UTC Modified: 2001-05-27 22:01 UTC
From: drew at elysium dot ltd dot uk Assigned:
Status: Closed Package: Apache related
PHP Version: 4.0.2 OS: RH 6.2
Private report: No CVE-ID: None
 [2000-09-17 19:49 UTC] drew at elysium dot ltd dot uk
There seems to be a problem with the values of $PATH_TRANSLATED under different circumstances :-

In your Apache document_root create the following files :-

.htaccess
AddHandler testhandler .test
Action testhandler handler.phtml

handler.phtml
<? print "PATH_TRANSLATED = $PATH_TRANSLATED"; ?>

index.test
Content not used

You will need AllowOverride All (or similar) in the Directory spec for your Apache document root (to all adding handlers).

Here is a list of requests and responses

http://localhost/index.test -
    PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect)
http://localhost/handler.phtml -
    PATH_TRANSLATED = /home/httpd/html/handler.phtml (Correct)
http://localhost/index.test/path_info -
    PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect)
http://localhost/handler.phtml/path_info -
    PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect)

The reason I have put incorrect for 3 of the tests is that the value differs from the value of PATH_TRANSLATED that Apache provides.  PHP just copies the value of SCRIPT_FILENAME over the top of PATH_TRANSLATED.  Please find attached a patch to make to responses the same as Apache's version of PATH_TRANSLATED.

http://localhost/index.test -
    PATH_TRANSLATED = /home/httpd/html/index.test (Correct)
http://localhost/handler.phtml -
    PATH_TRANSLATED = /home/httpd/html/handler.phtml (Correct)
http://localhost/index.test/path_info -
    PATH_TRANSLATED = /home/httpd/html/index.test/path_info (Correct)
http://localhost/handler.phtml/path_info -
    PATH_TRANSLATED = /home/httpd/html/path_info (Incorrect)

Not really sure whats going on with the last test - bug in Apache.  There is also a pretty big bug in Apache when doing these type of tests from a public_html (~user) type of directory.

Rgds Drew Wells

--- php-4.0.2/sapi/apache/mod_php4.c.orig       Sun Aug 20 15:29:00 2000
+++ php-4.0.2/sapi/apache/mod_php4.c    Mon Sep 18 12:16:49 2000
@@ -232,7 +232,7 @@
        register int i;
        array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
        table_entry *elts = (table_entry *) arr->elts;
-       char *script_filename=NULL;
+       char *script_filename = NULL, *path_translated = NULL;
 
        for (i = 0; i < arr->nelts; i++) {
                char *val;
@@ -241,7 +241,10 @@
                        val = elts[i].val;
                        if (!strcmp(elts[i].key, "SCRIPT_FILENAME")) {
                                script_filename = val;
+                       } else if (!strcmp(elts[i].key, "PATH_TRANSLATED")) {
+                               path_translated = val;
                        }
+
                } else {
                        val = empty_string;
                }
@@ -249,7 +252,7 @@
        }
 
        /* insert special variables */
-       if (script_filename) {
+       if (script_filename && !path_translated) {
                php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array ELS_CC PLS_CC);
        }
        php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array ELS_CC PLS_CC);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-04 09:01 UTC] sniper@php.net
Could you please check if this problem exists when
using the PHP 4.0.4RC3:

http://www.php.net/distributions/php-4.0.4RC3.tar.gz

--Jani
 [2000-12-30 14:05 UTC] sniper@php.net
No feedback, considered fixed.

--Jani
 [2001-01-16 06:03 UTC] sniper@php.net
Reopened per user request. Problem still exists
with php4.0.4pl1

--Jani
 [2001-05-27 22:01 UTC] sniper@php.net
This should be fixed in PHP 4.0.5, reopen if this is not the case.

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 16:01:28 2024 UTC