Page MenuHome GnuPG

curses: dialog broken with wide characters
Closed, ResolvedPublic


If the description or the prompt contains non-ASCII characters, the dialog is broken. Looks like the dialog width is not correctly calculated. For example, the following commands:

$ ./curses/pinentry-curses
OK Pleased to meet you
setdesc 中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文
setprompt 中文中文中文中文中文

Generates such a dialog:

│ 中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文
│                                                     │
│ 中文中文中文中文中文 ________________________________________
│                                                     │
│       <OK>                             <Cancel>     │

I gave it a try to fix the issue and got a patch (attached below). For the description it looks good:

│ 中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文 │
│                                                              │
│ 中文中文中文中文中文 _________________________________________________
│                                                              │
│         <OK>                                  <Cancel>       │

But the dialog is still broken with non-ASCII prompts.



Event Timeline

chyen created this object in space S1 Public.

Well in my browser (Firefox) the dialogs are not rendered correctly. Here are the two dialogs in the terminal:

werner triaged this task as Normal priority.Jul 1 2019, 9:59 PM

I pushed the change to master.
Please test.

Thanks for the update! With git-master, the toy example above works fine. However, pinentry-curses seems to hang with real commands from gpg. Here is an example:

$ ./curses/pinentry-curses 
OK Pleased to meet you
SETDESC 請輸入密語來解鎖 OpenPGP 私鑰:%0A%22Chih-Hsuan Yen <>%22%0A3072 位元長的 DSA 金鑰, ID F98EF2A7B0A098AE,%0A建立於 2018-04-25 (主要金鑰 ID 3FDDD575826C5C30).%0A

(CPU usage of ./curses/pinentry-curses goes > 90%)

My terminal info:

$ stty size
36 146

Thanks for the further fix! With that only a minor hiccup remains:

A segment in the left border is not drawn.

Thanks for further testing.
I realized that it's not the left border drawing problem in fact, but the newline should be between the description and passphrase line.
I'm going to fix this.

BTW, I envy somehow that you have good concise words in Chinese for technical terms of cryptography. Even non-native speaker like me can understand them.

In Japanese, by easier normal words, it is difficult to distinguish between key and lock, and the concept of keyring is not popular, while people can understand when given good explanations.

I pushed the fix. Thanks for your cooperation.

Thanks for all the fixes! I can confirm commit dad35d65f05eb1c15589a7e4755dcae6aed2d6cf works just fine on all my machines (Linux & macOS).

BTW, I envy somehow that you have good concise words in Chinese for technical terms of cryptography.

Words like 金鑰 or 私鑰 are all newly created specifically for translating cryptographical terms. I guess those who speaking Japanese can do something similar.

That reminds me that there are two different usages for the term 密鑰:

  • Refer to private keys
  • Refer to general keys, either public or private

Sometimes it's easier to create terms than to keep the same usage everywhere :)