emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4c6afb5: ; Comment on the code in a recent commit


From: Eli Zaretskii
Subject: master 4c6afb5: ; Comment on the code in a recent commit
Date: Thu, 4 Nov 2021 15:46:46 -0400 (EDT)

branch: master
commit 4c6afb527bddf9e9f481dd6f6627ffd5407b8803
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    ; Comment on the code in a recent commit
    
    * lisp/international/mule-cmds.el
    (highlight-confusing-reorderings): Comment on the strategy of
    highlighting suspicious text.
---
 lisp/international/mule-cmds.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 8a64d61..c05a99c 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -3293,6 +3293,22 @@ specify the portion of the buffer to check."
                     (point) end nil
                     (current-bidi-paragraph-direction)))
         (goto-char next)
+        ;; We detect the problematic parts by watching directional
+        ;; properties of strong L2R and R2L characters.  But malicious
+        ;; reordering in source buffers can, and usuually does,
+        ;; include syntactically-important punctuation characters.
+        ;; Those have "weak" directionality, so we cannot easily
+        ;; detect when they are affected in malicious ways.
+        ;; Therefore, once we find a strong directional character
+        ;; whose directionality was tweaked, we highlight the text
+        ;; around it, between the first bidi control character we find
+        ;; before it that starts an override/embedding/isolate, and
+        ;; the first control after it that ends these.  This could
+        ;; sometimes highlight only part of the affected text.  An
+        ;; alternative would be to find the first "starter" following
+        ;; BOL and the last "ender" before EOL, and highlight
+        ;; everything in between them -- this could sometimes
+        ;; highlight too much.
         (let ((start
                (save-excursion
                  (re-search-backward reorder-starters nil t)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]