Skip to content

Tidy follow-up for GH-15046 #15053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ PHP NEWS
. Fix references in request_parse_body() options array. (nielsdos)
. Add RoundingMode enum. (timwolla, saki)

- Tidy:
. Failures in the constructor now throw exceptions rather than emitting
warnings and having a broken object. (nielsdos)

- XSL:
. Fix trampoline leak in xpath callables. (nielsdos)

Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ PHP 8.4 UPGRADE NOTES
. strcspn() with empty $characters now returns the length of the string instead
of incorrectly stopping at the first NUL character. See GH-12592.

- Tidy:
. Failures in the constructor now throw exceptions rather than emitting
warnings and having a broken object.

- XML:
. The xml_set_*_handler() functions now declare and check for an effective
signature of callable|string|null for the $handler parameters.
Expand Down
10 changes: 8 additions & 2 deletions ext/tidy/tests/bug54682.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ tidy
--FILE--
<?php

$nx = new Tidy("*");
$nx = new Tidy();
$nx->diagnose();
var_dump($nx);

?>
--EXPECTF--
Warning: tidy::__construct(): Cannot load "*" into memory%win %s on line %d
object(tidy)#%d (2) {
["errorBuffer"]=>
NULL
["value"]=>
NULL
}
9 changes: 6 additions & 3 deletions ext/tidy/tests/open_basedir_failure_config.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ echo "=== tidy_parse_file ===\n";
tidy_parse_file(__DIR__.'/open_basedir/test.html', 'my_config_file.ini');

echo "=== __construct ===\n";
$tidy = new tidy(__DIR__.'/open_basedir/test.html', 'my_config_file.ini');
try {
$tidy = new tidy(__DIR__.'/open_basedir/test.html', 'my_config_file.ini');
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}

echo "=== parseFile ===\n";
$tidy = new tidy;
Expand All @@ -38,8 +42,7 @@ Warning: tidy_parse_string(): open_basedir restriction in effect. File(my_config

Warning: tidy_parse_file(): open_basedir restriction in effect. File(my_config_file.ini) is not within the allowed path(s): (%sopen_basedir) in %s on line %d
=== __construct ===

Warning: tidy::__construct(): open_basedir restriction in effect. File(my_config_file.ini) is not within the allowed path(s): (%sopen_basedir) in %s on line %d
tidy::__construct(): open_basedir restriction in effect. File(my_config_file.ini) is not within the allowed path(s): (%sopen_basedir)
=== parseFile ===

Warning: tidy::parseFile(): open_basedir restriction in effect. File(my_config_file.ini) is not within the allowed path(s): (%sopen_basedir) in %s on line %d
Expand Down
9 changes: 6 additions & 3 deletions ext/tidy/tests/parsing_inexistent_file.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ var_dump($tidy->parseFile("does_not_exist.html"));

var_dump(tidy_parse_file("does_not_exist.html"));

$tidy = new tidy("does_not_exist.html");
try {
$tidy = new tidy("does_not_exist.html");
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Warning: tidy::parseFile(): Cannot load "does_not_exist.html" into memory in %s on line %d
bool(false)

Warning: tidy_parse_file(): Cannot load "does_not_exist.html" into memory in %s on line %d
bool(false)

Warning: tidy::__construct(): Cannot load "does_not_exist.html" into memory in %s on line %d
Cannot load "does_not_exist.html" into memory
Loading
Loading