#7782 [Opn]: [PATCH] Cannot use PATH_INFO fully with php isapi, open since PHP 4.0.3pl1...
| From: | auke at muze dot nl | Date: | Wed, 10 Dec 2003 10:53:52 +0000 |
| Subject: | #7782 [Opn]: [PATCH] Cannot use PATH_INFO fully with php isapi, open since PHP 4.0.3pl1... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51888@lists.php.net to get a copy of this message | ||
ID: 7782
User updated by: auke at muze dot nl
Reported By: auke at muze dot nl
Status: Open
-Bug Type: Feature/Change Request
+Bug Type: IIS related
Operating System: Windows 2000
-PHP Version: 4.0.3pl1
+PHP Version: 4.0.3pl1 - 4.3.4
New Comment:
The three (3) year anniversary of this bug has just passed silently,
and I'd
just like to say that the latest release of PHP still has the same
problem, we still maintain patches that fix this for most versions of
PHP, although we're a bit behind now. An overview of all patches can
be
found at ftp://ftp.muze.nl/pub/ariadne/win/iis/.
We'd very much like someone to look at it and at least tell us whether
we are overlooking some long since included solution to this same
problem, or give another reason why our patches are not good enough to
make it to PHP itself. As a reference I'd like you to look at
http://www.zend.com/zend/week/week65.php#Heading4
where it was
mentioned
that the fix was scheduled for PHP 4.2.0... For some reason that never
happened.
If a patch for the current CVS of PHP is needed, please tell us and
we'll
make one.
Previous Comments:
------------------------------------------------------------------------
[2003-05-13 14:51:06] auke at muze dot nl
Well, I guess this bug scores high in the
longest-open-but-not-fixed-while-patches-are-available topscore... the
version number is correct, we've been fixing PHP since 4.0.6 and
patches for most PHP versions can be downloaded from
ftp://ftp.muze.nl/pub/ariadne/win/iis/
Can someone somewhere please tell me whether this will ever make it
into PHP, or perhaps if it has, but we simply haven't noticed?
If the problem is with the patches, please do tell...
------------------------------------------------------------------------
[2001-04-24 08:19:35] auke at muze dot nl
Hi,
Due to some problems we have had with the isapi version of php under
IIS,
we have made some changes in the sourcecode of this isapi module to
support
Apache style PATH_INFO and PATH_TRANSLATED variables. We tested it with
IIS 5 on Windows 2000 Server.
(See also Bug number 7782).
What we have done:
- In the function "init_request_info" we have added some code which
will
translate the "path_translated" server variable to a path
which points to the requested script on disk.
- In the function "sapi_isapi_register_server_variables2" we have
added
some translations for the variables $PATH_INFO and $PATH_TRANSLATED
PATH_INFO will now be translated from:
/script/path/script.php/some/non/existing/path
to
/some/non/existing/path
PATH_TRANSLATED will be translated from:
d:\Inetpub\wwwroot\script.php\some\non\existing\path
to
d:\Inetpub\wwwroot\script.php
- We have added a function named "sapi_isapi_get_server_var"
which will retrieve the requested server variable and returns
a pointer to it. This function has been added to make things more
structured (because of the need to check for a "INSUFFICIENT BUFFER"
error).
We have made a patch file of these changes against the cvs version 1.7
of
php4isapi.c. This path file is attached to this e-mail.
Please keep in mind that we did not have the opportunity to test this
fix with Zeus.
We hope you can/will commit this fix to the php cvs repository.
With kind regards,
Gijsbert te Riet,
Muze.
gijs@muze.nl
patch:
16a17
> | IIS PATH_TRANSLATED / PATH_INFO fix: Gijsbert te Riet
<gijs@muze.nl> |
83a85
> "PATH_INFO",
88a91
> "REQUEST_URI",
464a468,492
> static char *sapi_isapi_get_server_var(LPEXTENSION_CONTROL_BLOCK
lpECB, char *varname, DWORD *buffer_len) {
> char *buffer;
>
> buffer=emalloc(*buffer_len=ISAPI_SERVER_VAR_BUF_SIZE);
> if (!lpECB->GetServerVariable(lpECB->ConnID, varname, buffer,
buffer_len)) {
> if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
>
> buffer = (char *) erealloc(buffer, *buffer_len);
> if (!lpECB->GetServerVariable(lpECB->ConnID, varname, buffer,
buffer_len)) {
>
> efree(buffer);
> buffer=0;
>
> }
>
> } else {
>
> efree(buffer);
> buffer=0;
> }
> }
>
> return buffer;
> }
>
468,469c496
< DWORD variable_len;
< char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
---
> DWORD varsize, varbufsize;
470a498
> char *var_buf1, *var_buf2;
473,478c501,508
< variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
< if (lpECB->GetServerVariable(lpECB->ConnID, *p,
static_variable_buf, &variable_len)
< && static_variable_buf[0]) {
< php_register_variable(*p, static_variable_buf, track_vars_array
ELS_CC PLS_CC);
< if (recorded_values) {
< recorded_values[p-server_variables] =
estrndup(static_variable_buf, variable_len);
---
>
> if (variable_buf=sapi_isapi_get_server_var(lpECB, *p, &varsize)) {
> // translate PATH_INFO to Apache compatible PATH_INFO
> if (strcmp(*p, "PATH_INFO") == 0) {
> if (var_buf1=sapi_isapi_get_server_var(lpECB, "SCRIPT_NAME",
&varbufsize)) {
> memmove(variable_buf, variable_buf + strlen(var_buf1),
strlen(variable_buf) - strlen(var_buf1) + 1);
> efree(var_buf1);
> }
480,484c510,519
< } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
< variable_buf = (char *) emalloc(variable_len);
< if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf,
&variable_len)
< && variable_buf[0]) {
< php_register_variable(*p, variable_buf, track_vars_array ELS_CC
PLS_CC);
---
>
> // translate PATH_TRANSLATED to Apache compatible PATH_TRANSLATED
> if (strcmp(*p, "PATH_TRANSLATED") == 0) {
> if (var_buf1=sapi_isapi_get_server_var(lpECB, "PATH_INFO",
&varbufsize)) {
> if (var_buf2=sapi_isapi_get_server_var(lpECB, "SCRIPT_NAME",
&varbufsize)) {
>
variable_buf[strlen(variable_buf)-(strlen(var_buf1)-strlen(var_buf2))]='\0';
> efree(var_buf2);
> }
> efree(var_buf1);
> }
485a521,522
>
> php_register_variable(*p, variable_buf, track_vars_array ELS_CC
PLS_CC);
487,489c524
< recorded_values[p-server_variables] = variable_buf;
< } else {
< efree(variable_buf);
---
> recorded_values[p-server_variables] = estrndup(variable_buf,
varsize);
490a526,527
>
> efree(variable_buf);
649a687,691
> char scrambled='\0';
> char pathdelim='\\';
> char *pos=NULL;
> char *lastpos;
>
652a695,720
>
> // Check if PathTranslated really points to our script
> if (access(SG(request_info).path_translated, 4) != 0) {
> // no, it doesn't: let's translate it
> lastpos=pos=SG(request_info).path_translated;
> while (*pos && ( pos=(char *)strchr(pos, pathdelim) )) {
> if (pos==SG(request_info).path_translated) {
> lastpos=++pos;
> } else {
>
> scrambled=*pos;
> *pos='\0';
>
> if (!access((const char *)SG(request_info).path_translated,4)) {
>
> *pos=scrambled;
> lastpos=pos++;
> }
> }
>
> }
>
> *lastpos='\0';
> }
>
>
------------------------------------------------------------------------
[2001-01-28 19:01:33] jmoore@php.net
After some research ive found that iis doesnt infact support this (dont
know why its in CGI specs) You might want to take a look at:
http://support.microsoft.com/support/kb/articles/Q184/3/20.ASP
and
http://support.microsoft.com/support/kb/articles/Q252/3/52.ASP
Changing to feature/change reqest.
James
------------------------------------------------------------------------
[2001-01-28 16:12:56] jmoore@php.net
Verified under win2k IIS, will look into it further although this might
be a general difference between IIS and Apache PHP has no control
over.
James
------------------------------------------------------------------------
[2000-11-13 09:19:55] auke at muze dot nl
Under Apache it is possible to add non existant paths/files after a
call to a script, e.g.:
http://host/script.php/a/path/template.html
in which case Apache will start php with script.php and
/a/path/template.html in the server variable PATH_INFO.
when trying this in IIS 5.0 under windows 2000, it seems that IIS
correctly calls the phpisapi.dll, but php then returns the message:
Warning: Failed opening
'd:\inetpub\wwwroot\test.php\a\path\template.html' for inclusion
(include_path='') in Unknown on line 0
It would be nice if this worked like with the apache version...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=7782&edit=1