Req #20226 [Opn->Fbk]: can't do "foo.php/path.inf" via cgi (with patch)
Edit report at http://bugs.php.net/bug.php?id=20226&edit=1
ID: 20226
Updated by: jani@php.net
Reported by: tom at tomclegg dot net
Summary: can't do "foo.php/path.inf" via cgi (with patch)
-Status: Open
+Status: Feedback
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Unix
PHP Version: 4.2.3
Block user comment: N
Private report: N
New Comment:
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2002-11-03 05:36:42] tom at tomclegg dot net
I use php as a cgi usuing Apache's "Action" directive. If I put a
script in /u/joe/pub/example.php and visit http://joe/example.php/foo
then Apache puts /example.php/foo in PATH_INFO, and PHP tries to open
/u/joe/pub/example.php/foo. (Internal server error; premature end of
script headers)
This patch checks /u, /u/joe, /u/joe/pub, etc.; if one of them is a
regular file (in this case /u/joe/pub/example.php) then that file is
used as the script filename. Now the script runs, with the entire
PATH_INFO passed to it. (It's up to the script to figure out which part
to ignore.)
--- main/fopen_wrappers.c.orig Fri Aug 23 01:00:49 2002
+++ main/fopen_wrappers.c Sun Nov 3 02:54:26 2002
@@ -388,6 +388,23 @@
SG(request_info).path_translated = NULL;
return FAILURE;
}
+
+ /* check for /home/joe/public_html/example.php/pathinfo */
+ if (1) {
+ char *s;
+ for (s=filename+1; *s; s++) {
+ if (*s == PHP_DIR_SEPARATOR && *(s-1) != PHP_DIR_SEPARATOR) {
+ *s = 0;
+ if (0 == stat (filename, &st)) {
+ if (S_ISREG(st.st_mode)) {
+ break;
+ }
+ }
+ *s = PHP_DIR_SEPARATOR;
+ }
+ }
+ }
+
fp = VCWD_FOPEN(filename, "rb");
/* refuse to open anything that is not a regular file */
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=20226&edit=1
Thread (3 messages)