Merge pull request #32 from jwtk/base64padding

#31: fixed base64 url padding bug
This commit is contained in:
Les Hazlewood 2015-06-26 11:50:56 -07:00
commit 9689900f6f
1 changed files with 8 additions and 1 deletions

View File

@ -82,7 +82,14 @@ public class Base64UrlCodec extends AbstractTextCodec {
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);