]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #43353 (wrong detection of 'data' wrapper causes notice)
authorArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 15:47:31 +0000 (15:47 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 15:47:31 +0000 (15:47 +0000)
ext/standard/tests/file/bug43353.phpt [new file with mode: 0644]
main/streams/streams.c

diff --git a/ext/standard/tests/file/bug43353.phpt b/ext/standard/tests/file/bug43353.phpt
new file mode 100644 (file)
index 0000000..a118178
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #43353 wrong detection of 'data' wrapper
+--FILE--
+<?php
+
+var_dump(is_dir('file:///datafoo:test'));
+var_dump(is_dir('datafoo:test'));
+var_dump(file_get_contents('data:text/plain,foo'));
+var_dump(file_get_contents('datafoo:text/plain,foo'));
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+string(3) "foo"
+
+Warning: file_get_contents(datafoo:text/plain,foo): failed to open stream: No such file or directory in %s
+bool(false)
index ce25c27393182da19185baee290aca53323a5ed3..a7dd5d2374eebb78237f61537d439cb6c8356db9 100755 (executable)
@@ -1521,7 +1521,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char
                n++;
        }
 
-       if ((*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", path, 4))) {
+       if ((*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || (n == 4 && !memcmp("data:", path, 5)))) {
                protocol = path;
        } else if (n == 5 && strncasecmp(path, "zlib:", 5) == 0) {
                /* BC with older php scripts and zlib wrapper */