georgemandis / konami-js

Adding the Konami Code easter egg to your projects since 2009! Compatible with gestures on smartphones and tablets as well. Compatible with all front-end frameworks and vanilla JavaScript
http://konamijs.mand.is/
MIT License
959 stars 122 forks source link

Touch input is not properly validated #30

Closed BenBergman closed 7 years ago

BenBergman commented 7 years ago

With the current code setup the user is able to have any gestures or taps present between the expected pattern elements and it will still execute correctly. For example, the following sequence will trigger the easter egg:

UP, UP, LEFT, LEFT, LEFT, LEFT, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, TAP, TAP

This could become a problem for pages that demand a lot of user interaction. Extended use of a page is likely to cause accidental triggering of the easter egg.

georgemandis commented 7 years ago

Good catch! Do you a have a pull request to fix it? I could review and make one but probably won't have time for a while.

BenBergman commented 7 years ago

I didn't have a chance to make a PR yet, but hopefully I'll have some time later this week.

BenBergman commented 7 years ago

I submitted a PR for this fix. Let me know if there is anything I should be doing to improve the PR.

georgemandis commented 7 years ago

Thanks! It seems fine, but I want to review it properly before merging in case I thought thoughts or suggestions. I just haven't had time, but should this weekend.