From ea4cee93c82496e3d1c4db1d69930f9fca85eb8b Mon Sep 17 00:00:00 2001 From: Danack Date: Thu, 13 Feb 2014 14:48:51 +0000 Subject: Allow valid multi-byte utf-8 characters to be allowed as file names in phar archives. --- ext/phar/tests/create_new_phar.phpt | 8 +++++++- ext/phar/tests/create_path_error.phpt | 31 +++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'ext/phar/tests') diff --git a/ext/phar/tests/create_new_phar.phpt b/ext/phar/tests/create_new_phar.phpt index ec57c27217..26794095e1 100644 --- a/ext/phar/tests/create_new_phar.phpt +++ b/ext/phar/tests/create_new_phar.phpt @@ -9,8 +9,13 @@ phar.require_hash=1 ===DONE=== @@ -18,4 +23,5 @@ include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.pha --EXPECT-- brand new! +Text in utf8 file. ===DONE=== diff --git a/ext/phar/tests/create_path_error.phpt b/ext/phar/tests/create_path_error.phpt index d3fc035860..7451d9cd39 100644 --- a/ext/phar/tests/create_path_error.phpt +++ b/ext/phar/tests/create_path_error.phpt @@ -22,15 +22,26 @@ var_dump(file_get_contents($pname . '/b.php')); function error_handler($errno, $errmsg) { - echo "Error: $errmsg\n"; + echo "Error: $errmsg"; } set_error_handler('error_handler'); -$checks = array('/', '.', '../', 'a/..', 'a/', 'b//a.php'); +$count = 0; +$checks = array( + '/', '.', '../', 'a/..', 'a/', 'b//a.php', + "Font\xE5\x84\xB7\xE9\xBB\x91pro.ttf", //two valid multi-byte characters + "\xF0\x9F\x98\x8D.ttf", // valid 4 byte char - smiling face with heart-shaped eyes + "Font\xE9\xBBpro.ttf", //Invalid multi-byte character - missing last byte + "Font\xBB\x91pro.ttf", //Invalid multi-byte character - missing first byte + "\xFC\x81\x81\x81\x81pro.ttf", //RFC 3629 limited char points to 0000-10FFFF aka 5 byte utf-8 not valid +); foreach($checks as $check) { + $count++; + echo "$count:"; file_put_contents($pname . '/' . $check, "error"); + echo "\n"; } $phar = new Phar($fname); @@ -54,9 +65,17 @@ foreach($checks as $check) --EXPECTF-- string(5) "query" string(5) "query" -Error: file_put_contents(phar://%s//): failed to open stream: phar error: file "" in phar "%s" cannot be empty -Error: file_put_contents(phar://%s/.): failed to open stream: phar error: file "" in phar "%s" cannot be empty -Error: file_put_contents(phar://%s/../): failed to open stream: phar error: file "" in phar "%s" cannot be empty -Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: file "" in phar "%s" cannot be empty +1:Error: file_put_contents(phar://%s//): failed to open stream: phar error: file "" in phar "%s" cannot be empty +2:Error: file_put_contents(phar://%s/.): failed to open stream: phar error: file "" in phar "%s" cannot be empty +3:Error: file_put_contents(phar://%s/../): failed to open stream: phar error: file "" in phar "%s" cannot be empty +4:Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: file "" in phar "%s" cannot be empty +5: +6: +7: +8: +9:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character +10:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character +11:Error: file_put_contents(phar:///%s): failed to open stream: phar error: invalid path "%s" contains illegal character Exception: Entry a does not exist and cannot be created: phar error: invalid path "a" contains illegal character ===DONE=== + -- cgit v1.2.1