Ticket #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: | 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?
