]> git.phdru.name Git - bookmarks_db.git/commitdiff
Quote title for Mozilla (including apostrophe).
authorOleg Broytman <phd@phdru.name>
Sun, 14 Oct 2007 10:44:23 +0000 (10:44 +0000)
committerOleg Broytman <phd@phdru.name>
Sun, 14 Oct 2007 10:44:23 +0000 (10:44 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@97 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Writers/bkmk_whtml.py
bkmk_objects.py
check_title.py

index 7e652d2e7dc5f84f4300f9aaf3298a69667454ae..88889178611a81bb6436fdfded50ee3c2fcbc422 100644 (file)
@@ -4,9 +4,7 @@
    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):
@@ -18,8 +16,6 @@ def dump_comment(comment):
 
 ind_s = " "*4
 
-from bkmk_objects import Writer
-
 class writer_html(Writer):
    filename = "bookmarks.html"
 
@@ -30,13 +26,13 @@ class writer_html(Writer):
    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):
@@ -48,7 +44,7 @@ class writer_html(Writer):
          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):
index 344312ca0f91b9d22a7481612d0868fc23a389d0..345ef3a34cdfc40c652b274d99deb2753414e4be 100644 (file)
@@ -4,6 +4,9 @@
    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
@@ -166,3 +169,9 @@ def break_tree(linear):
 
    for object in linear:
       del object.parent
+
+
+def quote_title(title):
+   if BKMK_FORMAT == "MOZILLA":
+      title = cgi.escape(title, 1).replace("'", "&#39;")
+   return title
index 802212052032e436316ac09692a14a8db3737fd4..fee4c310e298b02edcf7e8fa9f8eb7fb304a3bb1 100755 (executable)
@@ -2,11 +2,11 @@
 """
    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():
@@ -24,7 +24,7 @@ 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")
@@ -39,7 +39,6 @@ def run():
       sys.stdout.flush()
 
    root_folder = storage.load()
-   from bkmk_objects import make_linear
    make_linear(root_folder)
    objects = len(root_folder.linear)
 
@@ -55,10 +54,11 @@ def run():
             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