summaryrefslogtreecommitdiffstats
path: root/mbyte.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-07-20 16:29:55 -0700
committerKevin McCarthy <kevin@8t8.us>2016-07-20 16:29:55 -0700
commit8905cbb6efbae6d2e475c7822e61f721927a67ae (patch)
tree01008d2b315e4c7b349ccef34732164e11cfdc3f /mbyte.c
parent23095372e842fecf249990787174329ecbbe1693 (diff)
Filter directional markers that corrupt the screen. (closes #3854)
Thanks to Vincent Lefèvre for working on these utf-8 screen display issues.
Diffstat (limited to 'mbyte.c')
-rw-r--r--mbyte.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/mbyte.c b/mbyte.c
index d476a3a8..3df143f5 100644
--- a/mbyte.c
+++ b/mbyte.c
@@ -525,6 +525,18 @@ wchar_t replacement_char (void)
return Charset_is_utf8 ? 0xfffd : '?';
}
+int is_display_corrupting_utf8 (wchar_t wc)
+{
+ if (wc == (wchar_t)0x200f || /* bidi markers: #3827 */
+ wc == (wchar_t)0x200e ||
+ wc == (wchar_t)0x00ad || /* soft hyphen: #3848 */
+ (wc >= (wchar_t)0x202a && /* misc directional markers: #3854 */
+ wc <= (wchar_t)0x202e))
+ return 1;
+ else
+ return 0;
+}
+
int mutt_filter_unprintable (char **s)
{
BUFFER *b = NULL;
@@ -548,13 +560,8 @@ int mutt_filter_unprintable (char **s)
}
if (!IsWPrint (wc))
wc = '?';
- /* Filter out the RIGHT-TO-LEFT and LEFT-TO-RIGHT bidi markers because
- * they result in screen corruption. See ticket #3827.
- * Filter soft-hypen. See ticket #3848.
- */
else if (Charset_is_utf8 &&
- ((wc == (wchar_t)0x200f) || (wc == (wchar_t)0x200e) ||
- (wc == (wchar_t)0x00ad)))
+ is_display_corrupting_utf8 (wc))
continue;
k2 = wcrtomb (scratch, wc, &mbstate2);
scratch[k2] = '\0';