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

Flags/PermanentFlags somehow contains an empty string #44

Open
ptrcnull opened this issue Sep 11, 2023 · 2 comments · May be fixed by #45
Open

Flags/PermanentFlags somehow contains an empty string #44

ptrcnull opened this issue Sep 11, 2023 · 2 comments · May be fixed by #45

Comments

@ptrcnull
Copy link
Contributor

ptrcnull commented Sep 11, 2023

originally reported here: emersion/go-imap#544
tl;dr: go-imap-sql inserts an empty string to Flags, which then gets incorrectly serialized in go-imap for the SELECT response and becomes impossible to get parsed back by go-imap itself

looks like the logic for collecting flags from the mailbox is wrong:
https://github.com/foxcpp/go-imap-sql/blob/c0176dad/mailbox.go#L128-L137

the simplest fix would be

if flag == "" {
    continue
}

though i'm not sure why it even happens

@ptrcnull
Copy link
Contributor Author

ptrcnull commented Sep 11, 2023

checking the SQL database itself, there indeed is at least one record in the flags table where the flag itself is an empty string:

maddy> SELECT DISTINCT flag FROM flags;
+------------------+
| flag             |
|------------------|
| \Deleted         |
| $mdnsent         |
| $Label4          |
| nonjunk          |
| $label4          |
| $forwarded       |
| $label1          |
| \Answered        |
| \Seen            |
| junk             |
| loadremoteimages |
|                  |
| \Draft           |
| \Recent          |
| \Flagged         |
| $Label1          |
| yeet             |
+------------------+
SELECT 17
Time: 0.053s
maddy>

@ptrcnull
Copy link
Contributor Author

it looks like there's quite a lot of them actually...

maddy> select count(*) from flags;
+--------+
| count  |
|--------|
| 126760 |
+--------+
SELECT 1
Time: 0.040s
maddy> select count(*) from flags where flag = '';
+-------+
| count |
|-------|
| 39784 |
+-------+
SELECT 1
Time: 0.051s
maddy>

so i assume it's not an accidental insert, and instead the parsing should be fixed to not include the empty string

@ptrcnull ptrcnull linked a pull request Sep 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant