Support Forum

Post By Email: Line breaks in email reply get replaced with spaces

CC chris.crabtree
chris.crabtree
Member

So when I reply by email with a simple message like so:

A 4-line reply. Line 1.
Line 2.
Line 3.
Line 4.

The text of the message that’s actually posted in the forum becomes:

A 4-line reply. Line 1. Line 2. Line 3. Line 4.

It looks to me like the content filtering may be a bit too aggressive.

Specifically, in sp-email-post-imap.php, the function sp_process_inbox_imap() does a number of str_replace() operations on the raw content. I’m sure I don’t understand the deeper purpose behind some of these, but the culprit in my specific example case here looks to be this line:

$content = str_replace(chr(13).chr(10), ‘ ‘, $content);

Wondering if, rather than a space, the replacement character should be a “n” newline instead?

Thanks!

p.s. if it matters, I replied to the email via gmail’s standard web UI via the Chrome browser on a Mac.

 

3 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

I considered the filtering, as at the first release, to be what I can only describe as ‘rough’. I think my comment to my colleagues here was that once this starts to get used we can expect all kinds of filtering/display issues which will need addressing. This is to do with the non-standard way that different email clients deal with the email body content before sending it off. And some really do make a mess of it. The one I have the most problems with being Apple Mail although it should be OK using that at the moment.

GMail should be OK so I am surprised you are seeing a problem there. But it may well have changed of course. So should, I believe, PostBox – and therefore old Thunderbird clients – which Steve uses if I am not mistaken.

Anyway – the loose plan is that we take these issues on board as and when they are raised – adjust the filters until we get them right for as broad a collection of clients as are being used – and slowly clean up the code to suit. So my best suggestion – especially as you seem to know your way around the code – is tell us what you need exactly to get it right and then we will try that here and if no ill-effects in other clients we test with – then we will adopt it into the core code.

CC chris.crabtree
chris.crabtree
Member

Sounds reasonable to me! I understand how loose different email clients can be with their formatting, so it will definitely be an evolution.

So this is my change. I tested it with multi-line text last night and it worked as expected.

Before:

$content = str_replace(chr(13).chr(10), ‘ ‘, $content);

After:

$content = str_replace(chr(13).chr(10), "n", $content);

Thanks!

 

 

YS Yellow Swordfish
Yellow Swordfish
Member

That’s great thanks. Noted and we will try that out this end to see if it has any disturbing effects with the other clients we are using.