sipmsg: handle Pidgin 3.x paragraph separators
commitd2a88933f5349331e442eea66eaa61391e0eaa73
authorJakub Adam <jakub.adam@ktknet.cz>
Wed, 22 Mar 2017 09:47:33 +0000 (22 10:47 +0100)
committerStefan Becker <chemobejk@gmail.com>
Sat, 27 May 2017 11:07:25 +0000 (27 14:07 +0300)
treebf0e3ae3f962d7931670ff90d122ab89c498f851
parentfc4111a7255cc38ccaccaba41d4302ed4358d87d
sipmsg: handle Pidgin 3.x paragraph separators

WebKitWebView, which Pidgin 3.x uses as message editor, encloses text
paragraphs between <div></div> tags. For the purpose of converting the
message into plaintext, we replace <div> tags with \r\n. The closing </div>
can be ignored (Sipe's HTML parser will strip unhandled tag from the output).

There is a special case of an empty paragraph, which WebKit encodes as
<div><br></div>. We handle it separately and replace the whole sequence with
a single \r\n, not two line breaks <div> and <br> would normally (wrongly)
get converted to, and thus

a<div><br></div><div><br></div><div>b</div><div>c</div>

transforms to

a\r\n
\r\n
\r\n
b\r\n
c

which is a good approximation of the HTML input.

Thanks to Rickard Claesson for bringing this issue to attention.
src/core/sipmsg.c