Kevin Vance - Firefox 2.0 crashed when I clicked on a link to a story at…

Entries | Archive | Friends | Friends' Friends | User Info

05:31 am

Wednesday, November 15th, 2006
Previous Entry Share Next Entry
Firefox 2.0 crashed when I clicked on a link to a story at It dutifully saved my session to be recovered later. Unfortunately, some bug (probably in the beta flash 9 plugin) causes the recovery to crash at the same place. All seems lost, right? NO. Because Firefox actually stored the session in a SANE FORMAT.

Just load up your trusty python shell and:

>>> import demjson
>>> store = file('sessionstore.js').read()
>>> session = demjson.decode(store.strip()[1:-1])
>>> for w in session['windows']:
...     for t in w['tabs']:
...         for e in t['entries']:
...             if '' in e['url']:
...                 w['tabs'].remove(t)
>>> store = demjson.encode(session)
>>> file('sessionstore.js', 'w').write('(%s)' % store)

Et voila! Session restored, minus one theonion tab. Easy, right?

Almost. First, it puts parenthesis around the whole thing, which no python JSON parser understood. That's trivial to work around. Then, it used bare identifiers starting with '_' in objects, which no python JSON parser understood. It was a one-line fix to demjson.

Imagine how cool it would have been if any of the python JSON modules had been up to scratch though :P
Link )Reply )

From: ext_70670
2007-11-20 10:22 am (UTC)

sessionstore.js isn't *quite* JSON-compatible


I tried to use demjson and a couple of other python json parsers to parse my FF2.0 sessionstore.js files but they failed to do so.

After investigating further and talking on Moz #developers it seems like the format isn't strictly JSON-compatible. The main issue seems to be the file uses constructions of the following style:


And the parser barfs on the "#1=" (even if you change the demjson code to accept "#" as valid).

So, I think the upshot is that a) the file format may eventually become JSON-compatible, b) You might be able to get certain instances of the file being in a JSON-compatible format due to the content in them, c) but equally, it's possible to find instances of the file that aren't JSON-compatible. (Like mine... :-( )

Just wanted to add this comment to save others potentially spending time fruitlessly...

(Reply) (Thread)