From 789d114c213bb9468c4711180d996c3a1b39ad6c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 14 Oct 2007 10:44:23 +0000 Subject: [PATCH] Quote title for Mozilla (including apostrophe). git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@97 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Writers/bkmk_whtml.py | 12 ++++-------- bkmk_objects.py | 9 +++++++++ check_title.py | 12 ++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index 7e652d2..8888917 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -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("\n") self.outfile.write(f.header + "\n") - self.outfile.write('

%s

\n\n' % f.name) + self.outfile.write('

%s

\n\n' % quote_title(f.name)) self._folder(f, 0) def start_folder(self, f, level): self.outfile.write(ind_s*level + '

%s

\n' % f.name) + self.outfile.write('>%s\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\n' % b.name) + self.outfile.write('>%s\n' % quote_title(b.name)) if b.comment: self.outfile.write('
%s\n' % dump_comment(b.comment)) def ruler(self, r, level): diff --git a/bkmk_objects.py b/bkmk_objects.py index 344312c..345ef3a 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -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("'", "'") + return title diff --git a/check_title.py b/check_title.py index 8022120..fee4c31 100755 --- a/check_title.py +++ b/check_title.py @@ -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 -- 2.39.2