AO3-4200 Add rel=nofollow to links to reduce SEO usefulness for spammers #3137

Merged
merged 3 commits into from Nov 4, 2017

Conversation

Projects
None yet
3 participants
Contributor

ariana-paris commented Nov 2, 2017

Issue

https://otwarchive.atlassian.net/browse/AO3-4200

Purpose

Adds rel="nofollow" to all tags in sanitised fields to reduce their usefulness as SEO-boosters for spam.

Testing

See JIRA.

@@ -27,6 +27,10 @@ module Config
'th' => ['abbr', 'axis', 'colspan', 'height', 'rowspan', 'scope', 'width'],
'ul' => ['type'],
},
+
+ add_attributes: {
+ 'a' => {'rel' => 'nofollow'}
@houndci-bot

houndci-bot Nov 2, 2017

Space inside { missing.
Space inside } missing.

spec/lib/html_cleaner_spec.rb
end
+
@houndci-bot

houndci-bot Nov 2, 2017

1 trailing blank lines detected.

- end
-
+
+ context "Sanitize tags allowed only in the content field" do
@houndci-bot

houndci-bot Nov 3, 2017

Block has too many lines. [35/25]

+ end
+
+ context "Strip out tags not allowed in text fields other than content" do
+ [:endnotes, :notes, :summary].each do |field|
@houndci-bot

houndci-bot Nov 3, 2017

Use %i or %I for an array of symbols.

- ].each do |value|
- it "should strip script tags: #{value}" do
- result = sanitize_value(:content, value)
+ [:content, :endnotes, :notes, :summary].each do |field|
@houndci-bot

houndci-bot Nov 3, 2017

Block has too many lines. [261/25]
Use %i or %I for an array of symbols.

- it "should strip script tags: #{value}" do
- result = sanitize_value(:content, value)
+ [:content, :endnotes, :notes, :summary].each do |field|
+ context "Sanitize #{field} field" do
@houndci-bot

houndci-bot Nov 3, 2017

Block has too many lines. [259/25]

+
+ ["'';!--\"<XSS>=&{()}",
+ '<XSS STYLE="behavior: url(xss.htc);">'
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

+ "<SCRIPT>alert(/XSS/.source)</SCRIPT>",
+ '</TITLE><SCRIPT>alert("XSS");</SCRIPT>',
+ '<SCRIPT SRC="http://ha.ckers.org/xss.jpg"></SCRIPT>'
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

+ ["\\\";alert('XSS');//",
+ "xss:expr/*blah*/ession(alert('XSS'))",
+ "xss:expression(alert('XSS'))"
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

+ "<IMG SRC=\"jav&#x09;ascript:alert('XSS');\">",
+ "<IMG SRC=\"jav&#x0A;ascript:alert('XSS');\">",
+ "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">",
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

+ '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">',
+ "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">",
+ "<META HTTP-EQUIV=\"Set-Cookie\" Content=\"USERID=&lt;SCRIPT&gt;alert('XSS')&lt;/SCRIPT&gt;\">"
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

+
+ ["<BODY ONLOAD=alert('XSS')>",
+ '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>',
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

+
+ ["<!--#exec cmd=\"/bin/echo '<SCR'\"-->",
+ "<!--#exec cmd=\"/bin/echo 'IPT SRC=http://ha.ckers.org/xss.js></SCRIPT>'\"-->"
+ ].each do |value|
@houndci-bot

houndci-bot Nov 3, 2017

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

@sarken sarken merged commit 423775e into otwcode:master Nov 4, 2017

4 checks passed

Scrutinizer 4 new issues
Details
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound 14 violations found.

@ariana-paris ariana-paris deleted the ariana-paris:AO3-4200-no-follow-links branch Nov 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment