1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix missing empty string checks in ext/enchant

The library requires the tags to be non-empty, and also requires the
ordering to be non-empty. For the tags, otherwise, assertion failures
can be observed.

Closes GH-18733.
This commit is contained in:
Niels Dossche
2025-06-01 18:45:04 +02:00
parent b871261c10
commit 88f546b166
4 changed files with 56 additions and 0 deletions

1
NEWS
View File

@@ -71,6 +71,7 @@ PHP NEWS
- Enchant:
. Added enchant_dict_remove_from_session(). (nielsdos)
. Added enchant_dict_remove(). (nielsdos)
. Fix missing empty string checks. (nielsdos)
- EXIF:
. Add OffsetTime* Exif tags. (acc987)

View File

@@ -529,6 +529,11 @@ PHP_FUNCTION(enchant_broker_dict_exists)
PHP_ENCHANT_GET_BROKER;
if (taglen == 0) {
zend_argument_must_not_be_empty_error(2);
RETURN_THROWS();
}
RETURN_BOOL(enchant_broker_dict_exists(pbroker->pbroker, tag));
}
/* }}} */
@@ -554,6 +559,16 @@ PHP_FUNCTION(enchant_broker_set_ordering)
PHP_ENCHANT_GET_BROKER;
if (ptaglen == 0) {
zend_argument_must_not_be_empty_error(2);
RETURN_THROWS();
}
if (porderinglen == 0) {
zend_argument_must_not_be_empty_error(3);
RETURN_THROWS();
}
enchant_broker_set_ordering(pbroker->pbroker, ptag, pordering);
RETURN_TRUE;
}

View File

@@ -0,0 +1,17 @@
--TEST--
enchant_broker_dict_exists() function - empty tag
--EXTENSIONS--
enchant
--FILE--
<?php
$broker = enchant_broker_init();
try {
enchant_broker_dict_exists($broker, '');
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "Done\n";
?>
--EXPECT--
enchant_broker_dict_exists(): Argument #2 ($tag) must not be empty
Done

View File

@@ -0,0 +1,23 @@
--TEST--
enchant_broker_set_ordering() function - empty tag
--EXTENSIONS--
enchant
--FILE--
<?php
$broker = enchant_broker_init();
try {
enchant_broker_set_ordering($broker, '', '');
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
enchant_broker_set_ordering($broker, '*', '');
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "Done\n";
?>
--EXPECT--
enchant_broker_set_ordering(): Argument #2 ($tag) must not be empty
enchant_broker_set_ordering(): Argument #3 ($ordering) must not be empty
Done