From c9c5a8c2632f603a4e3d099f10ecd59096c900df Mon Sep 17 00:00:00 2001 From: Khai Do Date: Wed, 20 Jul 2016 14:33:19 -0700 Subject: [PATCH] Add rel=nofollow parameter to links in comments Spamming a Gerrit site is a real issue: https://groups.google.com/d/msg/repo-discuss/Q9x23wnOQXg/aAtXSGqNAwAJ Google recommends adding rel="nofollow"[1] to links on comments: "This can discourage spammers from targeting your site, and will help keep your site from inadvertently passing PageRank to bad neighborhoods on the web". [1] https://support.google.com/webmasters/answer/96569?hl=en Change-Id: I17c2c6f009d31db1c91b39d37227edebf923373a --- .../gwtexpui/safehtml/client/SafeHtml.java | 2 +- .../safehtml/client/SafeHtml_LinkifyTest.java | 27 ++++++++++++------- .../safehtml/client/SafeHtml_WikifyTest.java | 15 +++++++---- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java index b8f0800373..10c2a784ac 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java @@ -138,7 +138,7 @@ public abstract class SafeHtml "(?:[(]" + part + "*" + "[)])*" + part + "*" + ")", - "$1"); + "$1"); } /** diff --git a/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java b/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java index bf96d770fd..8fe743e7ed 100644 --- a/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java +++ b/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java @@ -25,7 +25,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A http://go.here/ B"); + "A http://go.here/ B"); } @Test @@ -34,7 +35,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A https://go.here/ B"); + "A https://go.here/ B"); } @Test @@ -43,7 +45,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A (http://go.here/) B"); + "A (http://go.here/) B"); } @Test @@ -52,7 +55,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A http://go.here/#m() B"); + "A http://go.here/#m() B"); } @Test @@ -61,7 +65,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A <http://go.here/> B"); + "A <http://go.here/> B"); } @Test @@ -70,7 +75,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A http://go.here/foo B"); + "A http://go.here/foo B"); } @Test @@ -79,7 +85,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A http://go.here/. B"); + "A http://go.here/. B"); } @Test @@ -88,7 +95,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A http://go.here/, B"); + "A http://go.here/, B"); } @Test @@ -97,7 +105,8 @@ public class SafeHtml_LinkifyTest { final SafeHtml n = o.linkify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "A http://go.here/.. B"); + "A http://go.here/.. B"); } private static SafeHtml html(String text) { diff --git a/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyTest.java b/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyTest.java index 41d6f37374..8f6ff8d5d8 100644 --- a/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyTest.java +++ b/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyTest.java @@ -65,7 +65,8 @@ public class SafeHtml_WikifyTest { final SafeHtml n = o.wikify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "

A http://go.here/ B

"); + "

A http://go.here/ B

"); } @Test @@ -74,7 +75,8 @@ public class SafeHtml_WikifyTest { final SafeHtml n = o.wikify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "

A https://go.here/ B

"); + "

A https://go.here/ B

"); } @Test @@ -83,7 +85,8 @@ public class SafeHtml_WikifyTest { final SafeHtml n = o.wikify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "

A (http://go.here/) B

"); + "

A (http://go.here/) B

"); } @Test @@ -92,7 +95,8 @@ public class SafeHtml_WikifyTest { final SafeHtml n = o.wikify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "

A http://go.here/#m() B

"); + "

A http://go.here/#m() B

"); } @Test @@ -101,7 +105,8 @@ public class SafeHtml_WikifyTest { final SafeHtml n = o.wikify(); assertThat(o).isNotSameAs(n); assertThat(n.asString()).isEqualTo( - "

A <http://go.here/> B

"); + "

A <http://go.here/> B

"); } private static SafeHtml html(String text) {