]> git.phdru.name Git - bookmarks_db.git/blobdiff - bkmk_objects.py
Feat(robots): Align "Content-Type"
[bookmarks_db.git] / bkmk_objects.py
index 4850261ef529c854708b5eb0437323720ed9d41e..741567039d7763077e1255ef162e6f09bb498e28 100644 (file)
@@ -85,7 +85,7 @@ class Bookmark(object):
                 href += ':' + quote(password)
             href += '@'
         if host:
-            href += host.decode(parser_charset or 'utf-8').encode('idna')
+            href += host.encode('idna').decode('ascii')
             if port:
                 href += ':%d' % port
         if path:
@@ -228,10 +228,15 @@ def quote_title(title):
 
 def unquote_title(title):
     if BKMK_FORMAT == "MOZILLA":
-        from HTMLParser import HTMLParser
-        title = HTMLParser().unescape(
-            title.replace("&", '&').decode('utf-8'))
-        title = title.encode('utf-8').replace("'", "'")
+        try:
+            from HTMLParser import HTMLParser
+        except ImportError:
+            from html import unescape
+        else:
+            unescape = HTMLParser().unescape
+        title = unescape(
+            title.replace("&", '&'))
+        title = title.replace("'", "'")
     return title