@@ -775,11 +775,13 @@ static zend_result _php_tidy_apply_config_array(TidyDoc doc, const HashTable *ht
775
775
}
776
776
}
777
777
778
- static zend_result php_tidy_parse_string (PHPTidyObj * obj , const char * string , uint32_t len , const char * enc )
778
+ static zend_result php_tidy_parse_string (PHPTidyObj * obj , const zend_string * string , const char * enc )
779
779
{
780
780
TidyBuffer buf ;
781
781
782
- if (enc ) {
782
+ ZEND_ASSERT (!ZEND_SIZE_T_UINT_OVFL (ZSTR_LEN (string )));
783
+
784
+ if (enc ) {
783
785
if (tidySetCharEncoding (obj -> ptdoc -> doc , enc ) < 0 ) {
784
786
php_error_docref (NULL , E_WARNING , "Could not set encoding \"%s\"" , enc );
785
787
return FAILURE ;
@@ -789,9 +791,9 @@ static zend_result php_tidy_parse_string(PHPTidyObj *obj, const char *string, ui
789
791
obj -> ptdoc -> initialized = true;
790
792
791
793
tidyBufInit (& buf );
792
- tidyBufAttach (& buf , (byte * ) string , len );
794
+ tidyBufAttach (& buf , (byte * ) ZSTR_VAL ( string ), ( unsigned int ) ZSTR_LEN ( string ) );
793
795
if (tidyParseBuffer (obj -> ptdoc -> doc , & buf ) < 0 ) {
794
- php_error_docref (NULL , E_WARNING , "%s" , obj -> ptdoc -> errbuf -> bp );
796
+ php_error_docref (NULL , E_WARNING , "%s" , ( const char * ) obj -> ptdoc -> errbuf -> bp );
795
797
return FAILURE ;
796
798
}
797
799
tidy_doc_update_properties (obj );
@@ -995,7 +997,7 @@ PHP_FUNCTION(tidy_parse_string)
995
997
obj = Z_TIDY_P (return_value );
996
998
997
999
if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) != SUCCESS
998
- || php_tidy_parse_string (obj , ZSTR_VAL ( input ), ( uint32_t ) ZSTR_LEN ( input ) , enc ) != SUCCESS ) {
1000
+ || php_tidy_parse_string (obj , input , enc ) != SUCCESS ) {
999
1001
zval_ptr_dtor (return_value );
1000
1002
RETURN_FALSE ;
1001
1003
}
@@ -1063,7 +1065,7 @@ PHP_FUNCTION(tidy_parse_file)
1063
1065
obj = Z_TIDY_P (return_value );
1064
1066
1065
1067
if (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) != SUCCESS
1066
- || php_tidy_parse_string (obj , ZSTR_VAL ( contents ), ( uint32_t ) ZSTR_LEN ( contents ) , enc ) != SUCCESS ) {
1068
+ || php_tidy_parse_string (obj , contents , enc ) != SUCCESS ) {
1067
1069
zval_ptr_dtor (return_value );
1068
1070
RETVAL_FALSE ;
1069
1071
}
@@ -1348,7 +1350,7 @@ PHP_METHOD(tidy, __construct)
1348
1350
}
1349
1351
zend_restore_error_handling (& error_handling );
1350
1352
1351
- php_tidy_parse_string (obj , ZSTR_VAL ( contents ), ( uint32_t ) ZSTR_LEN ( contents ) , enc );
1353
+ php_tidy_parse_string (obj , contents , enc );
1352
1354
1353
1355
zend_string_release_ex (contents , 0 );
1354
1356
}
@@ -1385,7 +1387,7 @@ PHP_METHOD(tidy, parseFile)
1385
1387
}
1386
1388
1387
1389
RETVAL_BOOL (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) == SUCCESS
1388
- && php_tidy_parse_string (obj , ZSTR_VAL ( contents ), ( uint32_t ) ZSTR_LEN ( contents ) , enc ) == SUCCESS );
1390
+ && php_tidy_parse_string (obj , contents , enc ) == SUCCESS );
1389
1391
1390
1392
zend_string_release_ex (contents , 0 );
1391
1393
}
@@ -1413,7 +1415,7 @@ PHP_METHOD(tidy, parseString)
1413
1415
obj = Z_TIDY_P (ZEND_THIS );
1414
1416
1415
1417
RETURN_BOOL (php_tidy_apply_config (obj -> ptdoc -> doc , options_str , options_ht , 2 ) == SUCCESS
1416
- && php_tidy_parse_string (obj , ZSTR_VAL ( input ), ( uint32_t ) ZSTR_LEN ( input ) , enc ) == SUCCESS );
1418
+ && php_tidy_parse_string (obj , input , enc ) == SUCCESS );
1417
1419
}
1418
1420
1419
1421
0 commit comments