#7782 [Asn]: Cannot use PATH_INFO fully with php isapi
| From: | auke at muze dot nl | Date: | Tue, 05 Nov 2002 08:33:40 +0000 |
| Subject: | #7782 [Asn]: Cannot use PATH_INFO fully with php isapi | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-24086@lists.php.net to get a copy of this message | ||
ID: 7782
User updated by: auke@muze.nl
Reported By: auke@muze.nl
Status: Assigned
Bug Type: Feature/Change Request
Operating System: Windows 2000
PHP Version: 4.0.3pl1
Assigned To: jmoore
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2002-11-04 21:46:33] dvsing@sonicspike.net
I'm running PHP 4.2.3 ISAPI and as far as I can tell this problem is
still present.
Test case:
c:\www\test.php exists and contains "<? phpinfo(); ?>".
When requesting http://localhost/test.php the standard
phpinfo() page
is shown, however when requesting
http://localhost/test.php/other/path/info
the PHP API returns a message
that it failed to open "c:\www\test.php\other\path\info". The PHP API
is incorrectly determining the php script to process when presented
with path info. This really needs to be fixed!
------------------------------------------------------------------------
[2002-09-28 02:20:58] cyberpuck@excite.com
Was the provided patch ever roled into the code? I've got 4.04 and it
still isn't working.
------------------------------------------------------------------------
[2002-04-23 15:13:30] jimw@php.net
this was assigned to the wrong username.
------------------------------------------------------------------------
[2001-11-30 06:40:48] derick@php.net
Assigning to James (As discussed)
------------------------------------------------------------------------
[2001-04-24 08:19:35] auke@muze.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';
> }
>
>
------------------------------------------------------------------------
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