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-- Basic long path test with file I/O, multibyte path and realpath() check --SKIPIF-..

Decoded Output download

--TEST--
Basic long path test with file I/O, multibyte path and realpath() check
--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
$p = "";
$s = str_repeat('x', 50) . "";
$how_many = 32;


for ($i = 0; $i < $how_many; $i++) {
    $p .= "$s";
    $p .= DIRECTORY_SEPARATOR;
}

/* path doesn't exist at this point! */
$p = realpath(__DIR__) . DIRECTORY_SEPARATOR . $p;

echo strlen($p), "\n", $p, "\n";

var_dump(mkdir($p, 0777, true));
var_dump(file_exists($p));

/* path exists now, ensure realpath() works! */
$p2 = realpath($p);
var_dump($p2);
/* realpath() will cut off the trailing slash */
var_dump(substr($p, 0, strlen($p) - 1) == $p2);

$p7 = $p . "hello.txt";

var_dump(file_put_contents($p7, "hello"));
var_dump(file_get_contents($p7));

unlink($p7);

for ($i = 0; $i < $how_many; $i++) {
    $p0 = substr($p, 0, strlen($p) - $i*(strlen($s) + 1));
    rmdir($p0);
}

var_dump(file_exists(realpath(__DIR__) . DIRECTORY_SEPARATOR . $s));

?>
--EXPECTF--
%d%d%d%d
%s\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x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xxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bool(true)
int(5)
string(5) "hello"
bool(false)

Did this file decode correctly?

Original Code

--TEST--
Basic long path test with file I/O, multibyte path and realpath() check
--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
$p = "";
$s = str_repeat('x', 50) . "";
$how_many = 32;


for ($i = 0; $i < $how_many; $i++) {
    $p .= "$s";
    $p .= DIRECTORY_SEPARATOR;
}

/* path doesn't exist at this point! */
$p = realpath(__DIR__) . DIRECTORY_SEPARATOR . $p;

echo strlen($p), "\n", $p, "\n";

var_dump(mkdir($p, 0777, true));
var_dump(file_exists($p));

/* path exists now, ensure realpath() works! */
$p2 = realpath($p);
var_dump($p2);
/* realpath() will cut off the trailing slash */
var_dump(substr($p, 0, strlen($p) - 1) == $p2);

$p7 = $p . "hello.txt";

var_dump(file_put_contents($p7, "hello"));
var_dump(file_get_contents($p7));

unlink($p7);

for ($i = 0; $i < $how_many; $i++) {
    $p0 = substr($p, 0, strlen($p) - $i*(strlen($s) + 1));
    rmdir($p0);
}

var_dump(file_exists(realpath(__DIR__) . DIRECTORY_SEPARATOR . $s));

?>
--EXPECTF--
%d%d%d%d
%s\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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