annotate mcabber/mcabber/nohtml.c @ 2251:f3bd1564fa70

Stop html-escaping otr messages and do only strip known tags. We'd like to remove that for good, but pidgin-otr and Adium are still sending html tags.
author franky
date Fri, 19 Feb 2016 22:14:15 +0100
parents e6d355e50d7a
children f5402d705f67
rev   line source
1470
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
1 /*
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
2 * nohtml.c -- (X)HTML helper functions
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
3 *
1599
dcd5d4c75199 Update/Add headers
Mikael Berthe <mikael@lilotux.net>
parents: 1470
diff changeset
4 * Copyright (C) 2008,2009 Mikael Berthe <mikael@lilotux.net>
1470
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
5 * Some portions come from the jabberd project, see below.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
6 *
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or (at
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
10 * your option) any later version.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
11 *
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
15 * General Public License for more details.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
16 *
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
20 * USA
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
21 *
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
22 *
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
23 * Some parts come from libjabber/str.c:
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
24 * Copyright (c) 1999-2002 Jabber.com, Inc. All Rights Reserved. Contact
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
25 * information for Jabber.com, Inc. is available at http://www.jabber.com/.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
26 * Portions Copyright (c) 1998-1999 Jeremie Miller.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
27 */
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
28
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
29 #include <string.h>
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
30 #include <glib.h>
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
31 #include <config.h>
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
32
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
33
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
34 /* html_strip(htmlbuf)
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
35 * Remove html entities from htmlbuf and try to convert it to plain text.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
36 * The caller must g_free the string after use.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
37 * Code mostly derived from strunescape(), in libjabber.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
38 */
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
39 char *html_strip(const char *htmlbuf)
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
40 {
2251
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
41 int i, j=0, html_len;
1470
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
42 char *nohtml;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
43
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
44 if (!htmlbuf) return(NULL);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
45
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
46 nohtml = g_strdup(htmlbuf);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
47
2251
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
48 html_len = (int)strlen(htmlbuf);
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
49 for (i = 0; i < html_len; i++) {
1470
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
50 if (htmlbuf[i] == '&') {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
51 if (!strncmp(&htmlbuf[i],"&amp;",5)) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
52 nohtml[j] = '&';
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
53 i += 4;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
54 } else if (!strncmp(&htmlbuf[i],"&quot;", 6)) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
55 nohtml[j] = '\"';
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
56 i += 5;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
57 } else if (!strncmp(&htmlbuf[i],"&apos;", 6)) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
58 nohtml[j] = '\'';
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
59 i += 5;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
60 } else if (!strncmp(&htmlbuf[i],"&lt;", 4)) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
61 nohtml[j] = '<';
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
62 i += 3;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
63 } else if (!strncmp(&htmlbuf[i],"&gt;", 4)) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
64 nohtml[j] = '>';
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
65 i += 3;
2251
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
66 } else {
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
67 nohtml[j] = htmlbuf[i];
1470
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
68 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
69 } else if (htmlbuf[i] == '<') {
2251
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
70 if (!strncmp(&htmlbuf[i],"<br>", 4)) {
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
71 nohtml[j] = '\n';
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
72 i += 3;
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
73 } else if (!strncmp(&htmlbuf[i],"<br/>", 5)) {
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
74 nohtml[j] = '\n';
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
75 i += 4;
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
76 } else if (!strncmp(&htmlbuf[i],"<FONT>", 6)) {
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
77 /* Let's strip <FONT> from Adium */
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
78 i += 5;
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
79 j--;
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
80 } else if (!strncmp(&htmlbuf[i],"</FONT>", 7)) {
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
81 i += 6;
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
82 j--;
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
83 } else {
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
84 nohtml[j] = htmlbuf[i];
f3bd1564fa70 Stop html-escaping otr messages and do only strip known tags.
franky
parents: 1811
diff changeset
85 }
1470
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
86 } else
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
87 nohtml[j] = htmlbuf[i];
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
88 j++;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
89 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
90 nohtml[j] = '\0';
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
91 return nohtml;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
92 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
93
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
94 /* html_escape(text)
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
95 * Add (x)html entities to the text.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
96 * The caller must g_free the string after use.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
97 * Code mostly derived from strescape(), in libjabber.
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
98 */
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
99 char *html_escape(const char *text)
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
100 {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
101 int i, j;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
102 int oldlen, newlen;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
103 char *html;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
104
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
105 if (!text) return(NULL);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
106
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
107 oldlen = newlen = strlen(text);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
108
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
109 for (i = 0; i < oldlen; i++) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
110 switch(text[i])
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
111 {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
112 case '&':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
113 newlen += 5;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
114 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
115 case '\'':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
116 newlen += 6;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
117 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
118 case '\"':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
119 newlen += 6;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
120 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
121 case '<':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
122 newlen += 4;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
123 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
124 case '>':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
125 newlen += 4;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
126 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
127 case '\n':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
128 newlen += 5;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
129 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
130 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
131
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
132 if (oldlen == newlen)
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
133 return g_strdup(text);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
134
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
135 html = g_new0(char, newlen+1);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
136
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
137 for (i = j = 0; i < oldlen; i++) {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
138 switch(text[i])
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
139 {
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
140 case '&':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
141 memcpy(&html[j], "&amp;", 5);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
142 j += 5;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
143 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
144 case '\'':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
145 memcpy(&html[j], "&apos;", 6);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
146 j += 6;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
147 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
148 case '\"':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
149 memcpy(&html[j], "&quot;", 6);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
150 j += 6;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
151 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
152 case '<':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
153 memcpy(&html[j], "&lt;", 4);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
154 j += 4;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
155 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
156 case '>':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
157 memcpy(&html[j], "&gt;", 4);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
158 j += 4;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
159 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
160 case '\n':
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
161 memcpy(&html[j], "<br/>", 5);
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
162 j += 5;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
163 break;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
164 default:
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
165 html[j++] = text[i];
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
166 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
167 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
168 return html;
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
169 }
a8b924b5474c The OTR protocol expects (X)HTML messsages
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
170
1811
e6d355e50d7a Update Vim modelines
Mikael Berthe <mikael@lilotux.net>
parents: 1668
diff changeset
171 /* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */