From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, xypron.glpk@gmx.de,
Liming Gao <liming.gao@intel.com>
Cc: michael.d.kinney@intel.com
Subject: Re: [edk2-devel] [edk] [PATCH] ShellPkg/edit: allow non-ASCII characters in edit
Date: Mon, 2 Nov 2020 22:10:56 +0100 [thread overview]
Message-ID: <dc413efd-11fe-c393-836f-1194e120b645@redhat.com> (raw)
In-Reply-To: <20191124103749.21576-1-xypron.glpk@gmx.de>
On 11/24/19 11:37, Heinrich Schuchardt via Groups.Io wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2339
>
> Currently it is not possible to add letters outside the range
> U+0020 - U+007F to a file using the edit command.
>
> In Unicode the following are control characters:
>
> * U+0000—U+001F (C0 controls)
> * U+007F (DEL)
> * U+0080—U+009F (C1 controls).
>
> For reference see:
>
> * https://unicode.org/charts/PDF/U0000.pdf
> * https://unicode.org/charts/PDF/U0080.pdf
>
> So the characters we should exclude from the file buffer are:
> U+0000 - U+001f, U+007f - U009F
>
> Allow all other characters as input to the file buffer in Unicode mode.
> Allow only ASCII characters as input in ASCII mode.
>
> When saving a file in ASCII mode replace non-ASCII characters by a question
> mark ('?').
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> Resent due to a typo in Limings email-address.
> ---
(1) Please run "BaseTools/Scripts/SetupGit.py" in your edk2 clone.
(2) This patch was lost because the ShellPkg maintainers were not CC'd.
I suggest resending the patch, with the Content-Transfer-Encoding fixed
(8bit or base64, per (1)), and with the following folks CC'd (per (2)):
Ray Ni <ray.ni@intel.com>
Zhichao Gao <zhichao.gao@intel.com>
Thanks
Laszlo
> .../Edit/FileBuffer.c | 21 +++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
> index fd324cc4a8..12235e4e4b 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
> @@ -1360,6 +1360,8 @@ GetNewLine (
> /**
>
> Change a Unicode string to an ASCII string.
>
>
>
> + Non-ASCII characters are replaced by '?'.
>
> +
>
> @param[in] UStr The Unicode string.
>
> @param[in] Length The maximum size of AStr.
>
> @param[out] AStr ASCII string to pass out.
>
> @@ -1378,8 +1380,12 @@ UnicodeToAscii (
> //
>
> // just buffer copy, not character copy
>
> //
>
> - for (Index = 0; Index < Length; Index++) {
>
> - *AStr++ = (CHAR8) *UStr++;
>
> + for (Index = 0; Index < Length; Index++, UStr++) {
>
> + if (*UStr < 0x80) {
>
> + *AStr++ = (CHAR8) *UStr;
>
> + } else {
>
> + *AStr++ = '?';
>
> + }
>
> }
>
>
>
> return Index;
>
> @@ -2154,9 +2160,16 @@ FileBufferDoCharInput (
>
>
> default:
>
> //
>
> - // DEAL WITH ASCII CHAR, filter out thing like ctrl+f
>
> + // Do not add Unicode control characters to the file buffer:
>
> + //
>
> + // * U+0000-U+001f (C0 controls)
>
> + // * U+007f (DEL)
>
> + // * U+0080-U+009f (C1 controls)
>
> + //
>
> + // Do not add non-ASCII characters in ASCII mode.
>
> //
>
> - if (Char > 127 || Char < 32) {
>
> + if (Char < 0x20 || (Char >= 0x7f &&
>
> + (Char <= 0x9f || FileBuffer.FileType == FileTypeAscii))) {
>
> Status = StatusBarSetStatusString (L"Unknown Command");
>
> } else {
>
> Status = FileBufferAddChar (Char);
>
prev parent reply other threads:[~2020-11-02 21:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-24 10:37 [edk] [PATCH] ShellPkg/edit: allow non-ASCII characters in edit Heinrich Schuchardt
2020-11-02 21:10 ` Laszlo Ersek [this message]
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-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc413efd-11fe-c393-836f-1194e120b645@redhat.com \
--to=devel@edk2.groups.io \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox