GmailAttachmentsExtractor icon indicating copy to clipboard operation
GmailAttachmentsExtractor copied to clipboard

ParseException: expected ';', got "["

Open strahl opened this issue 2 years ago • 1 comments

First thanks a lot for your tool! I got the following error when calling java -jar GmailAttachmentsExtractor.jar larger:5M ~/Dokumente/EMailAttachments using the precompiled 1.0.3 JAR from github.

517/~611 (84%) | Processing email '[C.A.R.] Thank you!'
    Extracting 3 attachment(s) to directory '2008.05.12 12_59_25 [C.A.R.] Thank you!'
javax.mail.internet.ParseException: In parameter list <; filename=IMG_0907[1]>, expected ';', got "["
        at javax.mail.internet.ParameterList.<init>(ParameterList.java:314)
        at javax.mail.internet.ContentDisposition.<init>(ContentDisposition.java:109)
        at javax.mail.internet.MimeBodyPart.getFileName(MimeBodyPart.java:1294)
        at javax.mail.internet.MimeBodyPart.getFileName(MimeBodyPart.java:549)
        at pl.geek.tewu.gmail_attachments_extractor.Utils.getPartFileName(Utils.java:208)
        at pl.geek.tewu.gmail_attachments_extractor.GmailAttachmentsExtractor.extractAttachments(GmailAttachmentsExtractor.java:154)
        at pl.geek.tewu.gmail_attachments_extractor.Main.call(Main.java:45)
        at pl.geek.tewu.gmail_attachments_extractor.Main.call(Main.java:14)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1783)
        at picocli.CommandLine.access$900(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2150)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2144)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2108)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1975)
        at picocli.CommandLine.execute(CommandLine.java:1904)
        at pl.geek.tewu.gmail_attachments_extractor.Main.main(Main.java:29)

❯ java -jar GmailAttachmentsExtractor.jar --version
1.0.3
❯ java --version
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Debian-1deb11u1, mixed mode, sharing)

strahl avatar May 25 '22 06:05 strahl

I looked into it with a debugger and found the --unsafe option which fixed the parse exception. Here the output from the debug console at the exception Utils.java line 208:

> part
MimeBodyPart@68
> exc
ParseException@69 "javax.mail.internet.ParseException: In parameter list <; filename=IMG_0907[1]>, expected ';', got "[""
> fixNotQuotedPartFileName(part)
(void)
> part.getFileName()
"IMG_0907[1]"

strahl avatar May 25 '22 11:05 strahl