Bug #71541 [Opn->Nab]: Script invoked multiple times if PATH_INFO present

From: Date: Sun, 07 Feb 2016 11:47:51 +0000
Subject: Bug #71541 [Opn->Nab]: Script invoked multiple times if PATH_INFO present
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199089@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71541&edit=1 ID: 71541 Updated by: requinix@php.net Reported by: lobbotermey at gmail dot com Summary: Script invoked multiple times if PATH_INFO present -Status: Open +Status: Not a bug Type: Bug Package: URL related Operating System: Ubuntu 14.04.3 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: As you say, the browser is requesting default.css in the same "directory" as the current page, resulting in /foo.php/default.css. So your PHP script will be invoked again. Previous Comments: ------------------------------------------------------------------------ [2016-02-07 10:16:38] lobbotermey at gmail dot com Description: ------------ The test script generates a simple HTML document containing the $_SERVER PATH_INFO and SCRIPT_FILENAME variables and writes the same to a file called "test". This appears to work as expected and, provided you invoke it with a conventional URI, eg "http://example.com/foo.php", everything is fine. However, if you invoke it with a URI that includes path info - for example "http://example.com/foo.php/" (note trailing "/") - although the echo to the browser appears to work, if you look at the "test" file, you see that the script has in fact been run multiple times. The problem appears to be related to the stylesheet; the script is invoked once as "http://example.com/foo.php/" and then a second time as "http://example.com/foo.php/default.css", presumably as the browser attempts to fetch the stylesheet and the server interprets it as a call to the same script with different path info and invokes PHP again. Im not sure exactly where the problem lies here. PHP, Apache and the browser (tried with both FF44 and Chrome43) all appear to be behaving as designed, but the result is still broken. At the very least, this should probably be documented somewhere. Test script: --------------- // WARNING: this will write a file called "test" echo "<!doctype html>\n"; echo "<html lang=en>\n"; echo "<head>\n"; echo "<meta charset=utf-8>\n"; echo "<link rel=StyleSheet href=default.css type=text/css>\n"; echo "<title>Test PATH_INFO bug</title>\n"; echo "</head>\n"; echo "<body>\n"; echo "<p>Server SCRIPT_FILENAME is '{$_SERVER['SCRIPT_FILENAME']}'.</p>\n"; echo "<p>Server PATH_INFO is '{$_SERVER['PATH_INFO']}'.</p>\n"; if (($fh = fopen('test', 'a')) !== FALSE) { fwrite($fh, $_SERVER['SCRIPT_FILENAME'] . "\n" . $_SERVER['PATH_INFO'] . "\n"); fclose($fh); } echo "</body>\n"; echo "</html>\n"; Expected result: ---------------- The "test" file should contain: /$DOCROOT/test.php / Actual result: -------------- The "test" file actually contains: /$DOCROOT/test.php / /$DOCROOT/test.php /default.css ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71541&edit=1

« previous php.bugs (#199089) next »