fdm icon indicating copy to clipboard operation
fdm copied to clipboard

1st, 2st, 3st, and 4st -- added the UID to the FETCH message

Open wu0lss4j opened this issue 5 months ago • 4 comments

On branch master Your branch is up to date with 'origin/master'.

Changes to be committed: modified: imap-common.c

modified lines 1153 and 1188 adding UID FETCH instead of just FETCH, hopefully now fdm will get all of gmail's special headers like X-GM-LABELS, X-GM-THRID, and X-GM-MSGID

removed one UID FETCH because the return msg apparently the IMAP server does not reply UID FETCH rather just FETCH

added the necessary logic to locate the " UID {UID}" at the end of the IMAP server's reply to the UID FETCH instruction, correctly assuming that everything that is in the message between X-GM-LABELS and UID are the labels, it even checks for the special case where there are no gmail labels.

Note: Gmail is extra special with labels, because if you tell fdm to fetch all email from a single label, that label is not returned by gmail and fdm will never see it. This is because gmail treats labels as virtual folders.

Not happy with the code, and I think it can be further improved, it's still quite fast, and I've yet to find another edge case with labels. So far so good.

modified:   configure.ac

added version info, but somehow doesn't stick, I wanted to call this program fdm_i 2.2i_1 but ¯_(ツ)_/¯, it ain't workin...

wu0lss4j avatar Oct 13 '25 13:10 wu0lss4j

This seems more complicated than necessary, you just need to skip everything after the ) which closes the X-GM-LABELS, no? So couldn't you just find that ), something like:

@@ -1193,10 +1193,9 @@ imap_state_gmext_body(struct account *a, struct fetch_ctx *fctx)
        if ((lb = strchr(lb, '(')) == NULL)
                return (imap_invalid(a, line));
        lb++; /* drop '(' */
-       lblen = strlen(lb);
-       if (lblen < 2 || lb[lblen - 1] != ')' || lb[lblen - 2] != ')')
+       if ((br = strchr(lb, ')') == NULL)
                return (imap_invalid(a, line));
-       lblen -= 2; /* drop '))' from the end */
+       lblen = br - lb;

        add_tag(&m->tags, "gmail_msgid", "%llu", msgid);
        add_tag(&m->tags, "gmail_thrid", "%llu", thrid);

nicm avatar Oct 20 '25 07:10 nicm

Or maybe the labels can contain )s?

nicm avatar Oct 20 '25 07:10 nicm

Hi, I am not sure because, you can also have a ) in your label, for some reason. So, if your code logic is to drop everything after the 1st closing parenthesis after X-GM-LABELS, it may be counter productive, that is why I went from the other direction, when I am “sure” that the ending is always “ UID nnn)”, or?

Sent from Gmail Mobile for iOS

Nicholas Marriott @.***> escreveu em seg., 20/10/2025 às 09:51 :

nicm left a comment (nicm/fdm#151) This seems more complicated than necessary, you just need to skip everything after the ) which clsoes the X-GM-LABELS, no? So couldn't you just find that ), somethin DuckDuckGo removed one tracker. More https://duckduckgo.com/-QoZ-qo7TnhDML4wcTPRCLPOUxlrW5ZFY2IRFm2gaIr8gz0gvrY1gwyCgj5emdt29ktrgGygxYAnC8nBsFIzk01thm5vAEU2cJNkYiOIcAqolkapVqE2WP5LeUWjOPYpLU6gQV9YA_1OAJgwi91JA8vK1s39_nCEvmM-1T9dVHr4-6G0SrrckxxrT3nwzOriJ72BZ8fO65dufRmMOetCYAzQcif0_vhExrnAab6GoJYrGB1hy2EhUycO0Ho3uFRLa9elW8LqIh7AQB1JBuBJfAWx0AZ2uBGWIytOtgY5lOi4D07AeECPKAklzwTYieknH3kFzWc_ymRBvglB2lHIUtam0lBViVzE1vQUU0J-FnjBTGL_i4vu4uYzxGUBgSTvO7d050yBkBbiNWe1Guh187ddICXcQIk6j1-QttTYbUexiY1KnWwAcT_wNTpLSNHe5Zg8Itz0HKUwkWyBgXGysQHp37-CJIWl-Y7xfS5MVjktvlbiKqQQiWiDDg Deactivate https://duckduckgo.com/ nicm left a comment (nicm/fdm#151) https://github.com/nicm/fdm/pull/151#issuecomment-3420957086

This seems more complicated than necessary, you just need to skip everything after the ) which clsoes the X-GM-LABELS, no? So couldn't you just find that ), something like:

@@ -1193,10 +1193,9 @@ imap_state_gmext_body(struct account *a, struct fetch_ctx fctx) if ((lb = strchr(lb, '(')) == NULL) return (imap_invalid(a, line)); lb++; / drop '(' */

  •   lblen = strlen(lb);
    
  •   if (lblen < 2 || lb[lblen - 1] != ')' || lb[lblen - 2] != ')')
    
  •   if ((br = strchr(lb, ')') == NULL)
              return (imap_invalid(a, line));
    
  •   lblen -= 2; /* drop '))' from the end */
    
  •   lblen = br - lb;
    
      add_tag(&m->tags, "gmail_msgid", "%llu", msgid);
      add_tag(&m->tags, "gmail_thrid", "%llu", thrid);
    

— Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/pull/151#issuecomment-3420957086, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDIRDFAEE7ZBBRSEO6SE7S33YSIBFAVCNFSM6AAAAACJBK33F6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRQHE2TOMBYGY . You are receiving this because you authored the thread.Message ID: @.***>

wu0lss4j avatar Oct 20 '25 09:10 wu0lss4j

Yes! :-)

Sent from Gmail Mobile for iOS

Nicholas Marriott @.***> escreveu em seg., 20/10/2025 às 09:53 :

nicm left a comment (nicm/fdm#151) Or maybe the labels can contain )s? —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message I DuckDuckGo removed one tracker. More https://duckduckgo.com/-hC1_MkG2lyq6Cv_v6J0Q93FKHpe9yTuUn5IemSgH-lgPnBz79qaIhjOU8Kv-_jLEtFgvtttgStrSBSlugBSsA1twaAxUKgj6uzNvd7BP5I5Bt2QXgzlF5df3Kqw1RR2HYB4C25qKyXAYIJNwE9Du3s_rM5nZ_vanUK2DfZxcljBgLHcozGRCruogWDWTlysWb7HRMVjGfYu_KH8ooPJXmyC84lA1iTaSd3oiZSTRn5vP5SzIskRDDi7WEID5noUyK9aB17piD6dWyZDzWAiQZ7BDvRjZ8SonkuhO7S7hKorw_VgMAdU13Ab9sX4Es2qHxTZScVIVgE0MOtWb5gxIQB7rXZabHIsAB_pxbXFmb9cdcbulbJGTVy9kZ9krnLUvMRZTuijBKP1tsEEnyJ5du1vE1pNcOkwzedxYoUkoKjh9zu5W6ArLFCv0s6BxKZNTP0y9IV9i42JmSiCNLa_UEGjZNbDpLJNKIvTFRZ0rauVdJ5mQ8uJsOEiDh-7Z_D8tPQuEXclisBnbxMos-CyHx-NwM Deactivate https://duckduckgo.com/ nicm left a comment (nicm/fdm#151) https://github.com/nicm/fdm/pull/151#issuecomment-3420959571

Or maybe the labels can contain )s?

— Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/pull/151#issuecomment-3420959571, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDIRDFAOGJ2MOIQBLL57VBT3YSIF7AVCNFSM6AAAAACJBK33F6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRQHE2TSNJXGE . You are receiving this because you authored the thread.Message ID: @.***>

wu0lss4j avatar Oct 20 '25 09:10 wu0lss4j