Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
normandy
pleroma
Commits
85b59d07
Commit
85b59d07
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
test: add smoketests for the scrubbing policies
parent
7f0e2914
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/html_test.exs
+80
-0
80 additions, 0 deletions
test/html_test.exs
with
80 additions
and
0 deletions
test/html_test.exs
0 → 100644
+
80
−
0
View file @
85b59d07
defmodule
Pleroma
.
HTMLTest
do
alias
Pleroma
.
HTML
use
Pleroma
.
DataCase
@html_sample
"""
<b>this is in bold</b>
<p>this is a paragraph</p>
this is a linebreak<br />
this is an image: <img src="http://example.com/image.jpg"><br />
<script>alert('hacked')</script>
"""
@html_onerror_sample
"""
<img src="http://example.com/image.jpg" onerror="alert('hacked')">
"""
describe
"StripTags scrubber"
do
test
"works as expected"
do
expected
=
"""
this is in bold
this is a paragraph
this is a linebreak
this is an image:
alert('hacked')
"""
assert
expected
==
HTML
.
strip_tags
(
@html_sample
)
end
test
"does not allow attribute-based XSS"
do
expected
=
"
\n
"
assert
expected
==
HTML
.
strip_tags
(
@html_onerror_sample
)
end
end
describe
"TwitterText scrubber"
do
test
"normalizes HTML as expected"
do
expected
=
"""
this is in bold
<p>this is a paragraph</p>
this is a linebreak<br />
this is an image: <img src="http://example.com/image.jpg" /><br />
alert('hacked')
"""
assert
expected
==
HTML
.
filter_tags
(
@html_sample
,
Pleroma
.
HTML
.
Scrubber
.
TwitterText
)
end
test
"does not allow attribute-based XSS"
do
expected
=
"""
<img src="http://example.com/image.jpg" />
"""
assert
expected
==
HTML
.
filter_tags
(
@html_onerror_sample
,
Pleroma
.
HTML
.
Scrubber
.
TwitterText
)
end
end
describe
"default scrubber"
do
test
"normalizes HTML as expected"
do
expected
=
"""
<b>this is in bold</b>
<p>this is a paragraph</p>
this is a linebreak<br />
this is an image: <img src="http://example.com/image.jpg" /><br />
alert('hacked')
"""
assert
expected
==
HTML
.
filter_tags
(
@html_sample
,
Pleroma
.
HTML
.
Scrubber
.
Default
)
end
test
"does not allow attribute-based XSS"
do
expected
=
"""
<img src="http://example.com/image.jpg" />
"""
assert
expected
==
HTML
.
filter_tags
(
@html_onerror_sample
,
Pleroma
.
HTML
.
Scrubber
.
Default
)
end
end
end
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