After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 326385 - evolution-data-server 1.5.4 mangles ASCII punctuation in IMAP passwords
evolution-data-server 1.5.4 mangles ASCII punctuation in IMAP passwords
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Mailer
unspecified
Other Linux
: Normal critical
: ---
Assigned To: evolution-mail-maintainers
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2006-01-10 02:36 UTC by Ed Catmur
Modified: 2006-01-16 20:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
evo-imap-mailbox-utf7.patch (5.30 KB, patch)
2006-01-10 18:34 UTC, Ed Catmur
none Details | Review
evo-imap-mailbox-utf7.patch (5.64 KB, patch)
2006-01-11 16:16 UTC, Ed Catmur
committed Details | Review

Description Ed Catmur 2006-01-10 02:36:04 UTC
Evolution changes "&" characters in IMAP passwords into "&-". 

I'm guessing it's somehow deciding to encode the password in IMAP-UTF-7?
Comment 1 Ed Catmur 2006-01-10 02:38:43 UTC
Hm. Probably the fix to bug 323106 is somehow responsible, but that shouldn't affect passwords, only account names.
Comment 2 Ed Catmur 2006-01-10 02:48:15 UTC
Ah, right. camel/providers/imap/camel-imap-store.c, ~ll 1372.. (imap_auth_loop):

		if (authtype)
			authenticated = try_auth (store, authtype->authproto, ex);
		else {
			response = camel_imap_command (store, NULL, ex,
						       "LOGIN %S %S",
						       service->url->user,
						       service->url->passwd);
			if (response) {
				camel_imap_response_free (store, response);
				authenticated = TRUE;
			}
		}

RFC 2060/3501 says password is plaintext, so change 

                         "LOGIN %S %S" 

to 

                         "LOGIN %S %s"

Makes no difference to non-ASCII paswords; they're broken anyway.
Comment 3 Ed Catmur 2006-01-10 02:52:37 UTC
Yah, patching that string fixes it.

Hm - first time I've patched a live binary by hand. I guess changing strings doesn't really count, though.
Comment 4 Jeffrey Stedfast 2006-01-10 17:16:23 UTC
this is the wrong fix as passwords are not confined to atom tokens, hence the %S in the first place. the patch that fixed the mailbox UTF-7 bug is broken in that it should not encode things which are not mailboxes (but it obviously is)
Comment 5 Ed Catmur 2006-01-10 18:20:28 UTC
Right, yeah. The commit has:

	* camel-imap-command.c (imap_command_strdup_vprintf): Do the
        conversion from UTF-8 to IMAP-UTF-7 only just before sending a
	request. Do it also for %S formats, as that is what the CREATE
	command uses. But %S is used also for other commands (like LOGIN
	and LIST), so maybe we really would need a new format that would
	be used *only* for mailbox (folder) names, assuming it's only
	mailbox names that use the IMAP-UTF-7 encoding. Or is that what %F
	is intended for? But why then does CREATE use %S?

The docstring for camel_imap_command_start has:

 * @fmt can include the following %-escapes ONLY:
 *	%s, %d, %%: as with printf
 *	%S: an IMAP "string" (quoted string or literal)
 *	%F: an IMAP folder name

The reason CREATE (and RENAME, and LIST) use %S is that %F prepends the imap store's namespace, which can't be done (?) if the argument isn't an existing folder. So we need 3 %-escapes: IMAP-string, IMAP-folder-name, and IMAP-folder-name-that-already-has-the-namespace-prepended. Uses of %S in CREATE, RENAME, LIST would then be switched to use this third escape.
Comment 6 Ed Catmur 2006-01-10 18:34:34 UTC
Created attachment 57118 [details] [review]
evo-imap-mailbox-utf7.patch

Maybe this will work. I think it's right to convert the second argument of LIST/LSUB to UTF-7, as it can contain non-ASCII mailbox naming characters -- and * and ? are unaffected by the conversion to UTF-7.
Comment 7 Jeffrey Stedfast 2006-01-11 16:00:22 UTC
this looks like the kind of fix I was thinking of a few minutes ago when I responded to Partha's email poke on bug #323106

I think you missed a few cases of %S usage tho. There's 2 LIST commands in imap_connect_online() and your patch only fixes 1 of them, for example. Might be other places missed too.
Comment 8 Ed Catmur 2006-01-11 16:16:13 UTC
Created attachment 57163 [details] [review]
evo-imap-mailbox-utf7.patch

Oh, yeah. I misunderstood how LIST worked.

There aren't any more, though: 

$ grep %S ./*.c
./camel-imap-command.c: *       %S: an IMAP "string" (quoted string or literal)
./camel-imap-command.c: * %S strings will be passed as literals if the server supports LITERAL+
./camel-imap-command.c: * and quoted strings otherwise. (%S does not support strings that
./camel-imap-command.c: * be converted to UTF-7 and processed like %S.
./camel-imap-store.c:                                                  "LOGIN %S %S",

And camel-imap-command.c isn't used anywhere else.
Comment 9 Jeffrey Stedfast 2006-01-11 16:23:42 UTC
this patch looks right to me, altho I'd probably change %G to something more meaningful like %N (for Namespace) or %P (for Path)... I think I'm leaning toward %P since there are a few places where it's not used as a namespace (or "parent path")
Comment 10 Dave Malcolm 2006-01-11 21:30:41 UTC
Also observed downstream here:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=177513
Comment 11 parthasarathi susarla 2006-01-16 20:55:15 UTC
This works for me. And the code is review too. Committed on head. Closing this bug.