Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Unrecognized characters in search input #16

Closed
samupl opened this issue Dec 19, 2017 · 1 comment
Closed

Unrecognized characters in search input #16

samupl opened this issue Dec 19, 2017 · 1 comment

Comments

@samupl
Copy link

samupl commented Dec 19, 2017

A bug in handling input from the user in the search makes "weird" unicode characters to appear.

Steps to reproduce

There are two methods of triggering this bug that I know of

Method 1 (works in multiple choice and single choice)

  • Click on the select (you now should be able to type & the dropdown appears)
  • Press Return (the first option should be selected)
  • Type Uppercase "E" by holding Shift + E

A "�" character appears in the input.

Method 2

  • Click on the select (you now should be able to type & the dropdown appears)
  • Hold Ctrl and click on the input again, release Ctrl after click

A "�" character appears in the input.

Code description & solution

The bug is triggered in the mainClick() method. Every keyCode of every event that goes into this method gets converted to a string by String.fromCharCode() and put into the input, without verification.

Some keyup and keydown events, such as arrows, key-combos and special non-printable characters can be there as well. Fortunatelly, KeyboardEvent class contains a .charCode, that when used on onkeydown or onkeyup events returns "0".

I've opened up a PR that fixes this issue: #15

@samupl
Copy link
Author

samupl commented Dec 21, 2017

Merged and fixed by #15

@samupl samupl closed this as completed Dec 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant