Skip to content

Commit eff487c

Browse files
authored
Use 'ENT_QUOTES|ENT_SUBSTITUTE' for HTML encoding and decoding functions (#361)
1 parent 975e911 commit eff487c

File tree

6 files changed

+89
-11
lines changed

6 files changed

+89
-11
lines changed

language/functions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ array_fill(value: 50, count: 100, start_index: 0);
662662
<?php
663663
htmlspecialchars($string, double_encode: false);
664664
// Same as
665-
htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
665+
htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, 'UTF-8', false);
666666
?>
667667
]]>
668668
</programlisting>

reference/strings/functions/get-html-translation-table.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<methodsynopsis>
1212
<type>array</type><methodname>get_html_translation_table</methodname>
1313
<methodparam choice="opt"><type>int</type><parameter>table</parameter><initializer><constant>HTML_SPECIALCHARS</constant></initializer></methodparam>
14-
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_COMPAT</constant></initializer></methodparam>
14+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant></initializer></methodparam>
1515
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>"UTF-8"</initializer></methodparam>
1616
</methodsynopsis>
1717
<para>
@@ -51,7 +51,7 @@
5151
<para>
5252
A bitmask of one or more of the following flags, which specify which quotes the
5353
table will contain as well as which document type the table is for. The default is
54-
<literal>ENT_COMPAT | ENT_HTML401</literal>.
54+
<literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>.
5555
<table>
5656
<title>Available <parameter>flags</parameter> constants</title>
5757
<tgroup cols="2">
@@ -118,6 +118,28 @@
118118
</para>
119119
</refsect1>
120120

121+
<refsect1 role="changelog">
122+
&reftitle.changelog;
123+
<informaltable>
124+
<tgroup cols="2">
125+
<thead>
126+
<row>
127+
<entry>&Version;</entry>
128+
<entry>&Description;</entry>
129+
</row>
130+
</thead>
131+
<tbody>
132+
<row>
133+
<entry>8.1.0</entry>
134+
<entry>
135+
<parameter>flags</parameter> changed from <constant>ENT_COMPAT</constant> to <constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant>.
136+
</entry>
137+
</row>
138+
</tbody>
139+
</tgroup>
140+
</informaltable>
141+
</refsect1>
142+
121143
<refsect1 role="examples">
122144
&reftitle.examples;
123145
<para>

reference/strings/functions/html-entity-decode.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<methodsynopsis>
1212
<type>string</type><methodname>html_entity_decode</methodname>
1313
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14-
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_COMPAT</constant></initializer></methodparam>
14+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant></initializer></methodparam>
1515
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
1616
</methodsynopsis>
1717
<para>
@@ -46,7 +46,7 @@
4646
<listitem>
4747
<para>
4848
A bitmask of one or more of the following flags, which specify how to handle quotes and
49-
which document type to use. The default is <literal>ENT_COMPAT | ENT_HTML401</literal>.
49+
which document type to use. The default is <literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>.
5050
<table>
5151
<title>Available <parameter>flags</parameter> constants</title>
5252
<tgroup cols="2">
@@ -128,6 +128,12 @@
128128
</row>
129129
</thead>
130130
<tbody>
131+
<row>
132+
<entry>8.1.0</entry>
133+
<entry>
134+
<parameter>flags</parameter> changed from <constant>ENT_COMPAT</constant> to <constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant>.
135+
</entry>
136+
</row>
131137
<row>
132138
<entry>8.0.0</entry>
133139
<entry>

reference/strings/functions/htmlentities.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<methodsynopsis>
1212
<type>string</type><methodname>htmlentities</methodname>
1313
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14-
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_COMPAT</constant></initializer></methodparam>
14+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant></initializer></methodparam>
1515
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
1616
<methodparam choice="opt"><type>bool</type><parameter>double_encode</parameter><initializer>&true;</initializer></methodparam>
1717
</methodsynopsis>
@@ -44,7 +44,7 @@
4444
<para>
4545
A bitmask of one or more of the following flags, which specify how to handle quotes,
4646
invalid code unit sequences and the used document type. The default is
47-
<literal>ENT_COMPAT | ENT_HTML401</literal>.
47+
<literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>.
4848
<table>
4949
<title>Available <parameter>flags</parameter> constants</title>
5050
<tgroup cols="2">
@@ -166,6 +166,12 @@
166166
</row>
167167
</thead>
168168
<tbody>
169+
<row>
170+
<entry>8.1.0</entry>
171+
<entry>
172+
<parameter>flags</parameter> changed from <constant>ENT_COMPAT</constant> to <constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant>.
173+
</entry>
174+
</row>
169175
<row>
170176
<entry>8.0.0</entry>
171177
<entry>

reference/strings/functions/htmlspecialchars-decode.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<methodsynopsis>
1313
<type>string</type><methodname>htmlspecialchars_decode</methodname>
1414
<methodparam><type>string</type><parameter>string</parameter></methodparam>
15-
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_COMPAT</constant></initializer></methodparam>
15+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant></initializer></methodparam>
1616
</methodsynopsis>
1717

1818
<para>
@@ -44,7 +44,7 @@
4444
<listitem>
4545
<para>
4646
A bitmask of one or more of the following flags, which specify how to handle quotes and
47-
which document type to use. The default is <literal>ENT_COMPAT | ENT_HTML401</literal>.
47+
which document type to use. The default is <literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>.
4848
<table>
4949
<title>Available <parameter>flags</parameter> constants</title>
5050
<tgroup cols="2">
@@ -108,6 +108,28 @@
108108
</para>
109109
</refsect1>
110110

111+
<refsect1 role="changelog">
112+
&reftitle.changelog;
113+
<informaltable>
114+
<tgroup cols="2">
115+
<thead>
116+
<row>
117+
<entry>&Version;</entry>
118+
<entry>&Description;</entry>
119+
</row>
120+
</thead>
121+
<tbody>
122+
<row>
123+
<entry>8.1.0</entry>
124+
<entry>
125+
<parameter>flags</parameter> changed from <constant>ENT_COMPAT</constant> to <constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant>.
126+
</entry>
127+
</row>
128+
</tbody>
129+
</tgroup>
130+
</informaltable>
131+
</refsect1>
132+
111133
<refsect1 role="examples">
112134
&reftitle.examples;
113135
<para>

reference/strings/functions/htmlspecialchars.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<methodsynopsis>
1212
<type>string</type><methodname>htmlspecialchars</methodname>
1313
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14-
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_COMPAT</constant></initializer></methodparam>
14+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant></initializer></methodparam>
1515
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
1616
<methodparam choice="opt"><type>bool</type><parameter>double_encode</parameter><initializer>&true;</initializer></methodparam>
1717
</methodsynopsis>
@@ -93,7 +93,7 @@
9393
<para>
9494
A bitmask of one or more of the following flags, which specify how to handle quotes,
9595
invalid code unit sequences and the used document type. The default is
96-
<literal>ENT_COMPAT | ENT_HTML401</literal>.
96+
<literal>ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401</literal>.
9797
<table>
9898
<title>Available <parameter>flags</parameter> constants</title>
9999
<tgroup cols="2">
@@ -214,6 +214,28 @@
214214
</para>
215215
</refsect1>
216216

217+
<refsect1 role="changelog">
218+
&reftitle.changelog;
219+
<informaltable>
220+
<tgroup cols="2">
221+
<thead>
222+
<row>
223+
<entry>&Version;</entry>
224+
<entry>&Description;</entry>
225+
</row>
226+
</thead>
227+
<tbody>
228+
<row>
229+
<entry>8.1.0</entry>
230+
<entry>
231+
<parameter>flags</parameter> changed from <constant>ENT_COMPAT</constant> to <constant>ENT_QUOTES</constant> | <constant>ENT_SUBSTITUTE</constant>.
232+
</entry>
233+
</row>
234+
</tbody>
235+
</tgroup>
236+
</informaltable>
237+
</refsect1>
238+
217239
<refsect1 role="examples">
218240
&reftitle.examples;
219241
<para>

0 commit comments

Comments
 (0)