Skip to content

Commit

Permalink
Merge pull request #32 from jwtk/base64padding
Browse files Browse the repository at this point in the history
#31: fixed base64 url padding bug
  • Loading branch information
lhazlewood committed Jun 26, 2015
2 parents dac9ee6 + 4d2080b commit 9689900
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/io/jsonwebtoken/impl/Base64UrlCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ protected char[] ensurePadding(char[] chars) {

char[] result = chars; //assume argument in case no padding is necessary

int paddingCount = chars.length % 4;
int paddingCount = 0;

//fix for https://github.com/jwtk/jjwt/issues/31
int remainder = chars.length % 4;
if (remainder == 2 || remainder == 3) {
paddingCount = 4 - remainder;
}

if (paddingCount > 0) {
result = new char[chars.length + paddingCount];
System.arraycopy(chars, 0, result, 0, chars.length);
Expand Down

0 comments on commit 9689900

Please sign in to comment.