promisefeni / reallysimplehistory

Automatically exported from code.google.com/p/reallysimplehistory
Other
0 stars 0 forks source link

The call to this.storageField.focus() in Opera can inject random user input into the javascript to be eval'd #49

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Steps to reproduce the problem?
1. register an onkeydown event that modifies the history when fired (eg:
pressing 'n' fetches new item and adds n item to the history
2. Should see an error in Opera because it can't eval the json due to the
'n' that you pressed appearing before the '{'

Using version 0.6FINAL

I haven't tried to boil this down to a simple use case yet so there is a
chance that the problem is specific to my use, not sure.

But in general here's the situation.  I'm using RSH for http://markmail.org
and it's working fantastic in almost every way.  After executing a search
on the site you can navigate through the results by just hitting the 'n'
key.  In Opera (9.25) doing this produces an error.  In the error message
you can see that the keys that have been pressed (the n's) show up in the
JSON to be parsed.  An example of this error message is:
(nn{"DhtmlHistory_pageLoaded":true}).

After some digging, my guess is that this problem is showing up because of
the this.storageField.focus(); call on line 555.  Because focus is being
set on the textarea, it also captures the keyboard input.  I haven't dug
into things enough to really put together a good solution, but as a hack
I'm removing everything before the first '{' in the serializedHashTable
before the call to fromJSON().  I put the hack after line 643 and it looks
like:

serializedHashTable =
serializedHashTable.substring(serializedHashTable.indexOf("{"));

On the surface the hack seems to be working, unsure about any side effects.
 Let me know if you need a more straightforward test case or have any other
general questions.

--Ryan

Original issue reported on code.google.com by isubi...@gmail.com on 13 Feb 2008 at 7:25