Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c3bda6c3
Commit
c3bda6c3
authored
Sep 22, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-allow `name` attribute on user-provided anchor HTML
parent
f9df0e13
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
2 deletions
+10
-2
changelogs/unreleased/rs-allow-name-on-anchors.yml
changelogs/unreleased/rs-allow-name-on-anchors.yml
+5
-0
lib/banzai/filter/sanitization_filter.rb
lib/banzai/filter/sanitization_filter.rb
+2
-1
spec/lib/banzai/filter/sanitization_filter_spec.rb
spec/lib/banzai/filter/sanitization_filter_spec.rb
+3
-1
No files found.
changelogs/unreleased/rs-allow-name-on-anchors.yml
0 → 100644
View file @
c3bda6c3
---
title
:
Re-allow `name` attribute on user-provided anchor HTML
merge_request
:
author
:
type
:
fixed
lib/banzai/filter/sanitization_filter.rb
View file @
c3bda6c3
...
...
@@ -45,8 +45,9 @@ module Banzai
whitelist
[
:elements
].
push
(
'abbr'
)
whitelist
[
:attributes
][
'abbr'
]
=
%w(title)
# Disallow `name` attribute globally
# Disallow `name` attribute globally
, allow on `a`
whitelist
[
:attributes
][
:all
].
delete
(
'name'
)
whitelist
[
:attributes
][
'a'
].
push
(
'name'
)
# Allow any protocol in `a` elements...
whitelist
[
:protocols
].
delete
(
'a'
)
...
...
spec/lib/banzai/filter/sanitization_filter_spec.rb
View file @
c3bda6c3
...
...
@@ -101,16 +101,18 @@ describe Banzai::Filter::SanitizationFilter do
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
it
'disallows the `name` attribute globally'
do
it
'disallows the `name` attribute globally
, allows on `a`
'
do
html
=
<<~
HTML
<img name="getElementById" src="">
<span name="foo" class="bar">Hi</span>
<a name="foo" class="bar">Bye</a>
HTML
doc
=
filter
(
html
)
expect
(
doc
.
at_css
(
'img'
)).
not_to
have_attribute
(
'name'
)
expect
(
doc
.
at_css
(
'span'
)).
not_to
have_attribute
(
'name'
)
expect
(
doc
.
at_css
(
'a'
)).
to
have_attribute
(
'name'
)
end
it
'allows `summary` elements'
do
...
...
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