Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443488
Commits
c90e1672
Commit
c90e1672
authored
15 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#359276
by Freso, Heine, lyricnz: avoid double encoding/decoding of HTML entities.
parent
bea411e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/common.inc
+2
-2
2 additions, 2 deletions
includes/common.inc
modules/filter/filter.test
+9
-0
9 additions, 0 deletions
modules/filter/filter.test
with
11 additions
and
2 deletions
includes/common.inc
+
2
−
2
View file @
c90e1672
...
@@ -1359,12 +1359,12 @@ function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite',
...
@@ -1359,12 +1359,12 @@ function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite',
// Defuse all HTML entities
// Defuse all HTML entities
$string
=
str_replace
(
'&'
,
'&'
,
$string
);
$string
=
str_replace
(
'&'
,
'&'
,
$string
);
// Change back only well-formed entities in our whitelist
// Change back only well-formed entities in our whitelist
// Named entities
$string
=
preg_replace
(
'/&([A-Za-z][A-Za-z0-9]*;)/'
,
'&\1'
,
$string
);
// Decimal numeric entities
// Decimal numeric entities
$string
=
preg_replace
(
'/&#([0-9]+;)/'
,
'&#\1'
,
$string
);
$string
=
preg_replace
(
'/&#([0-9]+;)/'
,
'&#\1'
,
$string
);
// Hexadecimal numeric entities
// Hexadecimal numeric entities
$string
=
preg_replace
(
'/&#[Xx]0*((?:[0-9A-Fa-f]{2})+;)/'
,
'&#x\1'
,
$string
);
$string
=
preg_replace
(
'/&#[Xx]0*((?:[0-9A-Fa-f]{2})+;)/'
,
'&#x\1'
,
$string
);
// Named entities
$string
=
preg_replace
(
'/&([A-Za-z][A-Za-z0-9]*;)/'
,
'&\1'
,
$string
);
return
preg_replace_callback
(
'%
return
preg_replace_callback
(
'%
(
(
...
...
This diff is collapsed.
Click to expand it.
modules/filter/filter.test
+
9
−
0
View file @
c90e1672
...
@@ -399,6 +399,15 @@ class FilterTestCase extends DrupalWebTestCase {
...
@@ -399,6 +399,15 @@ class FilterTestCase extends DrupalWebTestCase {
$f
=
filter_xss
(
"
\xc0
aaa"
);
$f
=
filter_xss
(
"
\xc0
aaa"
);
$this
->
assertEqual
(
$f
,
''
,
t
(
'HTML filter -- overlong UTF-8 sequences.'
));
$this
->
assertEqual
(
$f
,
''
,
t
(
'HTML filter -- overlong UTF-8 sequences.'
));
$f
=
filter_xss
(
"Who's Online"
);
$this
->
assertNormalized
(
$f
,
"who's online"
,
t
(
'HTML filter -- html entity number'
));
$f
=
filter_xss
(
"Who's Online"
);
$this
->
assertNormalized
(
$f
,
"who's online"
,
t
(
'HTML filter -- encoded html entity number'
));
$f
=
filter_xss
(
"Who' Online"
);
$this
->
assertNormalized
(
$f
,
"who' online"
,
t
(
'HTML filter -- double encoded html entity number'
));
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment