From 1943141cf64f1935ba745c0dab5508d26adc6837 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Sun, 5 Oct 2014 17:17:15 +0900 Subject: [PATCH] coding.c (detect_coding_iso_2022): Set coding->rejected correctly when an invalid escape sequence is found (Bug#18610). --- src/ChangeLog | 5 +++++ src/coding.c | 30 ++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8005b738d6d..c8779d37841 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-10-05 K. Handa + + * coding.c (detect_coding_iso_2022): Set coding->rejected + correctly when an invalid escape sequence is found (Bug#18610). + 2014-10-04 Jan Djärv * gtkutil.c (create_menus): Only add tearoffs to empty menus. diff --git a/src/coding.c b/src/coding.c index 0337c0df60e..02e59286dc8 100644 --- a/src/coding.c +++ b/src/coding.c @@ -3073,8 +3073,13 @@ detect_coding_iso_2022 (struct coding_system *coding, ONE_MORE_BYTE (c1); if (c1 < ' ' || c1 >= 0x80 || (id = iso_charset_table[0][c >= ','][c1]) < 0) - /* Invalid designation sequence. Just ignore. */ - break; + { + /* Invalid designation sequence. Just ignore. */ + if (c1 >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); + break; + } } else if (c == '$') { @@ -3088,16 +3093,29 @@ detect_coding_iso_2022 (struct coding_system *coding, ONE_MORE_BYTE (c1); if (c1 < ' ' || c1 >= 0x80 || (id = iso_charset_table[1][c >= ','][c1]) < 0) - /* Invalid designation sequence. Just ignore. */ - break; + { + /* Invalid designation sequence. Just ignore. */ + if (c1 >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); + break; + } } else - /* Invalid designation sequence. Just ignore it. */ - break; + { + /* Invalid designation sequence. Just ignore it. */ + if (c >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); + break; + } } else { /* Invalid escape sequence. Just ignore it. */ + if (c >= 0x80) + rejected |= (CATEGORY_MASK_ISO_7BIT + | CATEGORY_MASK_ISO_7_ELSE); break; } -- 2.39.5