branch: elpa/mastodon
commit 962774f551af9ddb2c1e031a4a05be751da0c083
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    reimplement handling of rtl overrides: wrap in directional isolates. #718.
---
 lisp/mastodon-tl.el | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 3baa5dfd83..202fdfc22f 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -633,27 +633,21 @@ Do so if type of status at poins is not 
follow_request/follow."
                   (string= type "follow")) ; no counts for these
         (message "%s" echo)))))
 
-(defvar mastodon-tl-evil-unicode-regex
-  "[‮]"
-  ;; NB: this is (emacs) codepoints: 3fffe2, 3fff80, 3fffae.
-  ;; 3fffe2 is right-to-left-override (00202E?), I think.
-  ;; We probably shouldn't just strip these though, maybe they have legit
-  ;; uses?
-  "A regex of characters to be stripped from incoming JSON.")
-
-(defun mastodon-tl--display-name-strip (name)
-  "Strip NAME, a string, of characters in `mastodon-tl-evil-unicode-regex'."
-  (replace-regexp-in-string mastodon-tl-evil-unicode-regex
-                            "" name))
+(defun mastodon-tl--unicode-wrap (str)
+  "Wrap STR in unicode directional isolates."
+  ;; see https://unicode.org/reports/tr9/#Explicit_Directional_Isolates
+  ;; via Tusky (again! thanks)
+  ;; 
https://codeberg.org/tusky/Tusky/src/commit/16cef3d6202648e4fd67f06ef0fb1d0a2d04b68f/app/src/main/java/com/keylesspalace/tusky/util/StringUtils.kt#L65
+  (concat "\u2068" str "\u2069"))
 
 (defun mastodon-tl--byline-username (toot)
   "Format a byline username from account in TOOT.
-TOOT may be account data, or toot data, in which case acount data
-is extracted from it."
+  TOOT may be account data, or toot data, in which case acount data
+  is extracted from it."
   (let ((data (or (alist-get 'account toot)
                   toot))) ;; grouped nofifs use account data directly
     (let-alist data
-      (let ((disp (mastodon-tl--display-name-strip .display_name)))
+      (let ((disp (mastodon-tl--unicode-wrap .display_name)))
         (propertize (if (and .display_name
                              (not (string-empty-p disp)))
                         disp

Reply via email to