[kupfer] plugin.firefox3_support: Workaround Firefox 3.5's JSON writer



commit 1a1ea4f0bc5a7a0875635b18eddf3d5900111532
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Oct 22 14:57:41 2009 +0200

    plugin.firefox3_support: Workaround Firefox 3.5's JSON writer
    
    Firefox 3.5 writes bookmarks with a trailing comma in the JSON, which
    none of our two supported JSON parsers accept. We work around this
    issue by removing(!) a comma at index "-3" in the JSON content.

 kupfer/plugin/firefox3_support.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/firefox3_support.py b/kupfer/plugin/firefox3_support.py
index 64789f4..9303f48 100644
--- a/kupfer/plugin/firefox3_support.py
+++ b/kupfer/plugin/firefox3_support.py
@@ -27,6 +27,10 @@ def get_bookmarks(bookmarks_file):
 
 	with open(bookmarks_file) as f:
 		content = f.read().decode("UTF-8")
+		# HACK: Firefox' JSON writer leaves a trailing comma
+		# HACK: at the end of the array, which no parser accepts
+		if content.endswith(u"}]},]}"):
+			content = content[:-6] + u"}]}]}"
 		root = json_decoder(content)
 
 	catalogs = []



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]