cvs: php4 /ext/standard http_fopen_wrapper.c
| From: | Ilia Alshanetsky | Date: | Sun, 29 Dec 2002 20:01:34 +0000 |
| Subject: | cvs: php4 /ext/standard http_fopen_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-17454@lists.php.net to get a copy of this message | ||
iliaa Sun Dec 29 15:01:34 2002 EDT
Modified files:
/php4/ext/standard http_fopen_wrapper.c
Log:
Fixed bug #21267 (opening URLs that result in redirection to a relative
path was failing).
Index: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.54 php4/ext/standard/http_fopen_wrapper.c:1.55
--- php4/ext/standard/http_fopen_wrapper.c:1.54 Thu Dec 5 15:59:49 2002
+++ php4/ext/standard/http_fopen_wrapper.c Sun Dec 29 15:01:33 2002
@@ -18,7 +18,7 @@
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: http_fopen_wrapper.c,v 1.54 2002/12/05 20:59:49 helly Exp $ */
+/* $Id: http_fopen_wrapper.c,v 1.55 2002/12/29 20:01:33 iliaa Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -339,19 +339,25 @@
zval *entry, **entryp;
char new_path[HTTP_HEADER_BLOCK_SIZE];
+ char loc_path[HTTP_HEADER_BLOCK_SIZE];
*new_path='\0';
- if (strlen(location)<8 || (strncasecmp(location, "http://", 7) && strncasecmp(location, "https://", 8))) {
- strcpy(new_path, resource->scheme);
- strlcat(new_path, resource->host, sizeof(new_path));
- if ((use_ssl && resource->port != 443) || (!use_ssl && resource->port !=
80)) {
- snprintf(new_path+strlen(new_path), sizeof(new_path)-strlen(new_path)-1, ":%d",
resource->port);
- }
+ if (strlen(location)<8 || (strncasecmp(location, "http://", sizeof("http://")-1)
&& strncasecmp(location, "https://", sizeof("https://")-1))) {
if (*location != '/') {
- php_dirname(resource->path, strlen(resource->path));
- snprintf (new_path+strlen(new_path), sizeof(new_path)-strlen(new_path)-1, "%s/",
resource->path);
+ if (*(location+1) != '\0') {
+ php_dirname(resource->path, strlen(resource->path));
+ snprintf(loc_path, sizeof(loc_path) - 1, "%s%s", resource->path, location);
+ } else {
+ snprintf(loc_path, sizeof(loc_path) - 1, "/%s", location);
+ }
+ } else {
+ strlcpy(loc_path, location, sizeof(loc_path));
+ }
+ if ((use_ssl && resource->port != 443) || (!use_ssl && resource->port !=
80)) {
+ snprintf(new_path, sizeof(new_path) - 1, "%s://%s:%d%s", resource->scheme,
resource->host, resource->port, loc_path);
+ } else {
+ snprintf(new_path, sizeof(new_path) - 1, "%s://%s%s", resource->scheme,
resource->host, loc_path);
}
- strlcat(new_path, location, sizeof(new_path));
}
else {
strlcpy(new_path, location, sizeof(new_path));