You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2020/12/30 03:35:30 UTC
[james-project] 18/29: JAMES-1784 AttachmentAccessToken signature
should exclude trailing spaces
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ca72fb192a251ebb683d1c3d7365876cec614683
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Dec 26 11:18:10 2020 +0700
JAMES-1784 AttachmentAccessToken signature should exclude trailing spaces
Encountered in logs:
```
java.lang.IllegalArgumentException: Illegal base64 character 20
[...]
```
ASCII character 20 (HEX) is 'space'.
---
.../org/apache/james/jmap/draft/model/AttachmentAccessToken.java | 2 +-
.../apache/james/jmap/draft/model/AttachmentAccessTokenTest.java | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/AttachmentAccessToken.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/AttachmentAccessToken.java
index f456fe6..3df7dfe 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/AttachmentAccessToken.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/AttachmentAccessToken.java
@@ -86,7 +86,7 @@ public class AttachmentAccessToken implements SignedExpiringToken {
}
public Builder signature(String signature) {
- this.signature = signature;
+ this.signature = signature.trim();
return this;
}
diff --git a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/model/AttachmentAccessTokenTest.java b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/model/AttachmentAccessTokenTest.java
index 2d6b62f..2ce636a 100644
--- a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/model/AttachmentAccessTokenTest.java
+++ b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/model/AttachmentAccessTokenTest.java
@@ -49,6 +49,13 @@ public class AttachmentAccessTokenTest {
}
@Test
+ public void extraSpacesShouldBeIgnored() {
+ AttachmentAccessToken attachmentAccessToken = new AttachmentAccessToken(USERNAME, BLOB_ID, EXPIRATION_DATE, SIGNATURE);
+ assertThat(AttachmentAccessToken.from(attachmentAccessToken.serialize() + " ", BLOB_ID))
+ .isEqualTo(attachmentAccessToken);
+ }
+
+ @Test
public void fromShouldAcceptUsernamesWithUnderscores() {
Username failingUsername = Username.of("bad_separator@usage.screwed");
AttachmentAccessToken attachmentAccessToken = new AttachmentAccessToken(failingUsername.asString(), BLOB_ID, EXPIRATION_DATE, SIGNATURE);
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org