Uue, MIME, etc

Matts on 2002-11-06T15:14:56

Has anyone written, or does anyone know of, some perl that will heuristically detect whether a line in an email (or section of an email) is base64 encoded, or uuencoded?


No, but I know a good place to ask

VSarkiss on 2002-11-06T16:26:23

Far be it from me to tell you where to post, but it sounds like you are seeking Perl wisdom.

UUE versus base64

bart on 2002-11-06T20:37:35

If you see a line long string without whitespace, it likely is one of these. Differences are:
  • The alphabet is different. UUE uses Ascii codes 33 to 96, hence, no lowercase letters; bases64 uses mainly uppercase and lowercase letters, digits, and a few more characters. See table 1
  • UUE has a count byte up front, while base64 hasn't. So it's likely that the number of meaningful characters is 4*n+1 in UUE, and 4*n in base64. Also, you can check the value of the count byte.
  • For UUE, there should be a line "begin 644 filename" at the top, 644 being the file mode, and a line "end" underneath. MS is notorious for using an empty string instead of the file mode as well.
  • In case of base64, the message is likely in MIME format, hence, check for the "MIME" header and liely even a "content-transfer-encoding" header indicating that this message, or part of it in a multipart message, is in base64.