r3c / custom_from

Plugin for Roundcube webmail, enable virtual email sender input.
https://plugins.roundcube.net/#/packages/r3c/custom-from
Other
20 stars 16 forks source link

Fixed a 'BAD Invalid field-name' bug that in some cases could occur #9

Closed pimlie closed 10 years ago

pimlie commented 10 years ago

Fixed an imap bug that in some cases could occur ('BAD Invalid field-name in UID Fetch BODY.PEEK[HEADER.FIELDS' due to field-names being separated by 2 spaces) because of which no messages will be listed.

[16-Apr-2014 16:23:00 +0100]: [0095] C: A0008 UID FETCH 1:25 (UID RFC822.SIZE FLAGS INTERNALDATE BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT CONTENT-TYPE CC REPLY-TO LIST-POST DISPOSITION-NOTIFICATION-TO X-PRIORITY X-ORIGINAL-TO)]) [16-Apr-2014 16:23:00 +0100]: [0095] S: A0008 BAD Invalid field-name in UID Fetch BODY.PEEK[HEADER.FIELDS

pimlie commented 9 years ago

I recently upgraded my roundcube installation & plugins and it appears this change has been overwritten by commit a90697481e11f972e93767373145af3744659aa4, therefore I am experiencing the same problem again. Not sure whether the change in a90697481e11f972e93767373145af3744659aa4 was intentional or not, will you have a look at it yourself or would you like me to make another commit?

r3c commented 9 years ago

Hi,

not sure I understand your comment: change ddd2d2f is still available in current master? (see custom_from.php line 43)

pimlie commented 9 years ago

As far as I see commit ddd2d2f8c8995876e55f7c179f81d3b30333cc95 was merged on April 16 2014, commit 5c9dd98d03b469447a3e72123b8dbbce5300df7d was merged on April 18 2014 which removed my change.

If I check https://github.com/r3c/CustomFrom/blob/master/custom_from.php#L43 the trim only spans $params['fetch_headers'], but as this variable could be empty the space before $header adds an double spacing between IMAP fields like I explained in my original issue. The trim should span both $params and $header or the space should only be added if $params['fetch_headers'] is not empty.

r3c commented 9 years ago

OK got it. Should be fixed by b7d1baa then.

pimlie commented 9 years ago

Unfortunately not, the joining space will now always be trimmed.

It should be either as in my commit:

$params['fetch_headers'] = trim ($params['fetch_headers'] . ' ' . $header);

or semantically nicer:

$params['fetch_headers'] = (!empty($params['fetch_headers']) ? $params['fetch_headers'] . ' ' : '') . $header;
r3c commented 9 years ago

Right, last one was a bit botched, sorry about that. Just pushed 53723fe, hope it's better. I still can't test it though, as I couldn't reproduce the issue on my install.