Written by BroytMann. Copyright (C) 2000-2007 PhiloSoft Design
 """
 
-
-import os
-BKMK_FORMAT = os.environ.has_key("BKMK_FORMAT")
+from bkmk_objects import Writer, BKMK_FORMAT, quote_title
 
 
 def dump_comment(comment):
 
 ind_s = " "*4
 
-from bkmk_objects import Writer
-
 class writer_html(Writer):
    filename = "bookmarks.html"
 
    def root_folder(self, f):
       self.outfile.write("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n")
       self.outfile.write(f.header + "\n")
-      self.outfile.write('<H1>%s</H1>\n\n' % f.name)
+      self.outfile.write('<H1>%s</H1>\n\n' % quote_title(f.name))
       self._folder(f, 0)
 
    def start_folder(self, f, level):
       self.outfile.write(ind_s*level + '<DT><H3 ADD_DATE="%s"' % f.add_date)
       if (BKMK_FORMAT == "MOZILLA") and f.last_modified: self.outfile.write(' LAST_MODIFIED="%s"' % f.last_modified)
-      self.outfile.write('>%s</H3>\n' % f.name)
+      self.outfile.write('>%s</H3>\n' % quote_title(f.name))
       self._folder(f, level)
 
    def end_folder(self, f, level):
          if b.keyword: self.outfile.write(' SHORTCUTURL="%s"' % b.keyword)
          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</A>\n' % b.name)
+      self.outfile.write('>%s</A>\n' % quote_title(b.name))
       if b.comment: self.outfile.write('<DD>%s\n' % dump_comment(b.comment))
 
    def ruler(self, r, level):
 
    Written by Oleg BroytMann. Copyright (C) 2000-2007 PhiloSoft Design.
 """
 
+import os, cgi
+BKMK_FORMAT = os.environ.get("BKMK_FORMAT", '')
+
 
 class Folder(list):
    isFolder = 1
 
    for object in linear:
       del object.parent
+
+
+def quote_title(title):
+   if BKMK_FORMAT == "MOZILLA":
+      title = cgi.escape(title, 1).replace("'", "'")
+   return title
 
 """
    Check and show URLs in the bookmarks database where name <> real title
 
-   Written by BroytMann, Jul 2002 - Aug 2002. Copyright (C) 2002 PhiloSoft Design
+   Written by BroytMann. Copyright (C) 2002-2007 PhiloSoft Design.
 """
 
-
 import sys
+from bkmk_objects import make_linear, quote_title
 
 
 def run():
       pass
 
    if report_stats:
-      print "BroytMann check_title, Copyright (C) 2002 PhiloSoft Design"
+      print "BroytMann check_title, Copyright (C) 2002-2007 PhiloSoft Design"
 
    if args:
       sys.stderr.write("check_title: too many arguments\n")
       sys.stdout.flush()
 
    root_folder = storage.load()
-   from bkmk_objects import make_linear
    make_linear(root_folder)
    objects = len(root_folder.linear)
 
             continue
 
          if hasattr(object, "real_title"):
-            if object.name <> object.real_title:
+            quoted_title = quote_title(object.real_title)
+            if object.name <> quoted_title:
                print object.href
                print object.name
-               print object.real_title
+               print quoted_title
                print
          else:
             print object.href