]> granicus.if.org Git - php/commitdiff
MFB: Allow urlencode()d filer names in php://filter (fixes #43008)
authorArnaud Le Blanc <lbarnaud@php.net>
Sat, 2 Aug 2008 06:37:34 +0000 (06:37 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Sat, 2 Aug 2008 06:37:34 +0000 (06:37 +0000)
ext/standard/php_fopen_wrapper.c
ext/standard/tests/file/bug43008.phpt [new file with mode: 0644]

index 60c853b1187e6ba498bc65de0e3b9128deec2113..b60599d10a89e93278063bb660789ff7e841c715 100644 (file)
@@ -142,6 +142,7 @@ static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, i
 
        p = php_strtok_r(filterlist, "|", &token);
        while (p) {
+               php_url_decode(p, strlen(p));
                if (read_chain) {
                        if ((temp_filter = php_stream_filter_create(p, NULL, php_stream_is_persistent(stream) TSRMLS_CC))) {
                                php_stream_filter_append(&stream->readfilters, temp_filter);
diff --git a/ext/standard/tests/file/bug43008.phpt b/ext/standard/tests/file/bug43008.phpt
new file mode 100644 (file)
index 0000000..5e11cfc
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #43008 (php://filter uris ignore url encoded filternames and can't handle slashes)
+--FILE--
+<?php
+$url = b""
+       . b"php://filter/read="
+       . urlencode(b"convert.iconv.ISO-8859-15/UTF-8")
+       . b'|' . urlencode(b"string.rot13")
+       . b'|' . urlencode(b"string.rot13")
+       . b'|' . urlencode(b"convert.iconv.UTF-8/ISO-8859-15")
+       . b"/resource=data://text/plain,foob%E2r";
+var_dump(urlencode(file_get_contents($url)));
+?>
+--EXPECTF--
+string(8) "foob%E2r"