geth console special character/encoding problem #16286
Description
System information
Geth version: 1.7.2
OS & Version: Windows 10
Commit hash : release version downloaded by Mist (1db4ecd)
Expected behaviour
Copy pasting text into the geth console should leave the copied text unmodified and should not strip any characters.
Actual behaviour
Special characters (non-ascii) will be ignored/stripped by the geth console (it seems that this has to do with certain keyboard languages, but it works outside of the geth console) and this could result that passwords are set incorrectly. Even unlocking accounts with passwords including special characters might fail even if it shouldn't, see also ethereum/mist#3513 (comment) (search for "Let's talk about problem number 2:" within that post to fast forward to problem number 2 within that post)
Steps to reproduce the behaviour
- this was tested/confirmed under windows, but it could be that it has nothing to do with the OS (but the main reason could be the differences between certain keyboard languages)
- download/run geth (it seems that a lot/all versions are affected, but this needs to be confirmed/tested)
- set your keyboard language to e.g. English US, my default one (I also tested with German keyboard language)
- run "geth console" (without quotes)
- try to paste non-ASCII characters into the console or password prompt (e.g. the character with hex value 0xd3, i.e. Ó)
- the special characters will be ignored, which could be very dangerous because passwords might be set incorrectly and unlocking (for instance if the user just wants to see if the password is correct) might fail even if the password specified was correct
Note: I want to emphasize that the copy pasting only fails to work within geth, other tools and the same terminal (cmd) are able to get the whole input including special characters
Confirmation video (also see screenshots from ethereum/mist#3513 (comment)); this is a screen record to show what is happening:
Note: before I started geth.exe the copy pasting of all characters worked (even with my default English US keyboard layout), but it failed within the geth console... it suddently started working when changing to the English United States International keyboard layout... it seems to be geth related because it works outside geth with each and every keyboard layout.
It is needless to say that this same behaviour can be observed with any other geth commands and also with the password prompts (which is very dangerous! and the main reason that I've discovered this problem, see ethereum/mist#3513) etc. I decided to paste the character as a command (or let's say directly within the geth console, without using the password prompt etc) because it makes it more clear what is going on because this way we can see which characters are actually pasted and which ones are ignored
What is the effect of this problem:
- the user could unintentionally set a password that s/he doesn't want to set (personal.newAccount ()), the password could be very different depending on how many special characters s/he used, it could even be empty in the worse case even if the user wanted to set a very difficult password with many special characters
- the user can't unlock this newly created keystore files with the correct password (if it includes special characters) whenever s/he tries to use 3rd party tools (which accept the special chars)
- the user might not be able to unlock keyfiles generated by 3rd party tools (if they accepted the special characters but geth fails to accept them)
- other commands (besides the password cmd) might be affected the same way and could also lead to strange/unintended outcomes
.... etc
CC: @evertonfraga, @karalabe, @holiman