com php-src: Require strict base64 in data URI: ext/standard/te sts/file/stream_rfc2397_006.phpt main/str eams/memory.c
| From: | Nikita Popov | Date: | Fri, 22 Jul 2016 16:03:55 +0000 |
| Subject: | com php-src: Require strict base64 in data URI: ext/standard/te sts/file/stream_rfc2397_006.phpt main/str eams/memory.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93326@lists.php.net to get a copy of this message | ||
Commit: 7a02704c0ecdf4373c810760e70a424841619e0c
Author: Lauri Kenttä <lauri.kentta@gmail.com> Mon, 11 Jul 2016 12:40:03 +0300
Committer: Nikita Popov <nikic@php.net> Fri, 22 Jul 2016 18:03:55 +0200
Parents: f775199ac70abef4bf7fa29c805d73df09131e21
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7a02704c0ecdf4373c810760e70a424841619e0c
Log:
Require strict base64 in data URI
As the tests already show, the data URI wrapper is supposed to fail
for corrupt input, but for some reason, one case of invalid input is
still allowed to pass?! Strict base64 makes a lot more sense here.
Also, Chromium and Firefox fail on invalid base64, so it's a logical
choice for PHP as well.
Changed paths:
M ext/standard/tests/file/stream_rfc2397_006.phpt
M main/streams/memory.c
Diff:
diff --git a/ext/standard/tests/file/stream_rfc2397_006.phpt
b/ext/standard/tests/file/stream_rfc2397_006.phpt
index e6694a2..f6616a0 100644
--- a/ext/standard/tests/file/stream_rfc2397_006.phpt
+++ b/ext/standard/tests/file/stream_rfc2397_006.phpt
@@ -26,7 +26,9 @@ NULL
Warning: file_get_contents() expects parameter 1 to be a valid path, string given in %s line %d
NULL
-string(13) "foobar foobar"
+
+Warning: file_get_contents(data:;base64,#Zm9vYmFyIGZvb2Jhcg==): failed to open stream: rfc2397:
unable to decode in %sstream_rfc2397_006.php on line %d
+bool(false)
Warning: file_get_contents(data:;base64,#Zm9vYmFyIGZvb2Jhc=): failed to open stream: rfc2397:
unable to decode in %sstream_rfc2397_006.php on line %d
bool(false)
diff --git a/main/streams/memory.c b/main/streams/memory.c
index afa45c3..a1af61e 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -720,7 +720,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
dlen--;
if (base64) {
- base64_comma = php_base64_decode((const unsigned char *)comma, dlen);
+ base64_comma = php_base64_decode_ex((const unsigned char *)comma, dlen, 1);
if (!base64_comma) {
zval_ptr_dtor(&meta);
php_stream_wrapper_log_error(wrapper, options, "rfc2397: unable to decode");