Ticket #1485080 (closed Bugs: fixed)

Opened 6 months ago

Last modified 6 months ago

trim and chop usage redundant, occasionally incorrect

Reported by: memoryhole Owned by:
Priority: 5 Milestone: 0.2-alpha
Component: Client Scripts Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

The use of trim and chop in imap.inc is confused.

For the record, in PHP chop is an alias for rtrim, which removes whitespace from the END of the string. trim, on the other hand, removes whitespace from BOTH the end and the beginning of the string.

These functions are used redundantly throughout imap.inc. One common example:

$line=trim(chop(iil_ReadLine($fp, 10000)));

Calling chop in that case is redundant, because trim takes care of both ends of the line.

In some places, I suspect that chop is called when trim's behavior is expected. For example, line 2304 looks like this:

while (chop($line) != ')') {

... which actually causes problems with my IMAP server occasionally. Changing it to

while (trim($line) != ')') {

fixes the problem. Similar bugs are likely lurking elsewhere in this file, but I haven't had time to examine every use of chop to see if it makes sense.

... is it possible that the author of this file was expecting chop to behave like the Perl function of the same name?

Attachments

imap.patch (2.3 kB) - added by memoryhole 6 months ago.
fix for redundant chop/trim calls

Change History

Changed 6 months ago by memoryhole

fix for redundant chop/trim calls

Changed 6 months ago by memoryhole

I noticed that my patch also includes the fix to #1483910

Changed 6 months ago by francesco_r

I have applied your patch, but my problem (#1483910) is not resolved. I cannot open at least 30% of messages.

Changed 6 months ago by alec

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from later to 0.1.2

Patch applied in r1419.

Note: See TracTickets for help on using tickets.