diff --git a/pom.xml b/pom.xml
index 10d6aa03..d35ef5ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
1.3.29
4.2.2
4.2.1
- 1.5.0
+ 1.18.0
@@ -249,7 +249,7 @@
org.projectlombok
lombok
- 1.18.6
+ 1.18.22
provided
@@ -366,22 +366,22 @@
commons-io
commons-io
- 2.4
+ 2.11.0
org.apache.commons
commons-collections4
- 4.1
+ 4.4
commons-codec
commons-codec
- 1.10
+ 1.15
org.apache.commons
commons-math3
- 3.5
+ 3.6.1
org.apache.commons
@@ -426,27 +426,27 @@
org.jdom
jdom2
- 2.0.6
+ 2.0.6.1
org.ahocorasick
ahocorasick
- 0.4.0
+ 0.6.3
org.jsoup
jsoup
- 1.8.3
+ 1.14.3
com.ibm.icu
icu4j
- 55.1
+ 70.1
net.sourceforge.cssparser
cssparser
- 0.9.16
+ 0.9.29
@@ -464,12 +464,12 @@
com.h2database
h2
- 1.4.197
+ 2.0.204
mysql
mysql-connector-java
- 5.1.42
+ 8.0.27
org.postgresql
@@ -485,13 +485,13 @@
junit
junit
- 4.12
+ 4.13.2
test
org.mockito
mockito-core
- 2.0.11-beta
+ 2.28.2
test
diff --git a/src/main/java/com/commafeed/backend/feed/FeedUtils.java b/src/main/java/com/commafeed/backend/feed/FeedUtils.java
index da0feba9..5916b52c 100644
--- a/src/main/java/com/commafeed/backend/feed/FeedUtils.java
+++ b/src/main/java/com/commafeed/backend/feed/FeedUtils.java
@@ -28,7 +28,7 @@ import org.jsoup.nodes.Document.OutputSettings;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Entities.EscapeMode;
import org.jsoup.safety.Cleaner;
-import org.jsoup.safety.Whitelist;
+import org.jsoup.safety.Safelist;
import org.jsoup.select.Elements;
import org.w3c.css.sac.InputSource;
import org.w3c.dom.css.CSSStyleDeclaration;
@@ -57,7 +57,7 @@ public class FeedUtils {
private static final List ALLOWED_IMG_CSS_RULES = Arrays.asList("display", "width", "height");
private static final char[] FORBIDDEN_CSS_RULE_CHARACTERS = new char[] { '(', ')' };
- private static final Whitelist WHITELIST = buildWhiteList();
+ private static final Safelist WHITELIST = buildWhiteList();
public static String truncate(String string, int length) {
if (string != null) {
@@ -66,8 +66,8 @@ public class FeedUtils {
return string;
}
- private static synchronized Whitelist buildWhiteList() {
- Whitelist whitelist = new Whitelist();
+ private static synchronized Safelist buildWhiteList() {
+ Safelist whitelist = new Safelist();
whitelist.addTags("a", "b", "blockquote", "br", "caption", "cite", "code", "col", "colgroup", "dd", "div", "dl", "dt", "em", "h1",
"h2", "h3", "h4", "h5", "h6", "i", "iframe", "img", "li", "ol", "p", "pre", "q", "small", "strike", "strong", "sub", "sup",
"table", "tbody", "td", "tfoot", "th", "thead", "tr", "u", "ul");
@@ -504,14 +504,15 @@ public class FeedUtils {
StringBuilder message = new StringBuilder();
for (char c : msg.toCharArray()) {
- if (c >= 'a' && c <= 'm')
+ if (c >= 'a' && c <= 'm') {
c += 13;
- else if (c >= 'n' && c <= 'z')
+ } else if (c >= 'n' && c <= 'z') {
c -= 13;
- else if (c >= 'A' && c <= 'M')
+ } else if (c >= 'A' && c <= 'M') {
c += 13;
- else if (c >= 'N' && c <= 'Z')
+ } else if (c >= 'N' && c <= 'Z') {
c -= 13;
+ }
message.append(c);
}
diff --git a/src/test/java/com/commafeed/backend/service/PubSubServiceTest.java b/src/test/java/com/commafeed/backend/service/PubSubServiceTest.java
index 7ea4707c..a3c7980d 100644
--- a/src/test/java/com/commafeed/backend/service/PubSubServiceTest.java
+++ b/src/test/java/com/commafeed/backend/service/PubSubServiceTest.java
@@ -1,8 +1,14 @@
package com.commafeed.backend.service;
-import com.commafeed.CommaFeedConfiguration;
-import com.commafeed.backend.feed.FeedQueues;
-import com.commafeed.backend.model.Feed;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+import static org.mockserver.model.HttpRequest.request;
+import static org.mockserver.model.HttpResponse.response;
+
import org.apache.http.HttpHeaders;
import org.junit.Before;
import org.junit.Rule;
@@ -10,95 +16,88 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.mockserver.client.MockServerClient;
import org.mockserver.junit.MockServerRule;
import org.mockserver.model.MediaType;
-import static org.mockito.Mockito.*;
-import static org.mockserver.model.HttpRequest.request;
-import static org.mockserver.model.HttpResponse.response;
+import com.commafeed.CommaFeedConfiguration;
+import com.commafeed.backend.feed.FeedQueues;
+import com.commafeed.backend.model.Feed;
@RunWith(MockitoJUnitRunner.class)
public class PubSubServiceTest {
- PubSubService underTest;
+ PubSubService underTest;
- @Rule
- public MockServerRule mockServerRule = new MockServerRule(this, 22441);
- public MockServerClient mockServerClient;
+ @Rule
+ public MockServerRule mockServerRule = new MockServerRule(this, 22441);
+ public MockServerClient mockServerClient;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- CommaFeedConfiguration config;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ CommaFeedConfiguration config;
- @Mock
- FeedQueues queues;
+ @Mock
+ FeedQueues queues;
- @Mock
- Feed feed;
+ @Mock
+ Feed feed;
+ @Before
+ public void init() {
+ underTest = new PubSubService(config, queues);
- @Before
- public void init() {
- underTest = new PubSubService(config, queues);
+ // setup feed
+ feed = mock(Feed.class);
+ when(feed.getPushHub()).thenReturn("http://localhost:22441/hub");
+ when(feed.getPushTopic()).thenReturn("foo");
- // setup feed
- feed = mock(Feed.class);
- when(feed.getPushHub()).thenReturn("http://localhost:22441/hub");
- when(feed.getPushTopic()).thenReturn("foo");
+ // setup config
+ when(config.getApplicationSettings().getPublicUrl()).thenReturn("http://localhost:22441/hub");
+ }
- // setup config
- when(config.getApplicationSettings().getPublicUrl()).thenReturn("http://localhost:22441/hub");
- }
+ @Test
+ public void subscribe_200() {
+ // Arrange
+ mockServerClient.when(request().withMethod("POST")).respond(response().withStatusCode(200));
- @Test
- public void subscribe_200() {
- // Arrange
- mockServerClient
- .when(request().withMethod("POST"))
- .respond(response().withStatusCode(200));
+ // Act
+ underTest.subscribe(feed);
- // Act
- underTest.subscribe(feed);
+ // Assert
+ mockServerClient.verify(request().withContentType(MediaType.APPLICATION_FORM_URLENCODED)
+ .withHeader(HttpHeaders.USER_AGENT, "CommaFeed")
+ .withMethod("POST")
+ .withPath("/hub"));
+ verify(feed, never()).setPushTopic(anyString());
+ verifyZeroInteractions(queues);
+ }
- // Assert
- mockServerClient.verify(request()
- .withContentType(MediaType.APPLICATION_FORM_URLENCODED)
- .withHeader(HttpHeaders.USER_AGENT, "CommaFeed")
- .withMethod("POST")
- .withPath("/hub"));
- verify(feed, never()).setPushTopic(anyString());
- verifyZeroInteractions(queues);
- }
+ @Test
+ public void subscribe_400_withPushpressError() {
+ // Arrange
+ mockServerClient.when(request().withMethod("POST"))
+ .respond(response().withStatusCode(400).withBody(" is value is not allowed. You may only subscribe to"));
- @Test
- public void subscribe_400_withPushpressError() {
- // Arrange
- mockServerClient
- .when(request().withMethod("POST"))
- .respond(response().withStatusCode(400).withBody(" is value is not allowed. You may only subscribe to"));
+ // Act
+ underTest.subscribe(feed);
- // Act
- underTest.subscribe(feed);
+ // Assert
+ verify(feed).setPushTopic(anyString());
+ verify(queues).giveBack(feed);
+ }
- // Assert
- verify(feed).setPushTopic(anyString());
- verify(queues).giveBack(feed);
- }
+ @Test
+ public void subscribe_400_withoutPushpressError() {
+ // Arrange
+ mockServerClient.when(request().withMethod("POST")).respond(response().withStatusCode(400));
- @Test
- public void subscribe_400_withoutPushpressError() {
- // Arrange
- mockServerClient
- .when(request().withMethod("POST"))
- .respond(response().withStatusCode(400));
+ // Act
+ underTest.subscribe(feed);
- // Act
- underTest.subscribe(feed);
-
- // Assert
- verify(feed, never()).setPushTopic(anyString());
- verifyZeroInteractions(queues);
- }
+ // Assert
+ verify(feed, never()).setPushTopic(anyString());
+ verifyZeroInteractions(queues);
+ }
}
\ No newline at end of file