summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-08 02:15:57 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-08 02:15:57 +0100
commitb3072bd26138913d0d65bd23bd538a87a1b182f7 (patch)
treed22f0e1704657f9e57fc8b960b7fda876419eae6
parentb8b54735c7fe3bcdc2d3f739250b28e5facd9aef (diff)
parentd83eda6fd4fc74d5bedb1ca860c1015e7e0d3732 (diff)
downloadpoezio-b3072bd26138913d0d65bd23bd538a87a1b182f7.tar.gz
poezio-b3072bd26138913d0d65bd23bd538a87a1b182f7.tar.bz2
poezio-b3072bd26138913d0d65bd23bd538a87a1b182f7.tar.xz
poezio-b3072bd26138913d0d65bd23bd538a87a1b182f7.zip
Merge branch 'master' into plugins
Conflicts: src/tabs.py src/xhtml.py
-rw-r--r--src/pooptmodule.c21
-rw-r--r--src/xhtml.py8
2 files changed, 24 insertions, 5 deletions
diff --git a/src/pooptmodule.c b/src/pooptmodule.c
index b696fe4e..8a021379 100644
--- a/src/pooptmodule.c
+++ b/src/pooptmodule.c
@@ -44,6 +44,8 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
int last_space = -1;
int start_pos = 0;
+ int w = width; /* this is a width that increases to make the length of char
+ of colors attribute be ignored */
PyObject* retlist = PyList_New(0);
while (buffer[bpos])
@@ -57,7 +59,7 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
start_pos = spos + 1;
last_space = -1;
}
- else if ((spos - start_pos) >= width)
+ else if ((spos - start_pos) >= w)
{
if (last_space == -1)
{
@@ -72,11 +74,24 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
start_pos = last_space + 1;
last_space = -1;
}
+ w = width;
}
if (buffer[bpos] == 25) /* \x19 */
{
- spos++;
- bpos += 2;
+ while (buffer[bpos] &&
+ buffer[bpos] != 'u' &&
+ buffer[bpos] != 'b' &&
+ buffer[bpos] != 'o' &&
+ buffer[bpos] != '}')
+ {
+ bpos++;
+ spos++;
+ w++;
+ }
+ bpos++;
+ spos++;
+ w++;
+ spos--;
}
else
if (buffer[bpos] <= 127) /* ASCII char on one byte */
diff --git a/src/xhtml.py b/src/xhtml.py
index 973a4d18..99e0bf01 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -16,7 +16,11 @@ import re
import subprocess
import curses
from sleekxmpp.xmlstream import ET
+
+import xml.sax.saxutils
+
from xml.etree.ElementTree import ElementTree
+
from sys import version_info
from config import config
@@ -399,7 +403,7 @@ def poezio_colors_to_html(string):
while next_attr_char != -1:
attr_char = string[next_attr_char+1].lower()
if next_attr_char != 0:
- res += string[:next_attr_char]
+ res += xml.sax.saxutils.escape(string[:next_attr_char])
if attr_char == 'o':
for elem in opened_elements[::-1]:
res += '</%s>' % (elem,)
@@ -423,7 +427,7 @@ def poezio_colors_to_html(string):
else:
string = string[next_attr_char+2:]
next_attr_char = string.find('\x19')
- res += string
+ res += xml.sax.saxutils.escape(string)
for elem in opened_elements[::-1]:
res += '</%s>' % (elem,)
res += "</p></body>"