summaryrefslogtreecommitdiff
path: root/main/streams/streams.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-11-11 13:08:32 +0000
committerRob Richards <rrichards@php.net>2004-11-11 13:08:32 +0000
commitd563495a246e0d4e7ed3cb74ee2e8bcd48e285a3 (patch)
tree7affe6049a6e1bc57e71c5033f155dd1b7193195 /main/streams/streams.c
parente370219e2ac662df06cba4e97d0d79827c5a4ace (diff)
downloadphp-git-d563495a246e0d4e7ed3cb74ee2e8bcd48e285a3.tar.gz
add support for file://localhost/
support file:/// under windows again
Diffstat (limited to 'main/streams/streams.c')
-rwxr-xr-xmain/streams/streams.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 9a071746bc..c1ff46ce6b 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1492,24 +1492,36 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
}
/* TODO: curl based streams probably support file:// properly */
if (!protocol || !strncasecmp(protocol, "file", n)) {
-#ifdef PHP_WIN32
- if (protocol && path[n+1] == '/' && path[n+2] == '/' && path[n+4] != ':') {
+ if (protocol) {
+ int localhost = 0;
+
+ if (!strncasecmp(path, "file://localhost/", 17)) {
+ localhost = 1;
+ }
+
+#ifdef PHP_WIN32
+ if (localhost == 0 && path[n+3] != '\0' && path[n+3] != '/' && path[n+4] != ':') {
#else
- if (protocol && path[n+1] == '/' && path[n+2] == '/' && path[n+3] != '/') {
+ if (localhost == 0 && path[n+3] != '/') {
#endif
- if (options & REPORT_ERRORS) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "remote host file access not supported, %s", path);
+ if (options & REPORT_ERRORS) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "remote host file access not supported, %s", path);
+ }
+ return NULL;
}
- return NULL;
- }
- if (protocol && path_for_open) {
- /* skip past protocol and :/, but handle windows correctly */
- *path_for_open = (char*)path + n + 1;
- while (*(++*path_for_open)=='/');
+
+ if (path_for_open) {
+ /* skip past protocol and :/, but handle windows correctly */
+ *path_for_open = (char*)path + n + 1;
+ if (localhost == 1) {
+ (*path_for_open) += 11;
+ }
+ while (*(++*path_for_open)=='/');
#ifdef PHP_WIN32
- if (*(*path_for_open + 1) != ':')
+ if (*(*path_for_open + 1) != ':')
#endif
- (*path_for_open)--;
+ (*path_for_open)--;
+ }
}
if (options & STREAM_LOCATE_WRAPPERS_ONLY) {