Comment 2 for bug 504975

Revision history for this message
X (u78qir8a9-deactivatedaccount) wrote : Re: [Bug 504975] Re: Kupfer reads default Firefox bookmarks

2010/1/9, Andrew Holmes <email address hidden>:
> Yes, I think you're probably right, but my error output is a little
> different:
>
> So I assume this is a bug in a python module? Should I/we file a bug
> upstream to have this fixed or is the bookmarks.html workaround the best fix
> right now?
>
> Regards,
> Andy

I really think Firefox is outputting JSON that most libraries reject
as invalid. It commonly uses trailing commas or unterminated array
[...] or dict {..} objects.

See for example: http://code.google.com/p/simplejson/issues/detail?id=44

Here is a comparison of Python JSON modules and their behavior on
common invalid JSON:

http://blog.hill-street.net/?p=7 (Unavailable.. google cache link below)
http://74.125.77.132/search?q=cache:kOIOawEQNjIJ:blog.hill-street.net/%3Fp%3D7+python+json+%22Expecting+object%22&hl=en&strip=1

The trailing comma in array is rejected by 4 out of 6 listed modules.
Kupfer uses 'cjson' (column 1 in the table, see above link) if
available, then tries 'json' (almost the same as 'simplejson', column
3)

Workaround 0

Use bookmarks.html. We could output an error message (better, in the
future, an error dialog?) to instruct the user about this.

Workaround 1

So it might be possible to test out a Python json module that works
with Firefox' output habits. It must be tested out, and then Kupfer
can support only that module for firefox bookmarks. One module is
included with Python 2.6's standard library, called 'json'; it fails
to parse this output. The other Kupfer-supported alternative 'cjson'
likewise.

Workaround 2

Parse successively older .json files. There is usually five of them,
and one of them might work.