aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/data/uzbl/scripts/uzbl_tabbed.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/examples/data/uzbl/scripts/uzbl_tabbed.py b/examples/data/uzbl/scripts/uzbl_tabbed.py
index bf5ee97..9de6fba 100755
--- a/examples/data/uzbl/scripts/uzbl_tabbed.py
+++ b/examples/data/uzbl/scripts/uzbl_tabbed.py
@@ -34,6 +34,9 @@
# Contributor(s):
# mxey <mxey@ghosthacking.net>
# uzbl_config path now honors XDG_CONFIG_HOME if it exists.
+#
+# Romain Bignon <romain@peerfuse.org>
+# Fix for session restoration code.
# Configuration:
@@ -280,18 +283,6 @@ def readconfig(uzbl_config, config):
config[key] = os.path.expandvars(config[key])
-def rmkdir(path):
- '''Recursively make directories.
- I.e. `mkdir -p /some/nonexistant/path/`'''
-
- path, sep = os.path.realpath(path), os.path.sep
- dirs = path.split(sep)
- for i in range(2,len(dirs)+1):
- dir = os.path.join(sep,sep.join(dirs[:i]))
- if not os.path.exists(dir):
- os.mkdir(dir)
-
-
def counter():
'''To infinity and beyond!'''
@@ -301,6 +292,14 @@ def counter():
yield i
+def escape(s):
+ '''Replaces html markup in tab titles that screw around with pango.'''
+
+ for (split, glue) in [('&','&amp;'), ('<', '&lt;'), ('>', '&gt;')]:
+ s = s.replace(split, glue)
+ return s
+
+
def gen_endmarker():
'''Generates a random md5 for socket message-termination endmarkers.'''
@@ -544,7 +543,8 @@ class UzblTabbed:
else:
basedir = os.path.dirname(self.fifo_socket)
if not os.path.exists(basedir):
- rmkdir(basedir)
+ os.makedirs(basedir)
+
os.mkfifo(self.fifo_socket)
print "Listening on %s" % self.fifo_socket
@@ -984,7 +984,8 @@ class UzblTabbed:
(tabc, textc) = style
if tab_titles:
- pango += tab_format % (tabc, index, textc, tabtitle)
+ pango += tab_format % (tabc, index, textc,\
+ escape(tabtitle))
else:
pango += tab_format % (tabc, textc, index)
@@ -1020,8 +1021,7 @@ class UzblTabbed:
if not os.path.isfile(session_file):
dirname = os.path.dirname(session_file)
if not os.path.isdir(dirname):
- # Recursive mkdir not rmdir.
- rmkdir(dirname)
+ os.makedirs(dirname)
sessionstr = '\n'.join(self._tabsuris)
h = open(session_file, 'w')
@@ -1064,7 +1064,7 @@ if __name__ == "__main__":
uzbl.new_tab(line, False)
if not len(urls):
- self.new_tab()
+ uzbl.new_tab()
else:
uzbl.new_tab()