#7782 [Com]: Cannot use PATH_INFO fully with php isapi

2002-11-04 Thread dvsing
 ID:   7782
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Assigned
 Bug Type: Feature/Change Request
 Operating System: Windows 2000
 PHP Version:  4.0.3pl1
 Assigned To:  jmoore
 New Comment:

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!


Previous Comments:


[2002-09-28 02:20:58] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

this was assigned to the wrong username.



[2001-11-30 06:40:48] [EMAIL PROTECTED]

Assigning to James (As discussed)



[2001-04-24 08:19:35] [EMAIL PROTECTED]

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.
[EMAIL PROTECTED]

patch:
16a17
| IIS PATH_TRANSLATED / PATH_INFO fix: Gijsbert te Riet
[EMAIL PROTECTED] |
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) {
  

#7782 [Com]: Cannot use PATH_INFO fully with php isapi

2002-09-28 Thread cyberpuck

 ID:   7782
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Assigned
 Bug Type: Feature/Change Request
 Operating System: Windows 2000
 PHP Version:  4.0.3pl1
 Assigned To:  jmoore
 New Comment:

Was the provided patch ever roled into the code?  I've got 4.04 and it
still isn't working.


Previous Comments:


[2002-04-23 15:13:30] [EMAIL PROTECTED]

this was assigned to the wrong username.



[2001-11-30 06:40:48] [EMAIL PROTECTED]

Assigning to James (As discussed)



[2001-04-24 08:19:35] [EMAIL PROTECTED]

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.
[EMAIL PROTECTED]

patch:
16a17
| IIS PATH_TRANSLATED / PATH_INFO fix: Gijsbert te Riet
[EMAIL PROTECTED] |
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]) {