Opened 6 years ago
Closed 3 years ago
#1484141 closed Bugs (fixed)
Quoted text not wrapped properly when replying to an HTML email in plain text.
| Reported by: | dmandell | Owned by: | till |
|---|---|---|---|
| Priority: | 10 - Lowest | Milestone: | 0.4-beta |
| Component: | PHP backend | Version: | git-master |
| Severity: | normal | Keywords: | |
| Cc: |
Description
If I reply to an HTML email in plain text the quoted text doesn't get wrapped properly; occasionally a word will appear on a line by itself when there wasn't a line break. If I reply to an html email in HTML the text gets wrapped properly, and if I reply to a plain text email in plain text it works too. If necessary I can supply you with a snippet of text that causes the problem. I'm currently using revision 380, I'm pretty sure I noticed this in 361 also. If you need any more info from me please let me know, and if there's somewhere else I should be submitting bugs you can let me know that too.
I sent this to the dev list and they asked me to log it here, so I'm doing so. Eric Stadtherr asked me for the snippet of text in question, if anybody else wants it let me know.
Change History (16)
comment:1 Changed 6 years ago by thomasb
- Component changed from Client to PHP backend
- Milestone set to 0.1-rc2
comment:2 Changed 6 years ago by till
- Owner set to till
- Status changed from new to assigned
Should I commit this?
comment:3 Changed 6 years ago by thomasb
- Milestone changed from 0.1-rc2 to 0.1-stable
If it works as expected...
comment:4 Changed 6 years ago by dmandell
It doesn't work as expected, I was wrong. I've never been able to get wrapping quite right in plaintext, and I'm really not a programmer so I'm afraid I don't have any easy solutions. Ilohamail doesn't seem to exhibit the problem, but why that is I can't say.
comment:5 Changed 5 years ago by till
What about wordwrap() ?
comment:6 Changed 5 years ago by till
I need a test message here. As far as I can see, it works in trunk. At least I think?
function till_wrap($text, $size)
{
$text = wordwrap($text, $size);
$line = explode("\n", $text);
$keep = array();
for ($x=0; $x<count($line); $x++) {
array_push($keep, '> ' . $line[$x]);
}
return implode("\n", $keep);
}
comment:7 Changed 5 years ago by till
- Priority changed from 5 to 10
comment:8 Changed 5 years ago by till
I just tried this again.
Works in: IE7, Firefox (Windows and Mac) and Safari.
comment:9 Changed 5 years ago by till
Hobbes (aka Rainer) on IRC confirmed this is working too.
comment:10 Changed 5 years ago by the_glu
Worksforme too...
comment:11 Changed 5 years ago by till
- Resolution set to worksforme
- Status changed from assigned to closed
comment:12 Changed 5 years ago by dmandell
- Resolution worksforme deleted
- Status changed from closed to reopened
I sent this message to till before I realized I could reopen this ticket...
I stopped paying attention to trac for a while, I came back and saw that this bug was closed, however I'm still seeing this problem. I'm hoping I might provide you with the means to confirm the behavior so that it can be fixed.
Here's how I reproduce it: I log into gmail, type out a hundred or so words (maybe more?) in a single paragraph, send it to my email account and open up Roundcube.
In Roundcube I'm set by default to use plain text rather than the HTML composer. When I hit "Reply" to the email the compose page opens, and the text is already wrapped improperly. At the bottom of the email is an example of what Roundcube has done to a paragraph I've replied to. I can send that paragraph to an email account that you check with Roundcube to see if you see what I do.
I'm only sure that I see this issue with Gmail emails, most of the rest of the people I email use plain text.
On Thu, 10 Apr 2008 11:43:50 -0700, "Doug Mandell" <dmandell@…> wrote:
I'm typing a few paragraphs in order to get a paragraph that is the right
line length to cause an improperly wrapped sentence when I reply to this
message. There are several ways I could go about crafting this email, but
I
think I'm thinking about how I'm typing this email much too much, I've
actually gone back and edited what I was typing rather than just using a
stream-of-consciousness-type approach. I just need to generate a lot of
text, though not the same text, so that I'm sure that at least one line
will
be wrapped improperly. It's been really hard to track this down, and it's
come to the point where it's starting to drive me bananas, especially
because nobody is seeing what I'm seeing. I've got something like six
lines
of text now, which you think would be enough, though I've used some big
words, which might make it harder to wrap at the right place. I need to
keep to two or three letter words in order to be sure that I end up in the
right place. I am not an ox, am I?
Doug
comment:13 Changed 5 years ago by thomasb
- Milestone changed from 0.1-stable to 0.1.2
Could you please verify with the latest SVN checkout since [3790508c] could have fixed this issue.
comment:14 Changed 5 years ago by dmandell
I downloaded the latest SVN checkout and the problem still persists.
comment:15 Changed 5 years ago by alec
Confirmed. I've made investigation on it and found that problem occurs only when sending html messages from gmail. When sending in text/plain, message is wrapped to 70 (or 72) chars per line, but when sending in html format gmail creates multipart message. So, in roundcube for preview is used html part, but for reply roundcube use text part (if htmleditor is disabled) which is first. That text part is wrapped to 75 or more characters by gmail. Roundcube is trying to wrap again to 75 characters and we have behaviour described in ticket.
comment:16 Changed 3 years ago by alec
- Resolution set to fixed
- Status changed from reopened to closed
Fixed in [b620493a].

From dev-mailing list, by Doug Mandell:
function LangWrapLine($line, $width) { $line_len = strlen($line); $i = 0; //if line is less than width, we're good if ($line_len <= $width) return $line; for ($prev_i=0,$i=$width;$i<$line_len;$prev_i=$i,$i+=$width) { //extract last segment that is $width wide $chunk = substr($line, $prev_i, ($i-$prev_i))."\n"; //find last space in this chunk $last_space = strrpos($chunk, " "); $last_space = $prev_i + $last_space; if ($last_space==$prev_i){ //no space found in this chunk $next_space = strpos($line, " ", $i); if ($next_space!==false) { $i = $next_space; $line[$next_space] = "\n"; } } else { //replace last space before width with newline $line[$last_space]="\n"; $i = $last_space; } } return $line; } function LangSmartWrap($body, $len) { $lines = explode("\n", $body); if (!is_array($lines)) return ""; while ( list($i,$line)=each($lines) ) { if (!ereg("^>", $line)) $lines[$i] = LangWrapLine(chop($line), $len); } return implode("\n", $lines); }which is almost an exact copy of the relevant functions out of Ilohamail.
I then changed:
on line 491 to:
As I said, I know this isn't how it should be, but using the above functions everything works as it is supposed to.