Skip to content

Error decoding a string with Cyrillic characters to search an e-mail by subject via IMAP protocol #717

Description

@vadetcka999

Describe the bug
I'm trying to find a subject line email in my Gmail inbox.

    Store store = imapConnectionPool.getStore(account);
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.ENVELOPE);
    fp.add(FetchProfile.Item.CONTENT_INFO);
    fp.add(FetchProfile.Item.FLAGS);

    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message[] messages = inbox.search(new SubjectTerm("привет!"));
    inbox.fetch(messages,fp);
    return messages;

But the library does not encode it correctly "привет!", because if we look through the debug what commands the imap client sends to the server, we will see that it leaves incomprehensible characters.

    DEBUG: setDebug: Jakarta Mail version 2.1.1
    DEBUG: getProvider() returning jakarta.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
    DEBUG IMAP: mail.imap.fetchsize: 16384
    DEBUG IMAP: mail.imap.ignorebodystructuresize: false
    DEBUG IMAP: mail.imap.statuscachetimeout: 1000
    DEBUG IMAP: mail.imap.appendbuffersize: -1
    DEBUG IMAP: mail.imap.minidletime: 10
    DEBUG IMAP: closeFoldersOnStoreFailure
    DEBUG IMAP: protocolConnect returning false, host=imap.gmail.com, user=kuznetsovvs, password=<null>
    DEBUG IMAP: trying to connect to host "imap.gmail.com", port 993, isSSL true
    * OK Gimap ready for requests from 95.25.2.187 2adb3069b0e04-512b35b608cmb63806781e87
    A0 CAPABILITY
    * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER
    A0 OK Thats all she wrote! 2adb3069b0e04-512b35b608cmb63806781e87
    DEBUG IMAP: AUTH: XOAUTH2
    DEBUG IMAP: AUTH: PLAIN
    DEBUG IMAP: AUTH: PLAIN-CLIENTTOKEN
    DEBUG IMAP: AUTH: OAUTHBEARER
    DEBUG IMAP: protocolConnect login, host=imap.gmail.com, user=ostenzvuk@gmail.com, password=<non-null>
    DEBUG IMAP: AUTHENTICATE XOAUTH2 command trace suppressed
    DEBUG IMAP: AUTHENTICATE XOAUTH2 command result: A1 OK ostenzvuk@gmail.com authenticated (Success)
    A2 ENABLE UTF8=ACCEPT
    * ENABLED UTF8=ACCEPT
    A2 OK Success
    DEBUG IMAP: IMAPProtocol noop
    A3 NOOP
    A3 OK Success
    DEBUG IMAP: connection available -- size: 1
    A4 EXAMINE INBOX
    * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $NotPhishing $Phishing)
    * OK [PERMANENTFLAGS ()] Flags permitted.
    * OK [UIDVALIDITY 1] UIDs valid.
    * 712 EXISTS
    * 0 RECENT
    * OK [UIDNEXT 5454] Predicted next UID.
    * OK [HIGHESTMODSEQ 829444]
    A4 OK [READ-ONLY] INBOX selected. (Success)
    A5 SEARCH SUBJECT ?@825B! ALL
    * SEARCH
    A5 OK SEARCH completed (Success)

I don't think that's right "? @825B!" and the topics in English are fine. It searches for them and finds them. Problem with Russian and Ukrainian

Mail server:

  • Protocol being used: imap
  • Vendor/product: Google
  • Mail service URL: imap.gmail.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions