]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/parse_html.py
Do not even open non-image files; report the content type of a non-image file.
[bookmarks_db.git] / Robots / parse_html.py
index 6ec63369065035ca61308d3ad5cd65738dabd554..b30c66458eaa32960b5badce9bc849a2082213d7 100755 (executable)
@@ -5,20 +5,12 @@
    Written by BroytMann. Copyright (C) 1997-2007 PhiloSoft Design
 """
 
+import codecs
 
-import sys
-current_charset = sys.getdefaultencoding()
-if current_charset == "ascii":
-   try:
-      import locale
-   except ImportError:
-      pass
-   else:
-      current_charset = locale.getpreferredencoding()
-current_charset = current_charset.replace("windows-", "cp").lower()
+from m_lib.defenc import default_encoding
+current_charset = default_encoding.replace("windows-", "cp")
 DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic
 
-
 from HTMLParser import HTMLParseError
 from m_lib.net.www.html import HTMLParser as _HTMLParser
 
@@ -79,15 +71,13 @@ class HTMLParser(_HTMLParser):
       for attrname, value in attrs:
          if value:
             value = value.strip().lower()
-            if (attrname == 'rel') and (value in ('icon', 'shortcut icon')):
+            if (attrname == 'rel') and (value.lower() in ('icon', 'shortcut icon')):
                has_icon = True
             elif attrname == 'href':
                href = value
 
       if has_icon:
          self.icon = href
-      else:
-         self.icon = None
 
 
 import re