From 7fa224f4926f1e5d065f9a9d38ceb5417d12c584 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:50:43 +0200 Subject: [PATCH] Improve error message for too long file in ext/tidy As suggested in https://github.com/php/php-src/pull/14862#discussion_r1667788025 --- ext/tidy/tests/parsing_file_too_large.phpt | 8 ++++---- ext/tidy/tidy.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/tidy/tests/parsing_file_too_large.phpt b/ext/tidy/tests/parsing_file_too_large.phpt index a0118ba9ebdce..efb539e528e09 100644 --- a/ext/tidy/tests/parsing_file_too_large.phpt +++ b/ext/tidy/tests/parsing_file_too_large.phpt @@ -61,7 +61,7 @@ unlink($path); ?> --EXPECT-- int(0) -ValueError: Input string is too long -ValueError: Input string is too long -ValueError: Input string is too long -ValueError: tidy_repair_file(): Argument #1 ($filename) Input string is too long +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 diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 6178eb36a9bb7..cf01bb0d35bd6 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -306,7 +306,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file) if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(data))) { if (is_file) { zend_string_release_ex(data, false); - zend_argument_value_error(1, "Input string is too long"); + zend_argument_value_error(1, "File content is too long"); } else { zend_argument_value_error(1, "is too long"); } @@ -973,7 +973,7 @@ static zend_result php_tidy_output_handler(void **nothing, php_output_context *o tidyOptSetBool(doc, TidyMark, no); if (ZEND_SIZE_T_UINT_OVFL(output_context->in.used)) { - php_error_docref(NULL, E_WARNING, "Input string is too long"); + php_error_docref(NULL, E_WARNING, "File content is too long"); return status; } @@ -1086,7 +1086,7 @@ PHP_FUNCTION(tidy_parse_file) if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(contents))) { zend_string_release_ex(contents, 0); - zend_value_error("Input string is too long"); + zend_value_error("File content is too long"); RETURN_THROWS(); } @@ -1384,7 +1384,7 @@ PHP_METHOD(tidy, __construct) if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(contents))) { zend_string_release_ex(contents, 0); - zend_value_error("Input string is too long"); + zend_value_error("File content is too long"); RETURN_THROWS(); } @@ -1423,7 +1423,7 @@ PHP_METHOD(tidy, parseFile) if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(contents))) { zend_string_release_ex(contents, 0); - zend_value_error("Input string is too long"); + zend_value_error("File content is too long"); RETURN_THROWS(); }