Skip to content

Commit fa08743

Browse files
committed
Use 'ENT_QUOTES|ENT_SUBSTITUTE' for HTML encoding and decoding functions
1 parent 7b2c098 commit fa08743

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,15 @@ function headers_list(): array {}
512512

513513
/* {{{ html.c */
514514

515-
function htmlspecialchars(string $string, int $flags = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {}
515+
function htmlspecialchars(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE, ?string $encoding = null, bool $double_encode = true): string {}
516516

517-
function htmlspecialchars_decode(string $string, int $flags = ENT_COMPAT): string {}
517+
function htmlspecialchars_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE): string {}
518518

519-
function html_entity_decode(string $string, int $flags = ENT_COMPAT, ?string $encoding = null): string {}
519+
function html_entity_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE, ?string $encoding = null): string {}
520520

521-
function htmlentities(string $string, int $flags = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {}
521+
function htmlentities(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE, ?string $encoding = null, bool $double_encode = true): string {}
522522

523-
function get_html_translation_table(int $table = HTML_SPECIALCHARS, int $flags = ENT_COMPAT, string $encoding = "UTF-8"): array {}
523+
function get_html_translation_table(int $table = HTML_SPECIALCHARS, int $flags = ENT_QUOTES | ENT_SUBSTITUTE, string $encoding = "UTF-8"): array {}
524524

525525
/* }}} */
526526

ext/standard/basic_functions_arginfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,27 +765,27 @@ ZEND_END_ARG_INFO()
765765

766766
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_htmlspecialchars, 0, 1, IS_STRING, 0)
767767
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
768-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_COMPAT")
768+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_QUOTES | ENT_SUBSTITUTE")
769769
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
770770
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, double_encode, _IS_BOOL, 0, "true")
771771
ZEND_END_ARG_INFO()
772772

773773
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_htmlspecialchars_decode, 0, 1, IS_STRING, 0)
774774
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
775-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_COMPAT")
775+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_QUOTES | ENT_SUBSTITUTE")
776776
ZEND_END_ARG_INFO()
777777

778778
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_html_entity_decode, 0, 1, IS_STRING, 0)
779779
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
780-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_COMPAT")
780+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_QUOTES | ENT_SUBSTITUTE")
781781
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null")
782782
ZEND_END_ARG_INFO()
783783

784784
#define arginfo_htmlentities arginfo_htmlspecialchars
785785

786786
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_html_translation_table, 0, 0, IS_ARRAY, 0)
787787
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, table, IS_LONG, 0, "HTML_SPECIALCHARS")
788-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_COMPAT")
788+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "ENT_QUOTES | ENT_SUBSTITUTE")
789789
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"UTF-8\"")
790790
ZEND_END_ARG_INFO()
791791

ext/standard/html.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t
13161316
static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
13171317
{
13181318
zend_string *str, *hint_charset = NULL;
1319-
zend_long flags = ENT_COMPAT;
1319+
zend_long flags = ENT_QUOTES|ENT_SUBSTITUTE;
13201320
zend_string *replaced;
13211321
zend_bool double_encode = 1;
13221322

@@ -1367,7 +1367,7 @@ PHP_FUNCTION(htmlspecialchars)
13671367
PHP_FUNCTION(htmlspecialchars_decode)
13681368
{
13691369
zend_string *str;
1370-
zend_long quote_style = ENT_COMPAT;
1370+
zend_long quote_style = ENT_QUOTES|ENT_SUBSTITUTE;
13711371
zend_string *replaced;
13721372

13731373
ZEND_PARSE_PARAMETERS_START(1, 2)
@@ -1385,7 +1385,7 @@ PHP_FUNCTION(htmlspecialchars_decode)
13851385
PHP_FUNCTION(html_entity_decode)
13861386
{
13871387
zend_string *str, *hint_charset = NULL;
1388-
zend_long quote_style = ENT_COMPAT;
1388+
zend_long quote_style = ENT_QUOTES|ENT_SUBSTITUTE;
13891389
zend_string *replaced;
13901390

13911391
ZEND_PARSE_PARAMETERS_START(1, 3)
@@ -1468,7 +1468,7 @@ static inline void write_s3row_data(
14681468
PHP_FUNCTION(get_html_translation_table)
14691469
{
14701470
zend_long all = HTML_SPECIALCHARS,
1471-
flags = ENT_COMPAT;
1471+
flags = ENT_QUOTES|ENT_SUBSTITUTE;
14721472
int doctype;
14731473
entity_table_opt entity_table;
14741474
const enc_to_uni *to_uni_table = NULL;

0 commit comments

Comments
 (0)