Skip to contentSkip to conversation

Fix backspace in the username login prompt

PATCH Superseded Egor Ignatov 3 participants 6 messages Apr 29, 2021 – May 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix backspace in the username login prompt

This patch fixes an old bug when backspace key does not work in the username login prompt. It allows BIDI type BN characters (control chars like '\b') in the visual line. And when grub_gfxterm_putchar recieves this line it successfully processes backspace.

---
Hi, I'd like to try to propose this patch again. I'm new to the open source community, so any feedback and suggestions will be appreciated.

 grub/grub-core/normal/charset.c | 1 +
 1 file changed, 1 insertion(+)
grub/grub-core/normal/charset.c +1 -0
index b0ab47d73..30e819bdf 100644
@@ -925,6 +925,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
 	    pop_stack ();
 	    break;
 	  case GRUB_BIDI_TYPE_BN:
+	    visual_len++;
 	    break;
 	  case GRUB_BIDI_TYPE_R:
 	  case GRUB_BIDI_TYPE_AL:
Signature · 1 line
2.25.4
#1 lore raw

First of all, sorry for late reply but I am busy...

Quoted 4 lines · Egor Ignatov

This patch fixes an old bug when backspace key does not work in the username login prompt. It allows BIDI type BN characters (control chars like '\b') in the visual line. And when grub_gfxterm_putchar recieves this line it successfully processes backspace.

Did you test this patch with other BIDI type BN characters [1]? I am not convinced it works with them as expected. I think earlier version of your patch was more promising...

Quoted 13 lines

---
Hi, I'd like to try to propose this patch again. I'm new to the open source community, so any feedback and suggestions will be appreciated.

 grub/grub-core/normal/charset.c | 1 +
 1 file changed, 1 insertion(+)
grub/grub-core/normal/charset.c +0 -0
index b0ab47d73..30e819bdf 100644

grub/grub-core/normal/charset.c grub_bidi_line_logical_to_visual (const grub_uint32_t *logical, · line 931

Quoted 7 lines
grub/grub-core/normal/charset.c +1 -0
@@ -925,6 +925,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
 	    pop_stack ();
 	    break;
 	  case GRUB_BIDI_TYPE_BN:
+	    visual_len++;
 	    break;
 	  case GRUB_BIDI_TYPE_R:
 	  case GRUB_BIDI_TYPE_AL:

Daniel

[1] https://www.compart.com/en/unicode/bidiclass/BN

#2 lore raw

PATCH v2 1/1 Fix backspace in the username login prompt

This patch fixes a bug when backspace key does not work in the username login prompt. It allows backspace characters in the BIDI visual line. Thus grub_gfxterm_putchar receives '\b' chars that were previously ignored.

---

Quoted 1 line

Did you test this patch with other BIDI type BN characters [1]? I am not

You are right, I added a check to handle only backspace characters

Quoted 2 lines

convinced it works with them as expected. I think earlier version of your patch was more promising...

Earlier versions of my patch included workaround for special case when the password is longer than one line. This scenario is not very realistic and I dont think it's worth complicating the codebase.

Thank you for your response.
Let me know if you have any concerns about this version.

Egor

 grub-core/normal/charset.c | 2 ++
 1 file changed, 2 insertions(+)
grub-core/normal/charset.c +2 -0
index 4dfcc3107..8e7add1f8 100644
@@ -931,6 +931,8 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
 	    pop_stack ();
 	    break;
 	  case GRUB_BIDI_TYPE_BN:
+	    if (visual[visual_len].base == '\b')
+	      visual_len++;
 	    break;
 	  case GRUB_BIDI_TYPE_R:
 	  case GRUB_BIDI_TYPE_AL:
Signature · 1 line
2.29.3
#3 lore raw
Quoted 14 lines · Egor Ignatov

This patch fixes a bug when backspace key does not work in the username login prompt. It allows backspace characters in the BIDI visual line. Thus grub_gfxterm_putchar receives '\b' chars that were previously ignored.

---

Quoted 1 line

Did you test this patch with other BIDI type BN characters [1]? I am not

You are right, I added a check to handle only backspace characters

Quoted 2 lines

convinced it works with them as expected. I think earlier version of your patch was more promising...

Quoted 6 lines

Earlier versions of my patch included workaround for special case when the password is longer than one line. This scenario is not very realistic and I dont think it's worth complicating the codebase.

Thank you for your response.
Let me know if you have any concerns about this version.

Did you test your patch outside of username login prompt, e.g. CLI or menu entry editing? I am afraid your patch breaks at least these cases.

Daniel

Quoted 18 lines

Egor

 grub-core/normal/charset.c | 2 ++
 1 file changed, 2 insertions(+)
grub-core/normal/charset.c +2 -0
index 4dfcc3107..8e7add1f8 100644
@@ -931,6 +931,8 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
 	    pop_stack ();
 	    break;
 	  case GRUB_BIDI_TYPE_BN:
+	    if (visual[visual_len].base == '\b')
+	      visual_len++;
 	    break;
 	  case GRUB_BIDI_TYPE_R:
 	  case GRUB_BIDI_TYPE_AL:
#4 lore raw

Indeed I tested it with both CLI and menu entry editing and it works fine.

Thank you for taking the time to answer me.

PS Sorry if you received this message more than once.

Egor

#5 lore raw
In reply to Daniel Kiper
Quoted 4 lines · Daniel Kiper

Did you test your patch outside of username login prompt, e.g. CLI or menu entry editing? I am afraid your patch breaks at least these cases.

Daniel

Indeed I tested it with both CLI and menu entry editing and it works fine.

Thank you for taking the time to answer me.

Egor