Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
00360b9d
Commit
00360b9d
authored
Aug 19, 2015
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1211866
by stefan.r, joelpittet, tsphethean: Enable ENT_SUBSTITUTE flag in Html::escape
parent
7b91c7fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
core/lib/Drupal/Component/Utility/Html.php
core/lib/Drupal/Component/Utility/Html.php
+3
-2
core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
+1
-0
core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
+9
-9
core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
.../tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
+4
-4
No files found.
core/lib/Drupal/Component/Utility/Html.php
View file @
00360b9d
...
...
@@ -366,7 +366,8 @@ public static function decodeEntities($text) {
* - < (less than) becomes <
* - > (greater than) becomes >
* Special characters that have already been escaped will be double-escaped
* (for example, "<" becomes "&lt;").
* (for example, "<" becomes "&lt;"), and invalid UTF-8 encoding
* will be converted to the Unicode replacement character ("�").
*
* This method is not the opposite of Html::decodeEntities(). For example,
* this method will not encode "é" to "é", whereas
...
...
@@ -385,7 +386,7 @@ public static function decodeEntities($text) {
* @ingroup sanitization
*/
public
static
function
escape
(
$text
)
{
return
htmlspecialchars
(
$text
,
ENT_QUOTES
,
'UTF-8'
);
return
htmlspecialchars
(
$text
,
ENT_QUOTES
|
ENT_SUBSTITUTE
,
'UTF-8'
);
}
}
core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
View file @
00360b9d
...
...
@@ -288,6 +288,7 @@ public function providerEscape() {
array
(
'→'
,
'→'
),
array
(
'➼'
,
'➼'
),
array
(
'€'
,
'€'
),
array
(
'Drup�al'
,
"Drup
\x80
al"
),
);
}
...
...
core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
View file @
00360b9d
...
...
@@ -46,11 +46,11 @@ public function testSet($text, $message) {
* @see testSet()
*/
public
function
providerSet
()
{
// Checks that invalid multi-byte sequences are
reject
ed.
$tests
[]
=
array
(
"Foo
\xC0
barbaz"
,
'
'
,
'SafeMarkup::checkPlain() rejects i
nvalid sequence "Foo\xC0barbaz"'
,
TRUE
);
$tests
[]
=
array
(
"Fooÿñ"
,
'SafeMarkup::set()
accepts
valid sequence "Fooÿñ"'
);
$tests
[]
=
array
(
new
TextWrapper
(
"Fooÿñ"
),
'SafeMarkup::set()
accepts
valid sequence "Fooÿñ" in an object implementing __toString()'
);
$tests
[]
=
array
(
"<div>"
,
'SafeMarkup::set()
accepts
HTML'
);
// Checks that invalid multi-byte sequences are
escap
ed.
$tests
[]
=
array
(
"Foo
\xC0
barbaz"
,
'
Foo�barbaz'
,
'I
nvalid sequence "Foo\xC0barbaz"
is escaped
'
,
TRUE
);
$tests
[]
=
array
(
"Fooÿñ"
,
'SafeMarkup::set()
does not escape
valid sequence "Fooÿñ"'
);
$tests
[]
=
array
(
new
TextWrapper
(
"Fooÿñ"
),
'SafeMarkup::set()
does not escape
valid sequence "Fooÿñ" in an object implementing __toString()'
);
$tests
[]
=
array
(
"<div>"
,
'SafeMarkup::set()
does not escape
HTML'
);
return
$tests
;
}
...
...
@@ -141,10 +141,10 @@ function testCheckPlain($text, $expected, $message, $ignorewarnings = FALSE) {
* @see testCheckPlain()
*/
function
providerCheckPlain
()
{
// Checks that invalid multi-byte sequences are
reject
ed.
$tests
[]
=
array
(
"Foo
\xC0
barbaz"
,
''
,
'SafeMarkup::checkPlain()
reject
s invalid sequence "Foo\xC0barbaz"'
,
TRUE
);
$tests
[]
=
array
(
"
\xc2\"
"
,
''
,
'SafeMarkup::checkPlain()
reject
s invalid sequence "\xc2\""'
,
TRUE
);
$tests
[]
=
array
(
"Fooÿñ"
,
"Fooÿñ"
,
'SafeMarkup::checkPlain()
accepts
valid sequence "Fooÿñ"'
);
// Checks that invalid multi-byte sequences are
escap
ed.
$tests
[]
=
array
(
"Foo
\xC0
barbaz"
,
'
Foo�barbaz
'
,
'SafeMarkup::checkPlain()
escape
s invalid sequence "Foo\xC0barbaz"'
,
TRUE
);
$tests
[]
=
array
(
"
\xc2\"
"
,
'
�"
'
,
'SafeMarkup::checkPlain()
escape
s invalid sequence "\xc2\""'
,
TRUE
);
$tests
[]
=
array
(
"Fooÿñ"
,
"Fooÿñ"
,
'SafeMarkup::checkPlain()
does not escape
valid sequence "Fooÿñ"'
);
// Checks that special characters are escaped.
$tests
[]
=
array
(
"<script>"
,
'<script>'
,
'SafeMarkup::checkPlain() escapes <script>'
);
...
...
core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
View file @
00360b9d
...
...
@@ -182,10 +182,10 @@ public function testBuildRow($input, $expected, $message, $ignorewarnings = FALS
*/
public
function
providerTestBuildRow
()
{
$tests
=
array
();
// Checks that invalid multi-byte sequences are
reject
ed.
$tests
[]
=
array
(
"Foo
\xC0
barbaz"
,
''
,
'EntityTestListBuilder::buildRow()
reject
s invalid sequence "Foo\xC0barbaz"'
,
TRUE
);
$tests
[]
=
array
(
"
\xc2\"
"
,
''
,
'EntityTestListBuilder::buildRow
() reject
s invalid sequence "\xc2\""'
,
TRUE
);
$tests
[]
=
array
(
"Fooÿñ"
,
"Fooÿñ"
,
'EntityTestListBuilder::buildR
ow() accepts
valid sequence "Fooÿñ"'
);
// Checks that invalid multi-byte sequences are
escap
ed.
$tests
[]
=
array
(
"Foo
\xC0
barbaz"
,
'
Foo�barbaz
'
,
'EntityTestListBuilder::buildRow()
escape
s invalid sequence "Foo\xC0barbaz"'
,
TRUE
);
$tests
[]
=
array
(
"
\xc2\"
"
,
'
�"
'
,
'EntityTestListBuilder::buildRow
escape
s invalid sequence "\xc2\""'
,
TRUE
);
$tests
[]
=
array
(
"Fooÿñ"
,
"Fooÿñ"
,
'EntityTestListBuilder::buildR
does not escape
valid sequence "Fooÿñ"'
);
// Checks that special characters are escaped.
$tests
[]
=
array
(
"<script>"
,
'<script>'
,
'EntityTestListBuilder::buildRow() escapes <script>'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment