changeset: 6739:89b266256a85
user:      Kevin McCarthy <[email protected]>
date:      Wed Jul 20 16:29:55 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/89b266256a85

Filter directional markers that corrupt the screen. (closes #3854)

Thanks to Vincent Lefèvre for working on these utf-8 screen display issues.

diffs (61 lines):

diff -r 69bbe4da959f -r 89b266256a85 mbyte.c
--- a/mbyte.c   Tue Jul 19 18:56:13 2016 -0700
+++ b/mbyte.c   Wed Jul 20 16:29:55 2016 -0700
@@ -525,6 +525,18 @@
   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 @@
     }
     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';
diff -r 69bbe4da959f -r 89b266256a85 mbyte.h
--- a/mbyte.h   Tue Jul 19 18:56:13 2016 -0700
+++ b/mbyte.h   Wed Jul 20 16:29:55 2016 -0700
@@ -49,5 +49,6 @@
 extern int Charset_is_utf8;
 size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps);
 wchar_t replacement_char (void);
+int is_display_corrupting_utf8 (wchar_t wc);
 
 #endif /* _MBYTE_H */
diff -r 69bbe4da959f -r 89b266256a85 pager.c
--- a/pager.c   Tue Jul 19 18:56:13 2016 -0700
+++ b/pager.c   Wed Jul 20 16:29:55 2016 -0700
@@ -1156,9 +1156,7 @@
        dprint (3, (debugfile, "skip zero-width character U+%04X\n", (unsigned 
short)wc));
        continue;
       }
-      /* Filter bidi markers, see ticket #3827
-         Filter soft hyphen, see ticket #3848 */
-      if (wc == (wchar_t)0x200f || wc == (wchar_t)0x200e || wc == 
(wchar_t)0x00ad)
+      if (is_display_corrupting_utf8 (wc))
       {
        dprint (3, (debugfile, "filtered U+%04X\n", (unsigned short)wc));
        continue;

Reply via email to