if (*location != '/') {
if (*(location+1) != '\0') {
php_dirname(resource->path, strlen(resource->path));
- snprintf(loc_path, sizeof(loc_path) - 1, "%s%s", resource->path, location);
+ if (resource->path && *(resource->path) == '/' && *(resource->path + 1) == '\0') {
+ snprintf(loc_path, sizeof(loc_path) - 1, "%s%s", resource->path, location);
+ } else {
+ snprintf(loc_path, sizeof(loc_path) - 1, "%s/%s", resource->path, location);
+ }
} else {
snprintf(loc_path, sizeof(loc_path) - 1, "/%s", location);
}
} else {
snprintf(new_path, sizeof(new_path) - 1, "%s://%s%s", resource->scheme, resource->host, loc_path);
}
- }
- else {
+ } else {
strlcpy(new_path, location, sizeof(new_path));
}
stream = php_stream_url_wrap_http(NULL, new_path, mode, options, opened_path, context STREAMS_CC TSRMLS_CC);