Package com.mimecast.robin.util
Class UuencodeDecoder
java.lang.Object
com.mimecast.robin.util.UuencodeDecoder
Decoder for the classic Unix uuencode format.
Handles legacy attachments pasted as plain text, starting with a begin MODE FILENAME
line and ending with an end line - predating MIME multipart attachments, but still
occasionally seen, and sometimes used deliberately to slip content past scanners that no
longer recognise the format.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of a successful uuencode decode. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<UuencodeDecoder.Result> decode(byte[] content) Decodes uuencoded content.private static voiddecodeLine(String line, ByteArrayOutputStream out) Decodes a single uuencoded line (a length character followed by groups of 4 encoded characters, each group representing up to 3 decoded bytes) and appends its declared number of bytes to the output.static booleanlooksLikeUuencode(byte[] content) Checks whether the given content starts with a uuencode "begin" preamble.private static String
-
Field Details
-
BEGIN_LINE
-
-
Constructor Details
-
UuencodeDecoder
private UuencodeDecoder()
-
-
Method Details
-
looksLikeUuencode
public static boolean looksLikeUuencode(byte[] content) Checks whether the given content starts with a uuencode "begin" preamble.- Parameters:
content- Raw content bytes.- Returns:
- true if the content looks like uuencoded data.
-
decode
Decodes uuencoded content.- Parameters:
content- Raw content bytes, expected to contain a uuencode "begin" preamble.- Returns:
- Decoded result, or empty if the content isn't valid uuencode.
-
decodeLine
Decodes a single uuencoded line (a length character followed by groups of 4 encoded characters, each group representing up to 3 decoded bytes) and appends its declared number of bytes to the output.- Parameters:
line- Trimmed uuencode data line.out- Output buffer to append decoded bytes to.
-
stripTrailingWhitespace
-