Opened 5 years ago
Closed 5 years ago
#1485080 closed Bugs (fixed)
trim and chop usage redundant, occasionally incorrect
| Reported by: | memoryhole | Owned by: | |
|---|---|---|---|
| Priority: | 5 | Milestone: | 0.2-alpha |
| Component: | Client Scripts | Version: | git-master |
| 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 (1)
Change History (4)
Changed 5 years ago by memoryhole
comment:1 Changed 5 years ago by memoryhole
I noticed that my patch also includes the fix to #1483910
comment:2 Changed 5 years ago by francesco_r
I have applied your patch, but my problem (#1483910) is not resolved. I cannot open at least 30% of messages.
comment:3 Changed 5 years ago by alec
- Milestone changed from later to 0.1.2
- Resolution set to fixed
- Status changed from new to closed
Patch applied in [9b90b337].

fix for redundant chop/trim calls