From ceb76887ba51beae709334542a819e66531d1ec4 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Apr 2023 07:27:18 +0000 Subject: [PATCH 1/5] updating poms for branch'release-3.0.25' with non-snapshot versions --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 934ed008..69c0d18a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 3.0.25-SNAPSHOT + 3.0.25 redisques A highly scalable redis-persistent queuing system for vertx From 6ffd63e466587eff1c61b3b9c324e85e3252467b Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Apr 2023 07:27:18 +0000 Subject: [PATCH 2/5] updating poms for 3.0.26-SNAPSHOT development --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 934ed008..5eb38fb2 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 3.0.25-SNAPSHOT + 3.0.26-SNAPSHOT redisques A highly scalable redis-persistent queuing system for vertx From 345117972f6591f809dfc83f3297042feddc3d74 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Apr 2023 07:29:53 +0000 Subject: [PATCH 3/5] updating develop poms to master versions to avoid merge conflicts --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5eb38fb2..69c0d18a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 3.0.26-SNAPSHOT + 3.0.25 redisques A highly scalable redis-persistent queuing system for vertx From a8d51a2e3e8d7c3123df20f9d707956d99f69d33 Mon Sep 17 00:00:00 2001 From: runner Date: Wed, 26 Apr 2023 07:29:53 +0000 Subject: [PATCH 4/5] Updating develop poms back to pre merge state --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 69c0d18a..5eb38fb2 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 3.0.25 + 3.0.26-SNAPSHOT redisques A highly scalable redis-persistent queuing system for vertx From 4e03b5eff191b8451500885726d172b917a9d7c9 Mon Sep 17 00:00:00 2001 From: Xin Date: Thu, 11 May 2023 10:13:13 +0700 Subject: [PATCH 5/5] use apache base64 decoder --- .../redisques/util/HttpServerRequestUtil.java | 6 ++-- .../util/HttpServerRequestUtilTest.java | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/swisspush/redisques/util/HttpServerRequestUtil.java b/src/main/java/org/swisspush/redisques/util/HttpServerRequestUtil.java index 123bf701..1fab3142 100644 --- a/src/main/java/org/swisspush/redisques/util/HttpServerRequestUtil.java +++ b/src/main/java/org/swisspush/redisques/util/HttpServerRequestUtil.java @@ -4,6 +4,7 @@ import io.vertx.core.json.DecodeException; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; +import org.apache.commons.codec.binary.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,6 +28,7 @@ public class HttpServerRequestUtil { private static final String CONTENT_LENGTH = "Content-Length"; private static final String CONTENT_TYPE = "content-type"; private static final String APPLICATION_JSON = "application/json"; + private static final Base64 apacheDecoder = new Base64(); /** * Evaluates whether the provided request contains the provided url parameter and the value is either an empty @@ -134,9 +136,9 @@ public static String decode(String encoded) { String value = header.getString(1); if (key.equalsIgnoreCase(CONTENT_TYPE) && (value.contains("text/") || value.contains(APPLICATION_JSON))) { try { - object.put(PAYLOAD_OBJECT, new JsonObject(new String(object.getBinary(PAYLOAD), StandardCharsets.UTF_8))); + object.put(PAYLOAD_OBJECT, new JsonObject(new String(apacheDecoder.decode(object.getString(PAYLOAD)), StandardCharsets.UTF_8))); } catch (DecodeException e) { - object.put(PAYLOAD_STRING, new String(object.getBinary(PAYLOAD), StandardCharsets.UTF_8)); + object.put(PAYLOAD_STRING, new String(apacheDecoder.decode(object.getString(PAYLOAD)), StandardCharsets.UTF_8)); } object.remove(PAYLOAD); break; diff --git a/src/test/java/org/swisspush/redisques/util/HttpServerRequestUtilTest.java b/src/test/java/org/swisspush/redisques/util/HttpServerRequestUtilTest.java index acd07be7..4551df8e 100644 --- a/src/test/java/org/swisspush/redisques/util/HttpServerRequestUtilTest.java +++ b/src/test/java/org/swisspush/redisques/util/HttpServerRequestUtilTest.java @@ -81,4 +81,39 @@ public void testExtractJsonArrayFromBody(TestContext context){ context.assertTrue(result.isErr()); context.assertEquals("no array called 'locks' found", result.getErr()); } + + @Test + public void testBase64Decoder(TestContext context){ + String testDataUrlEncoded = "{\n" + + " \"headers\": [\n" + + " [\n" + + " \"Content-Type\",\n" + + " \"application/json\"\n" + + " ],\n" + + " [\n" + + " \"Accept-Charset\",\n" + + " \"utf-8, iso-8859-1, utf-16, *;q=0.7\"\n" + + " ]\n" + + " ],\n" + + " \"queueTimestamp\": 1477983671291,\n" + + " \"payload\": \"5rWL6K-V\"\n" + + "}"; + String testDataEncoded = "{\n" + + " \"headers\": [\n" + + " [\n" + + " \"Content-Type\",\n" + + " \"application/json\"\n" + + " ],\n" + + " [\n" + + " \"Accept-Charset\",\n" + + " \"utf-8, iso-8859-1, utf-16, *;q=0.7\"\n" + + " ]\n" + + " ],\n" + + " \"queueTimestamp\": 1477983671291,\n" + + " \"payload\": \"5rWL6K+V\"\n" + + "}"; + String decodedUrlPayload = HttpServerRequestUtil.decode(testDataUrlEncoded); + String decodedPayload = HttpServerRequestUtil.decode(testDataEncoded); + context.assertEquals(decodedUrlPayload, decodedPayload); + } }