Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vadetcka999 opened this issue Mar 4, 2024 · 9 comments · May be fixed by eclipse-ee4j/angus-mail#131
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@vadetcka999
Copy link

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, [email protected], password=<non-null>
    DEBUG IMAP: AUTHENTICATE XOAUTH2 command trace suppressed
    DEBUG IMAP: AUTHENTICATE XOAUTH2 command result: A1 OK [email protected] 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
@vadetcka999
Copy link
Author

HEEEELP MEE, and for BodyTerm same situation

 A5 SEARCH BODY "�@825B" ALL

@jmehrens jmehrens added duplicate This issue or pull request already exists bug Something isn't working labels Mar 4, 2024
@jmehrens
Copy link
Contributor

jmehrens commented Mar 4, 2024

Duplicate of #474

@jmehrens jmehrens marked this as a duplicate of #474 Mar 4, 2024
@synim503
Copy link

synim503 commented Mar 4, 2024

Duplicate of #474

Where's the solution to this problem?????

@jmehrens
Copy link
Contributor

jmehrens commented Mar 4, 2024

No workarounds that I'm aware of at this time. The draft PR for this has been linked to this ticket above that comment and in the development section. Explanation of the problems are in that PR. Work is in progress and it would help if there are people willing to test the snapshot once it is ready.

@synim503
Copy link

synim503 commented Mar 4, 2024

No workarounds that I'm aware of at this time. The draft PR for this has been linked to this ticket above that comment and in the development section. Explanation of the problems are in that PR. Work is in progress and it would help if there are people willing to test the snapshot once it is ready.

This needs to be addressed, it's a serious problem for some people including myself and people I know....

@synim503
Copy link

synim503 commented Mar 4, 2024

No workarounds that I'm aware of at this time. The draft PR for this has been linked to this ticket above that comment and in the development section. Explanation of the problems are in that PR. Work is in progress and it would help if there are people willing to test the snapshot once it is ready.

Is there any way I can compile a draft solution and test it now?

@jmehrens
Copy link
Contributor

jmehrens commented Mar 4, 2024

This needs to be addressed, it's a serious problem for some people including myself and people I know....
Is there any way I can compile a draft solution and test it now?

Agreed. I recognize the priority and importance of this issue as the first message in the linked the draft PR. I've also noted that this PR is going to take me some time to fully complete. I think the basic idea and approach is correct in that PR.

I pushed my latest changes to eclipse-ee4j/angus-mail#131 which builds now but test at your own risk. There are a few things that may not be correct. Put feedback in that PR.

@YAYO-KING
Copy link

Please prioritize this issue as it is used in many searches

@jmehrens
Copy link
Contributor

@YAYO-KING test the build in PR and give feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants