#7782 [Asn->Opn]: Cannot use PATH_INFO fully with php isapi, open since PHP 4.0.3pl1...
| From: | sniper@php.net | Date: | Tue, 02 Dec 2003 06:43:11 +0000 |
| Subject: | #7782 [Asn->Opn]: 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-51539@lists.php.net to get a copy of this message | ||
ID: 7782
Updated by: sniper@php.net
Reported By: auke at muze dot nl
-Status: Assigned
+Status: Open
Bug Type: Feature/Change Request
Operating System: Windows 2000
PHP Version: 4.0.3pl1
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...
------------------------------------------------------------------------
[2003-05-13 12:18:25] imajes@php.net
james email not responding, unassign bugs
------------------------------------------------------------------------
[2002-11-05 02:33:40] auke at muze dot nl
We've been updating the patch for each new version of PHP, since we
really need this functionality for Ariadne. You can download a patched
version of the isapi.dll for a number of PHP versions at
ftp://ftp.muze.nl/pub/ariadne/win/iis/ Most
have the patched source
included as well.
We also really would like to see this patch in the main PHP
distribution...
Auke van Slooten
Muze
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/7782
--
Edit this bug report at http://bugs.php.net/?id=7782&edit=1