mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix incorrect error check in browsecap for pcre2_match() Add missing error check on tidyLoadConfig
This commit is contained in:
commit
0f394ecbe8
5 changed files with 29 additions and 15 deletions
|
@ -612,7 +612,7 @@ static int browser_reg_compare(browscap_entry *entry, zend_string *agent_name, b
|
||||||
}
|
}
|
||||||
rc = pcre2_match(re, (PCRE2_SPTR)ZSTR_VAL(agent_name), ZSTR_LEN(agent_name), 0, 0, match_data, php_pcre_mctx());
|
rc = pcre2_match(re, (PCRE2_SPTR)ZSTR_VAL(agent_name), ZSTR_LEN(agent_name), 0, 0, match_data, php_pcre_mctx());
|
||||||
php_pcre_free_match_data(match_data);
|
php_pcre_free_match_data(match_data);
|
||||||
if (PCRE2_ERROR_NOMATCH != rc) {
|
if (rc >= 0) {
|
||||||
/* If we've found a possible browser, we need to do a comparison of the
|
/* If we've found a possible browser, we need to do a comparison of the
|
||||||
number of characters changed in the user agent being checked versus
|
number of characters changed in the user agent being checked versus
|
||||||
the previous match found and the current match. */
|
the previous match found and the current match. */
|
||||||
|
|
|
@ -28,13 +28,13 @@ tidy_repair_file($l, $l, $l ,$l); // This doesn't emit any warning, TODO look in
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Warning: tidy_repair_string(): Could not load configuration file "1" in %s on line %d
|
Warning: tidy_repair_string(): Could not load the Tidy configuration file "1" in %s on line %d
|
||||||
|
|
||||||
Warning: tidy_repair_string(): Could not set encoding "1" in %s on line %d
|
Warning: tidy_repair_string(): Could not set encoding "1" in %s on line %d
|
||||||
|
|
||||||
Warning: tidy_repair_string(): Could not load configuration file "" in %s on line %d
|
Warning: tidy_repair_string(): Could not load the Tidy configuration file "" in %s on line %d
|
||||||
|
|
||||||
Warning: tidy_repair_string(): Could not load configuration file "1" in %s on line %d
|
Warning: tidy_repair_string(): Could not load the Tidy configuration file "1" in %s on line %d
|
||||||
|
|
||||||
Warning: tidy_repair_string(): Could not set encoding "1" in %s on line %d
|
Warning: tidy_repair_string(): Could not set encoding "1" in %s on line %d
|
||||||
Path cannot be empty
|
Path cannot be empty
|
||||||
|
|
12
ext/tidy/tests/gh10636.phpt
Normal file
12
ext/tidy/tests/gh10636.phpt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
--TEST--
|
||||||
|
GH-10636 (Tidy does not output notice when it encountered parse errors in the default configuration file)
|
||||||
|
--EXTENSIONS--
|
||||||
|
tidy
|
||||||
|
--INI--
|
||||||
|
tidy.default_config={PWD}/gh10636_config
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$a = new tidy(__DIR__."/007.html");
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Notice: main(): There were errors while parsing the Tidy configuration file "%sgh10636_config" in %s on line %d
|
1
ext/tidy/tests/gh10636_config
Normal file
1
ext/tidy/tests/gh10636_config
Normal file
|
@ -0,0 +1 @@
|
||||||
|
indent:@
|
|
@ -79,14 +79,7 @@
|
||||||
_php_tidy_apply_config_array(_doc, _val_ht); \
|
_php_tidy_apply_config_array(_doc, _val_ht); \
|
||||||
} else if (_val_str) { \
|
} else if (_val_str) { \
|
||||||
TIDY_OPEN_BASE_DIR_CHECK(ZSTR_VAL(_val_str)); \
|
TIDY_OPEN_BASE_DIR_CHECK(ZSTR_VAL(_val_str)); \
|
||||||
switch (tidyLoadConfig(_doc, ZSTR_VAL(_val_str))) { \
|
php_tidy_load_config(_doc, ZSTR_VAL(_val_str)); \
|
||||||
case -1: \
|
|
||||||
php_error_docref(NULL, E_WARNING, "Could not load configuration file \"%s\"", ZSTR_VAL(_val_str)); \
|
|
||||||
break; \
|
|
||||||
case 1: \
|
|
||||||
php_error_docref(NULL, E_NOTICE, "There were errors while parsing the configuration file \"%s\"", ZSTR_VAL(_val_str)); \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TIDY_OPEN_BASE_DIR_CHECK(filename) \
|
#define TIDY_OPEN_BASE_DIR_CHECK(filename) \
|
||||||
|
@ -96,9 +89,7 @@ if (php_check_open_basedir(filename)) { \
|
||||||
|
|
||||||
#define TIDY_SET_DEFAULT_CONFIG(_doc) \
|
#define TIDY_SET_DEFAULT_CONFIG(_doc) \
|
||||||
if (TG(default_config) && TG(default_config)[0]) { \
|
if (TG(default_config) && TG(default_config)[0]) { \
|
||||||
if (tidyLoadConfig(_doc, TG(default_config)) < 0) { \
|
php_tidy_load_config(_doc, TG(default_config)); \
|
||||||
php_error_docref(NULL, E_WARNING, "Unable to load Tidy configuration file at \"%s\"", TG(default_config)); \
|
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -220,6 +211,16 @@ static void TIDY_CALL php_tidy_panic(ctmbstr msg)
|
||||||
php_error_docref(NULL, E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
|
php_error_docref(NULL, E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void php_tidy_load_config(TidyDoc doc, const char *path)
|
||||||
|
{
|
||||||
|
int ret = tidyLoadConfig(doc, path);
|
||||||
|
if (ret < 0) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "Could not load the Tidy configuration file \"%s\"", path);
|
||||||
|
} else if (ret > 0) {
|
||||||
|
php_error_docref(NULL, E_NOTICE, "There were errors while parsing the Tidy configuration file \"%s\"", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value)
|
static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value)
|
||||||
{
|
{
|
||||||
TidyOption opt = tidyGetOptionByName(doc, optname);
|
TidyOption opt = tidyGetOptionByName(doc, optname);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue