@@ -130,8 +130,8 @@ static void tidy_doc_update_properties(PHPTidyObj *);
130
130
static void tidy_add_node_default_properties (PHPTidyObj * );
131
131
static void * php_tidy_get_opt_val (PHPTidyDoc * , TidyOption , TidyOptionType * );
132
132
static void php_tidy_create_node (INTERNAL_FUNCTION_PARAMETERS , tidy_base_nodetypes );
133
- static int _php_tidy_set_tidy_opt (TidyDoc , const char * , zval * );
134
- static int _php_tidy_apply_config_array (TidyDoc doc , const HashTable * ht_options );
133
+ static zend_result _php_tidy_set_tidy_opt (TidyDoc , const char * , zval * , uint32_t arg );
134
+ static zend_result _php_tidy_apply_config_array (TidyDoc doc , const HashTable * ht_options , uint32_t arg );
135
135
static PHP_INI_MH (php_tidy_set_clean_output );
136
136
static void php_tidy_clean_output_start (const char * name , size_t name_len );
137
137
static php_output_handler * php_tidy_output_handler_init (const char * handler_name , size_t handler_name_len , size_t chunk_size , int flags );
@@ -209,10 +209,10 @@ static void php_tidy_load_config(TidyDoc doc, const char *path)
209
209
}
210
210
}
211
211
212
- static zend_result php_tidy_apply_config (TidyDoc doc , const zend_string * str_string , const HashTable * ht_options )
212
+ static zend_result php_tidy_apply_config (TidyDoc doc , const zend_string * str_string , const HashTable * ht_options , uint32_t arg )
213
213
{
214
214
if (ht_options ) {
215
- return _php_tidy_apply_config_array (doc , ht_options );
215
+ return _php_tidy_apply_config_array (doc , ht_options , arg );
216
216
} else if (str_string ) {
217
217
if (php_check_open_basedir (ZSTR_VAL (str_string ))) {
218
218
return FAILURE ;
@@ -222,14 +222,14 @@ static zend_result php_tidy_apply_config(TidyDoc doc, const zend_string *str_str
222
222
return SUCCESS ;
223
223
}
224
224
225
- static int _php_tidy_set_tidy_opt (TidyDoc doc , const char * optname , zval * value )
225
+ static zend_result _php_tidy_set_tidy_opt (TidyDoc doc , const char * optname , zval * value , uint32_t arg )
226
226
{
227
227
TidyOption opt = tidyGetOptionByName (doc , optname );
228
228
zend_string * str , * tmp_str ;
229
229
zend_long lval ;
230
230
231
231
if (!opt ) {
232
- php_error_docref ( NULL , E_WARNING , "Unknown Tidy configuration option \"%s\"" , optname );
232
+ zend_argument_value_error ( arg , "Unknown Tidy configuration option \"%s\"" , optname );
233
233
return FAILURE ;
234
234
}
235
235
@@ -238,7 +238,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, const char *optname, zval *value)
238
238
#else
239
239
if (tidyOptIsReadOnly (opt )) {
240
240
#endif
241
- php_error_docref ( NULL , E_WARNING , "Attempting to set read-only option \"%s\"" , optname );
241
+ zend_argument_value_error ( arg , "Attempting to set read-only option \"%s\"" , optname );
242
242
return FAILURE ;
243
243
}
244
244
@@ -345,7 +345,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
345
345
346
346
TIDY_SET_DEFAULT_CONFIG (doc );
347
347
348
- if (php_tidy_apply_config (doc , config_str , config_ht ) != SUCCESS ) {
348
+ if (php_tidy_apply_config (doc , config_str , config_ht , 2 ) != SUCCESS ) {
349
349
RETVAL_FALSE ;
350
350
} else if (enc_len ) {
351
351
if (tidySetCharEncoding (doc , enc ) < 0 ) {
@@ -783,20 +783,24 @@ static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetyp
783
783
tidy_create_node_object (return_value , obj -> ptdoc , node );
784
784
}
785
785
786
- static int _php_tidy_apply_config_array (TidyDoc doc , const HashTable * ht_options )
786
+ static zend_result _php_tidy_apply_config_array (TidyDoc doc , const HashTable * ht_options , uint32_t arg )
787
787
{
788
788
zval * opt_val ;
789
789
zend_string * opt_name ;
790
790
791
791
if (!HT_IS_PACKED (ht_options )) {
792
792
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (ht_options , opt_name , opt_val ) {
793
793
if (opt_name == NULL ) {
794
- continue ;
794
+ zend_argument_type_error (arg , "must be of type array with keys as string" );
795
+ return FAILURE ;
795
796
}
796
- _php_tidy_set_tidy_opt (doc , ZSTR_VAL (opt_name ), opt_val );
797
+ _php_tidy_set_tidy_opt (doc , ZSTR_VAL (opt_name ), opt_val , arg );
797
798
} ZEND_HASH_FOREACH_END ();
799
+ return SUCCESS ;
800
+ } else {
801
+ zend_argument_type_error (arg , "must be of type array with keys as string" );
802
+ return FAILURE ;
798
803
}
799
- return SUCCESS ;
800
804
}
801
805
802
806
static int php_tidy_parse_string (PHPTidyObj * obj , const char * string , uint32_t len , const char * enc )
@@ -1018,7 +1022,7 @@ PHP_FUNCTION(tidy_parse_string)
1018
1022
object_init_ex (return_value , tidy_ce_doc );
1019
1023
obj = Z_TIDY_P (return_value );
1020
1024
1021
- if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht ) != SUCCESS
1025
+ if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) != SUCCESS
1022
1026
|| php_tidy_parse_string (obj , ZSTR_VAL (input ), (uint32_t )ZSTR_LEN (input ), enc ) != SUCCESS ) {
1023
1027
zval_ptr_dtor (return_value );
1024
1028
RETURN_FALSE ;
@@ -1086,7 +1090,7 @@ PHP_FUNCTION(tidy_parse_file)
1086
1090
object_init_ex (return_value , tidy_ce_doc );
1087
1091
obj = Z_TIDY_P (return_value );
1088
1092
1089
- if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht ) != SUCCESS
1093
+ if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) != SUCCESS
1090
1094
|| php_tidy_parse_string (obj , ZSTR_VAL (contents ), (uint32_t )ZSTR_LEN (contents ), enc ) != SUCCESS ) {
1091
1095
zval_ptr_dtor (return_value );
1092
1096
RETVAL_FALSE ;
@@ -1381,7 +1385,7 @@ PHP_METHOD(tidy, __construct)
1381
1385
1382
1386
zend_error_handling error_handling ;
1383
1387
zend_replace_error_handling (EH_THROW , NULL , & error_handling );
1384
- if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht ) != SUCCESS ) {
1388
+ if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) != SUCCESS ) {
1385
1389
zend_restore_error_handling (& error_handling );
1386
1390
zend_string_release_ex (contents , 0 );
1387
1391
RETURN_THROWS ();
@@ -1425,7 +1429,7 @@ PHP_METHOD(tidy, parseFile)
1425
1429
RETURN_THROWS ();
1426
1430
}
1427
1431
1428
- RETVAL_BOOL (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht ) == SUCCESS
1432
+ RETVAL_BOOL (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) == SUCCESS
1429
1433
&& php_tidy_parse_string (obj , ZSTR_VAL (contents ), (uint32_t )ZSTR_LEN (contents ), enc ) == SUCCESS );
1430
1434
1431
1435
zend_string_release_ex (contents , 0 );
@@ -1454,7 +1458,7 @@ PHP_METHOD(tidy, parseString)
1454
1458
TIDY_SET_CONTEXT ;
1455
1459
obj = Z_TIDY_P (object );
1456
1460
1457
- RETURN_BOOL (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht ) == SUCCESS
1461
+ RETURN_BOOL (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) == SUCCESS
1458
1462
&& php_tidy_parse_string (obj , ZSTR_VAL (input ), (uint32_t )ZSTR_LEN (input ), enc ) == SUCCESS );
1459
1463
}
1460
1464
0 commit comments