Skip to content

Commit

Permalink
Fixed #335
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 26, 2016
1 parent 7756869 commit 7c3e56b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main/java/com/fasterxml/jackson/core/Base64Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public byte[] decode(String input) throws IllegalArgumentException
* assumption is that caller will ensure it is given in proper state, and
* used as appropriate afterwards.
*
* @since 2.2.3
* @since 2.3
*
* @throws IllegalArgumentException if input is not valid base64 encoded data
*/
Expand All @@ -458,16 +458,12 @@ public void decode(String str, ByteArrayBuilder builder) throws IllegalArgumentE
int ptr = 0;
int len = str.length();

main_loop:
while (ptr < len) {
// first, we'll skip preceding white space, if any
char ch;
do {
ch = str.charAt(ptr++);
if (ptr >= len) {
break main_loop;
}
} while (ch <= INT_SPACE);
} while ((ptr < len) && (ch <= INT_SPACE));
int bits = decodeBase64Char(ch);
if (bits < 0) {
_reportInvalidBase64(ch, 0, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,14 @@ public void testErrors() throws Exception
} catch (IllegalArgumentException iae) {
verifyException(iae, "length must be exactly");
}

// also, for [jackson-core#335]
final String BASE64_HELLO = "aGVsbG8=!";
try {
Base64Variants.MIME.decode(BASE64_HELLO);
fail("Should not pass");
} catch (IllegalArgumentException iae) {
verifyException(iae, "Illegal character");
}
}
}

0 comments on commit 7c3e56b

Please sign in to comment.