Skip to content

Commit

Permalink
Version 0.6
Browse files Browse the repository at this point in the history
Fixed bug where base64 encoded emails where ignored.
  • Loading branch information
tobiasmiosczka committed May 18, 2018
1 parent e7f2cb9 commit a056001
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.tobiasmiosczka.cinema</groupId>
<artifactId>KDMManager</artifactId>
<version>0.5.0</version>
<version>0.6.0</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,37 @@ private static KDM getKdmFromInputStream(InputStream inputStream, String fileNam
);
}

private static String decode(String s) {
if (s == null)
return null;
if (s.matches("^=\\?.*\\?.*\\?.*\\?=$")) {
String cypher = s.replaceAll("^=\\?.*?\\?", "").replaceAll("\\?.*?\\?=$", "");
//String charset = s.replaceAll("^=\\?", "").replaceAll("\\?.*?\\?.*?\\?=$", "");
String text = s.replaceAll("^=\\?.*?\\?.*?\\?", "").replaceAll("\\?=$", "");
switch (cypher) {
case "Q":
return text;
case "B":
return new String(Base64.getDecoder().decode(text));
default:
return s;
}
} else {
return s;
}
}

private static Collection<KDM> handleMessages(Message[] messages, IUpdate iUpdate) throws IOException, JDOMException, ParseException, MessagingException {
Collection<KDM> kdms = new HashSet<>();
for (int i = 0; i < messages.length; ++i) {
Message message = messages[i];
iUpdate.onUpdateEmailLoading(i, messages.length);

if (message.getContentType().contains("multipart")) {
Multipart multipart = (Multipart) message.getContent();
for (int j = 0; j < multipart.getCount(); ++j) {
BodyPart bodyPart = multipart.getBodyPart(j);
String fileName = bodyPart.getFileName();
String fileName = decode(bodyPart.getFileName());
if (fileName != null && (Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()) || !StringHelper.isBlank(fileName))) {
if (fileName.endsWith(".zip"))
kdms.addAll(unzip(bodyPart.getInputStream()));
Expand Down

0 comments on commit a056001

Please sign in to comment.