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