summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-07-07 20:45:24 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-07-07 20:55:25 +0200
commit36be830bfcdac16291d1a1050ecc9aee35cd102f (patch)
treee1cd7b717c86e90888ad0ae9f68b4686ee18da99 /degesch.c
parentf7dce5e861e90581dd1317847aa4ca6771323150 (diff)
downloadxK-36be830bfcdac16291d1a1050ecc9aee35cd102f.tar.gz
xK-36be830bfcdac16291d1a1050ecc9aee35cd102f.tar.xz
xK-36be830bfcdac16291d1a1050ecc9aee35cd102f.zip
degesch: better shift state encoding handling
I don't know, probably didn't matter.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/degesch.c b/degesch.c
index 48e2c17..2f8dc83 100644
--- a/degesch.c
+++ b/degesch.c
@@ -3599,9 +3599,16 @@ explode_formatter_attr (struct exploder *self, struct formatter_item *item)
static void
explode_text (struct exploder *self, const char *text)
{
+ // Throw away any potentially harmful control characters first
+ struct str filtered = str_make ();
+ for (const char *p = text; *p; p++)
+ if (!strchr ("\a\b\x1b", *p))
+ str_append_c (&filtered, *p);
+
size_t term_len = 0;
char *term = iconv_xstrdup (self->ctx->term_from_utf8,
- (char *) text, -1, &term_len);
+ filtered.str, filtered.len + 1, &term_len);
+ str_free (&filtered);
mbstate_t ps;
memset (&ps, 0, sizeof ps);
@@ -3613,11 +3620,6 @@ explode_text (struct exploder *self, const char *text)
hard_assert (len != (size_t) -2 && len != (size_t) -1);
processed += len;
- // Throw away any potentially harmful control characters
- // XXX: this is likely to break shift state encodings
- if (wcschr (L"\a\b\x1b", wch))
- continue;
-
struct line_char *c = line_char_new (term + processed - len, len, wch);
c->attrs = self->attrs;
LIST_APPEND_WITH_TAIL (self->result, self->result_tail, c);