- /* possible lossage here with very old versions of sscanf(3)... */
- if ((st = sscanf(buf, "%[^@]@%s %s\n", user, host, id)) == 3)
+ /*
+ * At this point, we assume the bug has two fields -- a user@host
+ * part, and an ID part. Either field may contain spurious @ signs.
+ * The previous version of this code presumed one could split at
+ * the rightmost '@'. This is not correct, as InterMail puts an
+ * '@' in the UIDL.
+ */
+
+ /* first, skip leading spaces */
+ user = buf + strspn(buf, " \t");
+
+ /*
+ * First, we split the buf into a userhost part and an id
+ * part ... but id doesn't necessarily start with a '<',
+ * espescially if the POP server returns an X-UIDL header
+ * instead of a Message-ID, as GMX's (www.gmx.net) POP3
+ * StreamProxy V1.0 does.
+ *
+ * this is one other trick. The userhost part
+ * may contain ' ' in the user part, at least in
+ * the lotus notes case.
+ * So we start looking for the '@' after which the
+ * host will follow with the ' ' separator with the id.
+ *
+ * XXX FIXME: There is a case this code cannot handle:
+ * the user name cannot have blanks after a '@'.
+ */
+ if ((delimp1 = strchr(user, '@')) != NULL &&
+ (id = strchr(delimp1,' ')) != NULL)