Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- Bug #54028 Directory::read() cannot handle non-unicode chars properly --SKIPIF-- ..
Decoded Output download
--TEST--
Bug #54028 Directory::read() cannot handle non-unicode chars properly
--SKIPIF--
<?php
include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
skip_if_not_win();
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
skip_if_no_required_exts("mbstring");
?>
--FILE--
<?php
/* This file is in UTF-8. */
include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
$prefix = __DIR__ . DIRECTORY_SEPARATOR . "testBug54028" . DIRECTORY_SEPARATOR;
$dirs = array("a", "", "", "", "", "", "");
mkdir($prefix);
foreach ($dirs as $d) {
mkdir($prefix . $d);
}
$directory = dir($prefix);
while (false !== ($content = $directory->read())) {
if ("." == $content || ".." == $content) continue;
printf("Returned (%s)
", $content);
printf("Encoding: %s
", mb_detect_encoding($content));
if ($content != get_basename_with_cp($prefix . $content, 65001, false)) {
echo "Verification failed!
";
}
echo "
";
}
foreach ($dirs as $d) {
rmdir($prefix . $d);
}
rmdir($prefix);
?>
--EXPECT--
Returned (a)
Encoding: ASCII
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Did this file decode correctly?
Original Code
--TEST--
Bug #54028 Directory::read() cannot handle non-unicode chars properly
--SKIPIF--
<?php
include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
skip_if_not_win();
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
skip_if_no_required_exts("mbstring");
?>
--FILE--
<?php
/* This file is in UTF-8. */
include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
$prefix = __DIR__ . DIRECTORY_SEPARATOR . "testBug54028" . DIRECTORY_SEPARATOR;
$dirs = array("a", "", "", "", "", "", "");
mkdir($prefix);
foreach ($dirs as $d) {
mkdir($prefix . $d);
}
$directory = dir($prefix);
while (false !== ($content = $directory->read())) {
if ("." == $content || ".." == $content) continue;
printf("Returned (%s)\n", $content);
printf("Encoding: %s\n", mb_detect_encoding($content));
if ($content != get_basename_with_cp($prefix . $content, 65001, false)) {
echo "Verification failed!\n";
}
echo "\n";
}
foreach ($dirs as $d) {
rmdir($prefix . $d);
}
rmdir($prefix);
?>
--EXPECT--
Returned (a)
Encoding: ASCII
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Returned ()
Encoding: UTF-8
Function Calls
None |
Stats
MD5 | 4c0baced4f9a4aa523b27b05fd68ec1a |
Eval Count | 0 |
Decode Time | 88 ms |