From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: bidi-string-strip-control-characters
Date: Thu, 20 Jan 2022 10:29:26 +0100 [thread overview]
Message-ID: <8735li69hl.fsf@gnus.org> (raw)
In-Reply-To: <83ee52rcar.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 20 Jan 2022 11:23:08 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
> Lars, I'm not sure I understand the purpose of this function. Can you
> explain?
Like the NEWS item says, it's for cases where you want to ensure that
there's no bidiness going on.
> The way it is currently used is also strange, to say the least: you
> apply it to a string made of a single character, so either it does
> nothing to the string, or it will return an empty string. So the
> following code will present the user with a riddle:
>
> (textsec-email-address-header-suspicious-p
> "Lars Ingebrigtsen <larsi@\N{RIGHT-TO-LEFT OVERRIDE}gnus.org>")
> "Disallowed character: `' (#x202e, RIGHT-TO-LEFT OVERRIDE)"
>
> The empty string between quotes is the riddle.
Well... perhaps not optimal, but not really a riddle. But the function
will probably be used elsewhere in textsec, too, but I haven't gotten
round to auditing all the strings yet.
> I think I understand the original problem: displaying a literal U+202E
> there will mess up the text on display, but if that is the reason, the
> right way is not to remove the character, it is to append to it the
> necessary bidi controls to prevent the messup (and make the appended
> controls be invisible).
>
> Here's an example:
>
> (insert (format "Disallowed character: `%s' (#x202e, RIGHT-TO-LEFT OVERRIDE)"
> (concat (string ?\x202e)
> (propertize (string ?\x202c ?\x200e) 'invisible t))))
>
> This displays the RLO character, but doesn't mess up the description
> after it.
The display is identical to the one we have now, though:
"Disallowed character: `' (#x202e, RIGHT-TO-LEFT OVERRIDE)"
So still a riddle.
But removing the bidi chars is "obviously correct" (and impervious to
future attacks) for somebody that's not that familiar with the bidi
machinery, so I prefer to remove the chars instead here.
> We do something like that in descr-text.el, so I guess we need to
> factor out that code and use it here.
Isn't that bidi-string-mark-left-to-right? I forget.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2022-01-20 9:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 9:23 bidi-string-strip-control-characters Eli Zaretskii
2022-01-20 9:29 ` Lars Ingebrigtsen [this message]
2022-01-20 10:14 ` bidi-string-strip-control-characters Eli Zaretskii
2022-01-20 12:47 ` bidi-string-strip-control-characters Lars Ingebrigtsen
2022-01-20 11:04 ` bidi-string-strip-control-characters Po Lu
2022-01-20 11:19 ` bidi-string-strip-control-characters Eli Zaretskii
2022-01-20 11:21 ` bidi-string-strip-control-characters Po Lu
2022-01-20 11:23 ` bidi-string-strip-control-characters Lars Ingebrigtsen
2022-01-20 11:33 ` bidi-string-strip-control-characters Eli Zaretskii
2022-01-20 12:46 ` bidi-string-strip-control-characters Lars Ingebrigtsen
2022-01-20 13:02 ` bidi-string-strip-control-characters Eli Zaretskii
2022-01-20 13:36 ` bidi-string-strip-control-characters Lars Ingebrigtsen
2022-01-20 16:51 ` bidi-string-strip-control-characters Eli Zaretskii
2022-01-21 9:18 ` bidi-string-strip-control-characters Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735li69hl.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).