mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +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:
1
NEWS
1
NEWS
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
17
ext/enchant/tests/broker_dict_exists_empty.phpt
Normal file
17
ext/enchant/tests/broker_dict_exists_empty.phpt
Normal 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
|
||||
23
ext/enchant/tests/broker_set_ordering_empty.phpt
Normal file
23
ext/enchant/tests/broker_set_ordering_empty.phpt
Normal 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
|
||||
Reference in New Issue
Block a user