13
13
| license@php.net so we can mail you a copy immediately. |
14
14
+----------------------------------------------------------------------+
15
15
| Authors: Rasmus Lerdorf <rasmus@php.net> |
16
- | Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
16
+ | Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
17
17
| Wez Furlong <wez@thebrainroom.com> |
18
18
| Gustavo Lopes <cataphract@php.net> |
19
19
+----------------------------------------------------------------------+
60
60
/* Macro for disabling flag of translation of non-basic entities where this isn't supported.
61
61
* Not appropriate for html_entity_decode/htmlspecialchars_decode */
62
62
#define LIMIT_ALL (all , doctype , charset ) do { \
63
- if ((all) && (CHARSET_PARTIAL_SUPPORT((charset)) || (doctype) == ENT_HTML_DOC_XML1)) \
64
- (all) = 0; \
63
+ (all) = (all) && !CHARSET_PARTIAL_SUPPORT((charset)) && ((doctype) != ENT_HTML_DOC_XML1); \
65
64
} while (0)
66
65
67
66
#define MB_FAILURE (pos , advance ) do { \
@@ -109,7 +108,7 @@ static inline unsigned int get_next_char(
109
108
/* We'll follow strategy 2. from section 3.6.1 of UTR #36:
110
109
* "In a reported illegal byte sequence, do not include any
111
110
* non-initial byte that encodes a valid character or is a leading
112
- * byte for a valid sequence.» */
111
+ * byte for a valid sequence." */
113
112
unsigned char c ;
114
113
c = str [pos ];
115
114
if (c < 0x80 ) {
@@ -1419,7 +1418,7 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
1419
1418
{
1420
1419
char * str , * hint_charset = NULL ;
1421
1420
int str_len , hint_charset_len = 0 ;
1422
- int len ;
1421
+ size_t new_len ;
1423
1422
long flags = ENT_COMPAT ;
1424
1423
char * replaced ;
1425
1424
zend_bool double_encode = 1 ;
@@ -1428,8 +1427,8 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
1428
1427
return ;
1429
1428
}
1430
1429
1431
- replaced = php_escape_html_entities_ex (str , str_len , & len , all , (int ) flags , hint_charset , double_encode TSRMLS_CC );
1432
- RETVAL_STRINGL (replaced , len , 0 );
1430
+ replaced = php_escape_html_entities_ex (str , str_len , & new_len , all , (int ) flags , hint_charset , double_encode TSRMLS_CC );
1431
+ RETVAL_STRINGL (replaced , ( int ) new_len , 0 );
1433
1432
}
1434
1433
/* }}} */
1435
1434
@@ -1468,17 +1467,18 @@ PHP_FUNCTION(htmlspecialchars)
1468
1467
PHP_FUNCTION (htmlspecialchars_decode )
1469
1468
{
1470
1469
char * str ;
1471
- int str_len , len ;
1470
+ int str_len ;
1471
+ size_t new_len = 0 ;
1472
1472
long quote_style = ENT_COMPAT ;
1473
1473
char * replaced ;
1474
1474
1475
1475
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s|l" , & str , & str_len , & quote_style ) == FAILURE ) {
1476
1476
return ;
1477
1477
}
1478
1478
1479
- replaced = php_unescape_html_entities (str , str_len , & len , 0 /*!all*/ , quote_style , NULL TSRMLS_CC );
1479
+ replaced = php_unescape_html_entities (str , str_len , & new_len , 0 /*!all*/ , quote_style , NULL TSRMLS_CC );
1480
1480
if (replaced ) {
1481
- RETURN_STRINGL (replaced , len , 0 );
1481
+ RETURN_STRINGL (replaced , ( int ) new_len , 0 );
1482
1482
}
1483
1483
RETURN_FALSE ;
1484
1484
}
@@ -1489,7 +1489,8 @@ PHP_FUNCTION(htmlspecialchars_decode)
1489
1489
PHP_FUNCTION (html_entity_decode )
1490
1490
{
1491
1491
char * str , * hint_charset = NULL ;
1492
- int str_len , hint_charset_len = 0 , len ;
1492
+ int str_len , hint_charset_len = 0 ;
1493
+ size_t new_len = 0 ;
1493
1494
long quote_style = ENT_COMPAT ;
1494
1495
char * replaced ;
1495
1496
@@ -1498,9 +1499,9 @@ PHP_FUNCTION(html_entity_decode)
1498
1499
return ;
1499
1500
}
1500
1501
1501
- replaced = php_unescape_html_entities (str , str_len , & len , 1 /*all*/ , quote_style , hint_charset TSRMLS_CC );
1502
+ replaced = php_unescape_html_entities (str , str_len , & new_len , 1 /*all*/ , quote_style , hint_charset TSRMLS_CC );
1502
1503
if (replaced ) {
1503
- RETURN_STRINGL (replaced , len , 0 );
1504
+ RETURN_STRINGL (replaced , ( int ) new_len , 0 );
1504
1505
}
1505
1506
RETURN_FALSE ;
1506
1507
}
@@ -1599,10 +1600,7 @@ PHP_FUNCTION(get_html_translation_table)
1599
1600
LIMIT_ALL (all , doctype , charset );
1600
1601
1601
1602
array_init (return_value );
1602
-
1603
- if (CHARSET_PARTIAL_SUPPORT (charset )) {
1604
- all = 0 ;
1605
- }
1603
+
1606
1604
entity_table = determine_entity_table (all , doctype );
1607
1605
if (all && !CHARSET_UNICODE_COMPAT (charset )) {
1608
1606
to_uni_table = enc_to_uni_index [charset ];
0 commit comments