From 787713c7dffc657460c3c38dc35a367e4afcf80c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 2 Apr 2016 22:27:58 +0300 Subject: [PATCH] Fix: convert unicode icon URLs to utf-8 --- Writers/bkmk_wflad.py | 5 ++++- Writers/bkmk_whtml.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Writers/bkmk_wflad.py b/Writers/bkmk_wflad.py index 189177f..999872b 100644 --- a/Writers/bkmk_wflad.py +++ b/Writers/bkmk_wflad.py @@ -53,7 +53,10 @@ Comment: %s""" % (level+1, b.name, b.href, strftime(b.add_date), strftime(b.last ("real_title", "RealTitle"), ("test_time", "TestTime"), ("icon_href", "IconURI"), ("icon", "Icon"), ("charset", "Charset")): if hasattr(b, attr_name): - self.outfile.write("\n%s: %s" % (attr_out, getattr(b, attr_name))) + value = getattr(b, attr_name) + if isinstance(value, unicode): + value = value.encode('utf-8') + self.outfile.write("\n%s: %s" % (attr_out, value)) if hasattr(b, "last_tested"): self.outfile.write("\n%s: %s" % ("LastTested", strftime(getattr(b, "last_tested")))) diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index caf3747..707b52a 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -51,7 +51,11 @@ class writer_html(Writer): self.outfile.write(' LAST_MODIFIED="%s"' % b.last_modified) if BKMK_FORMAT == "MOZILLA": if b.keyword: self.outfile.write(' SHORTCUTURL="%s"' % b.keyword) - if b.icon_href: self.outfile.write(' ICON_URI="%s"' % b.icon_href) + if b.icon_href: + value = b.icon_href + if isinstance(value, unicode): + value = value.encode('utf-8') + self.outfile.write(' ICON_URI="%s"' % value) if b.icon: self.outfile.write(' ICON="%s"' % b.icon) if b.charset: self.outfile.write(' LAST_CHARSET="%s"' % b.charset) self.outfile.write('>%s\n' % quote_title(b.name)) -- 2.39.5