1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
--TEST--
Trying to parse a file that is too large (over 4GB)
--EXTENSIONS--
tidy
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (getenv("SKIP_ASAN")) die("skip too big for asan");
if (getenv("GITHUB_ACTIONS")) die("skip potentially crashes on GitHub actions");
?>
--CONFLICTS--
all
--INI--
memory_limit="5G"
--FILE--
<?php
$path = __DIR__ . '/too_large_test.html';
$file = fopen($path, 'w+');
// Write over 4GB
const MIN_FILE_SIZE = 4_294_967_295;
var_dump(fseek($file, MIN_FILE_SIZE+10));
$s = str_repeat("a", 10);
$bytes_written = fwrite($file, $s);
if ($bytes_written === false) {
echo "Didn't write bytes\n";
}
$tidy = new tidy;
try {
var_dump($tidy->parseFile($path));
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(tidy_parse_file($path));
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
$tidy = new tidy($path);
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
tidy_repair_file($path);
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--CLEAN--
<?php
$path = __DIR__ . '/too_large_test.html';
unlink($path);
?>
--EXPECT--
int(0)
ValueError: File content is too long
ValueError: File content is too long
ValueError: File content is too long
ValueError: tidy_repair_file(): Argument #1 ($filename) File content is too long
|