From bf33a2b30a69c7603db98f16542dd90a61e9c056 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 23 Nov 2009 11:24:10 +0000 Subject: Fix security holes * Please be careful when using eval, you rarely need it. * There might be more issues, I haven't checked any of the bigger python scripts, plugins, or the C code. Signed-off-by: Andy Spencer --- examples/data/uzbl/scripts/clipboard.sh | 2 +- examples/data/uzbl/scripts/download.sh | 4 ++-- examples/data/uzbl/scripts/scheme.py | 5 +++-- examples/data/uzbl/scripts/yank.sh | 7 ++----- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/data/uzbl/scripts/clipboard.sh b/examples/data/uzbl/scripts/clipboard.sh index 60567d3..d493774 100755 --- a/examples/data/uzbl/scripts/clipboard.sh +++ b/examples/data/uzbl/scripts/clipboard.sh @@ -11,7 +11,7 @@ url="$7" selection=`$clip -o` case $action in - "yank" ) echo -n "$url" | eval "$clip";; + "yank" ) echo -n "$url" | $clip;; "goto" ) echo "uri $selection" > "$fifo";; * ) echo "clipboard.sh: invalid action";; esac diff --git a/examples/data/uzbl/scripts/download.sh b/examples/data/uzbl/scripts/download.sh index c8eb6ba..55b0cb2 100755 --- a/examples/data/uzbl/scripts/download.sh +++ b/examples/data/uzbl/scripts/download.sh @@ -16,7 +16,7 @@ test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; } # only changes the dir for the $get sub process if echo "$url" | grep -E '.*\.torrent' >/dev/null; then - ( cd "$dest"; eval "$GET" "$url") + ( cd "$dest"; $GET "$url" ) else - ( cd "$dest"; eval "$GET" "$url") + ( cd "$dest"; $GET "$url" ) fi diff --git a/examples/data/uzbl/scripts/scheme.py b/examples/data/uzbl/scripts/scheme.py index 7286703..0916466 100755 --- a/examples/data/uzbl/scripts/scheme.py +++ b/examples/data/uzbl/scripts/scheme.py @@ -16,8 +16,9 @@ if __name__ == '__main__': uri = sys.argv[8] u = urlparse.urlparse(uri) if u.scheme == 'mailto': - detach_open(['xterm', '-e', 'mail %s' % u.path]) + detach_open(['xterm', '-e', 'mail', u.path]) elif u.scheme == 'xmpp': + # Someone check for safe arguments to gajim-remote detach_open(['gajim-remote', 'open_chat', uri]) elif u.scheme == 'git': - detach_open(['git', 'clone', uri], cwd=os.path.expanduser('~/src')) + detach_open(['git', 'clone', '--', uri], cwd=os.path.expanduser('~/src')) diff --git a/examples/data/uzbl/scripts/yank.sh b/examples/data/uzbl/scripts/yank.sh index 376b7e2..6785d64 100755 --- a/examples/data/uzbl/scripts/yank.sh +++ b/examples/data/uzbl/scripts/yank.sh @@ -9,9 +9,6 @@ clip=xclip which $clip &>/dev/null || exit 1 -[ "x$9" = xprimary -o "x$9" = xsecondary -o "x$9" = xclipboard ] || exit 2 +[ "$9" = primary -o "$9" = secondary -o "$9" = clipboard ] || exit 2 -value=`eval "echo -n \\${$8}"` # bash: value = ${!8} - -echo "echo -n '${value}' | $clip -selection $9" -echo -n "'${value}' | $clip -selection $9" +echo -n "$8" | $clip -selection $9 -- cgit v1.2.3 From 7512da2ab5d2fd4e844879876ba7bbe447275f4f Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 18:48:39 +0800 Subject: Put whitespace around modcmd. --- examples/data/uzbl/plugins/keycmd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/data/uzbl/plugins/keycmd.py b/examples/data/uzbl/plugins/keycmd.py index b1e8299..8a509bb 100644 --- a/examples/data/uzbl/plugins/keycmd.py +++ b/examples/data/uzbl/plugins/keycmd.py @@ -234,8 +234,11 @@ def update_event(uzbl, k, execute=True): if 'modcmd_updates' not in config or config['modcmd_updates'] == '1': new_modcmd = k.get_modcmd() - if not new_modcmd or new_modcmd == modcmd: - uzbl.set('modcmd', uzbl_escape(new_modcmd)) + if not new_modcmd: + uzbl.set('modcmd') + + elif new_modcmd == modcmd: + uzbl.set('modcmd', " %s " % uzbl_escape(new_modcmd)) if 'keycmd_events' in config and config['keycmd_events'] != '1': return -- cgit v1.2.3 From 0d0d5e42e4e94385e7fd16c4b7725e58b7985fa4 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 18:49:16 +0800 Subject: Remove redundant print in bind. --- examples/data/uzbl/plugins/bind.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py index 530cc80..5557aeb 100644 --- a/examples/data/uzbl/plugins/bind.py +++ b/examples/data/uzbl/plugins/bind.py @@ -259,7 +259,6 @@ def bind(uzbl, glob, handler, *args, **kargs): bind = Bind(glob, handler, *args, **kargs) binds.append(bind) - print bind uzbl.event('ADDED_BIND', bind) -- cgit v1.2.3 From 2c23115387a668eff89e7dc048f565a3971174e0 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 18:50:27 +0800 Subject: Fixed ':_' binding in the config. --- examples/config/uzbl/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 8abe554..5945985 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -121,7 +121,7 @@ set socket_dir = /tmp # With this command you can enter in any command at runtime when prefixed with # a colon. -@bind :_ = chain '%s' +@bind :_ = %s # Middle click # if clicked on a link open the link in a new uzbl window -- cgit v1.2.3 From 0e7d35e4512bf576a2bd3096c24905a711ab2666 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 18:51:33 +0800 Subject: Mode plugin cleanup & removed hardcoded KEY_PRESS action. --- examples/data/uzbl/plugins/mode.py | 43 +++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/examples/data/uzbl/plugins/mode.py b/examples/data/uzbl/plugins/mode.py index e7705a0..74e805a 100644 --- a/examples/data/uzbl/plugins/mode.py +++ b/examples/data/uzbl/plugins/mode.py @@ -7,7 +7,6 @@ UZBLS = {} DEFAULTS = { 'mode': '', - 'default': '', 'modes': { 'insert': { 'forward_keys': True, @@ -20,8 +19,8 @@ DEFAULTS = { 'modcmd_updates': True, 'indicator': 'C'}}} -_RE_FINDSPACES = re.compile("\s+") - +FINDSPACES = re.compile("\s+") +VALID_KEY = re.compile("^[\w_]+$").match def error(msg): sys.stderr.write("mode plugin: error: %s\n" % msg) @@ -55,24 +54,22 @@ def get_mode(uzbl): return get_mode_dict(uzbl)['mode'] -def key_press(uzbl, key): - if key != "Escape": - return - - set_mode(uzbl) - - def set_mode(uzbl, mode=None): mode_dict = get_mode_dict(uzbl) + config = uzbl.get_config() + if mode is None: - if not mode_dict['default']: - return error("no default mode to fallback on") + if 'default_mode' not in config: + return - mode = mode_dict['default'] + mode = config['default_mode'] + + if not VALID_KEY(mode): + raise KeyError("invalid mode name: %r" % mode) - config = uzbl.get_config() if 'mode' not in config or config['mode'] != mode: config['mode'] = mode + return mode_dict['mode'] = mode mode_config = get_mode_config(uzbl, mode) @@ -92,31 +89,30 @@ def set_mode(uzbl, mode=None): def config_changed(uzbl, key, value): + value = None if not value else value if key == 'default_mode': - mode_dict = get_mode_dict(uzbl) - mode_dict['default'] = value - if value and not mode_dict['mode']: + if not get_mode(uzbl): set_mode(uzbl, value) elif key == 'mode': - if not value: - value = None - set_mode(uzbl, value) def mode_config(uzbl, args): - split = map(unicode.strip, _RE_FINDSPACES.split(args.lstrip(), 1)) + split = map(unicode.strip, FINDSPACES.split(args.lstrip(), 1)) if len(split) != 2: - return error("invalid MODE_CONFIG syntax: %r" % args) + raise SyntaxError('invalid config syntax: %r' % args) mode, set = split split = map(unicode.strip, set.split('=', 1)) if len(split) != 2: - return error("invalid MODE_CONFIG set command: %r" % args) + raise SyntaxError('invalid set syntax: %r' % args) key, value = split + if not VALID_KEY(key): + raise KeyError('invalid config key: %r' % key) + mode_config = get_mode_config(uzbl, mode) mode_config[key] = value @@ -150,7 +146,6 @@ def init(uzbl): connects = {'CONFIG_CHANGED': config_changed, 'INSTANCE_EXIT': del_instance, 'INSTANCE_START': add_instance, - 'KEY_PRESS': key_press, 'MODE_CONFIG': mode_config, 'LOAD_START': load_reset, 'TOGGLE_MODES': toggle_modes} -- cgit v1.2.3 From 17fc947a49fd65adffd847628c4701e0bc10f965 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 18:54:02 +0800 Subject: Indent event printing & strip outgoing commands. --- examples/data/uzbl/scripts/uzbl-event-manager | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/data/uzbl/scripts/uzbl-event-manager b/examples/data/uzbl/scripts/uzbl-event-manager index 8f43836..0054ff6 100755 --- a/examples/data/uzbl/scripts/uzbl-event-manager +++ b/examples/data/uzbl/scripts/uzbl-event-manager @@ -343,6 +343,7 @@ class UzblInstance(object): self._parent = parent self._client_socket = client_socket + self.depth = 0 self.buffer = '' # Call the init() function in every plugin. Inside the init function @@ -397,12 +398,13 @@ class UzblInstance(object): def send(self, msg): '''Send a command to the uzbl instance via the socket file.''' + msg = msg.strip() if self._client_socket: - print '<-- %s' % msg + print '%s<-- %s' % (' ' * self.depth, msg) self._client_socket.send(("%s\n" % msg).encode('utf-8')) else: - print '!-- %s' % msg + print '%s!-- %s' % (' ' * self.depth, msg) def connect(self, event, handler, *args, **kargs): @@ -468,18 +470,22 @@ class UzblInstance(object): # Silence _printing_ of geo events while debugging. if event != "GEOMETRY_CHANGED": - print "--> %s %s %s" % (event, args, '' if not kargs else kargs) + print "%s--> %s %s %s" % (' ' * self.depth, event, args, + '' if not kargs else kargs) if event not in self._handlers: return for handler in self._handlers[event]: + self.depth += 1 try: self.exec_handler(handler, *args, **kargs) except: print_exc() + self.depth -= 1 + def close(self): '''Close the client socket and clean up.''' -- cgit v1.2.3 From f7eeee9955f99d4acbfc90c7dc00b50767a15e07 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 21:09:36 +0800 Subject: Fixed extreme security hole in scheme.py allowing arbitrary command execution on the users pc. --- examples/data/uzbl/scripts/scheme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/data/uzbl/scripts/scheme.py b/examples/data/uzbl/scripts/scheme.py index 7286703..a54476f 100755 --- a/examples/data/uzbl/scripts/scheme.py +++ b/examples/data/uzbl/scripts/scheme.py @@ -16,7 +16,7 @@ if __name__ == '__main__': uri = sys.argv[8] u = urlparse.urlparse(uri) if u.scheme == 'mailto': - detach_open(['xterm', '-e', 'mail %s' % u.path]) + detach_open(['xterm', '-e', 'mail %r' % u.path]) elif u.scheme == 'xmpp': detach_open(['gajim-remote', 'open_chat', uri]) elif u.scheme == 'git': -- cgit v1.2.3 From 46005a341732359013572564f299901838eb7c2b Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Tue, 24 Nov 2009 22:14:32 +0800 Subject: Revert stupid idea of using %@ instead of %s. --- examples/data/uzbl/plugins/on_event.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/data/uzbl/plugins/on_event.py b/examples/data/uzbl/plugins/on_event.py index 3dfc3fa..afee4e6 100644 --- a/examples/data/uzbl/plugins/on_event.py +++ b/examples/data/uzbl/plugins/on_event.py @@ -1,7 +1,7 @@ '''Plugin provides arbitrary binding of uzbl events to uzbl commands. Formatting options: - %@ = space separated string of the arguments + %s = space separated string of the arguments %1 = argument 1 %2 = argument 2 %n = argument n @@ -45,10 +45,10 @@ def get_on_events(uzbl): def expand(cmd, args): - '''Replaces "%@ %1 %2 %3..." with " ...".''' + '''Replaces "%s %1 %2 %3..." with " ...".''' - if '%@' in cmd: - cmd = cmd.replace('%@', ' '.join(map(unicode, args))) + if '%s' in cmd: + cmd = cmd.replace('%s', ' '.join(map(unicode, args))) for (index, arg) in enumerate(args): index += 1 -- cgit v1.2.3 From 2138add3e391bbc08b386fcfcb02ed6f4616248b Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 25 Nov 2009 07:17:35 +0800 Subject: Use js for conditional binding & fix \wiki bind. --- examples/config/uzbl/config | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 5945985..ed522cc 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -125,8 +125,10 @@ set socket_dir = /tmp # Middle click # if clicked on a link open the link in a new uzbl window -# otherwise open the selection in the current window -@bind = sh 'if [ "\@SELECTED_URI" ]; then uzbl-browser -u \@SELECTED_URI; else echo "uri $(xclip -o)" > $4; fi' +# otherwise open the selection in the current window1 +set load_from_xclip = sh 'echo "uri $(xclip -o)" > $4' +set open_new_window = sh 'uzbl-browser -u \@SELECTED_URI' +@bind = js if("\@SELECTED_URI") { Uzbl.run("\@open_new_window"); } else { Uzbl.run("\\\@load_from_xclip"); } @bind j = scroll vertical 20 @bind = scroll vertical 100% @@ -157,7 +159,7 @@ set socket_dir = /tmp @bind gh = uri http://www.uzbl.org # shortcut to set variables @bind s _ = set %s -@bind \wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go +@bind \\wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go @bind gg _ = uri http://www.google.com/search?q=%s # Enclose the executable in quotes if it has spaces. Any additional parameters you use will # appear AFTER the default parameters -- cgit v1.2.3 From 940435ccef2ac6c129b4d999cc4f1d6e210beb54 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 25 Nov 2009 09:06:57 +0800 Subject: Complete partials as variables when preceded with 'set '. --- examples/data/uzbl/plugins/completion.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/data/uzbl/plugins/completion.py b/examples/data/uzbl/plugins/completion.py index 2da42ba..ee42b1f 100644 --- a/examples/data/uzbl/plugins/completion.py +++ b/examples/data/uzbl/plugins/completion.py @@ -15,7 +15,7 @@ NONE, ONCE, LIST = range(3) DEFAULTS = {'completions': [], 'level': NONE, 'lock': False} # The reverse keyword finding re. -FIND_SEGMENT = re.compile("(\@[\w_]+|[\w_]+)$").findall +FIND_SEGMENT = re.compile("(\@[\w_]+|set[\s]+[\w_]+|[\w_]+)$").findall # Formats LIST_FORMAT = " %s " @@ -52,7 +52,11 @@ def get_incomplete_keyword(uzbl): keylet = uzbl.get_keylet() left_segment = keylet.keycmd[:keylet.cursor] - return (FIND_SEGMENT(left_segment) + ['',])[0].lstrip() + partial = (FIND_SEGMENT(left_segment) + ['',])[0].lstrip() + if partial.startswith('set '): + partial = '@%s' % partial[4:].lstrip() + + return partial def stop_completion(uzbl, *args): -- cgit v1.2.3 From c2d23b2fbbd8a930623efa907247ce1df5b8b4ec Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 25 Nov 2009 09:22:41 +0800 Subject: Set completions also complete the '='. --- examples/data/uzbl/plugins/completion.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/data/uzbl/plugins/completion.py b/examples/data/uzbl/plugins/completion.py index ee42b1f..cfdf901 100644 --- a/examples/data/uzbl/plugins/completion.py +++ b/examples/data/uzbl/plugins/completion.py @@ -54,9 +54,9 @@ def get_incomplete_keyword(uzbl): left_segment = keylet.keycmd[:keylet.cursor] partial = (FIND_SEGMENT(left_segment) + ['',])[0].lstrip() if partial.startswith('set '): - partial = '@%s' % partial[4:].lstrip() + return ('@%s' % partial[4:].lstrip(), True) - return partial + return (partial, False) def stop_completion(uzbl, *args): @@ -67,11 +67,16 @@ def stop_completion(uzbl, *args): uzbl.set('completion_list') -def complete_completion(uzbl, partial, hint): +def complete_completion(uzbl, partial, hint, set_completion=False): '''Inject the remaining porition of the keyword into the keycmd then stop the completioning.''' - remainder = "%s " % hint[len(partial):] + if set_completion: + remainder = "%s = " % hint[len(partial):] + + else: + remainder = "%s " % hint[len(partial):] + uzbl.inject_keycmd(remainder) stop_completion(uzbl) @@ -87,7 +92,7 @@ def update_completion_list(uzbl, *args): '''Checks if the user still has a partially completed keyword under his cursor then update the completion hints list.''' - partial = get_incomplete_keyword(uzbl) + partial = get_incomplete_keyword(uzbl)[0] if not partial: return stop_completion(uzbl) @@ -110,7 +115,7 @@ def start_completion(uzbl, *args): if d['lock']: return - partial = get_incomplete_keyword(uzbl) + (partial, set_completion) = get_incomplete_keyword(uzbl) if not partial: return stop_completion(uzbl) @@ -123,13 +128,13 @@ def start_completion(uzbl, *args): elif len(hints) == 1: d['lock'] = True - complete_completion(uzbl, partial, hints[0]) + complete_completion(uzbl, partial, hints[0], set_completion) d['lock'] = False return elif partial in hints: d['lock'] = True - complete_completion(uzbl, partial, partial) + complete_completion(uzbl, partial, partial, set_completion) d['lock'] = False return -- cgit v1.2.3 From c8c56da8799c25e787bcdcd1fdd7bdc33db6d204 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 25 Nov 2009 09:28:15 +0800 Subject: Show the completion list before completing when partial in hints list. --- examples/data/uzbl/plugins/completion.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/data/uzbl/plugins/completion.py b/examples/data/uzbl/plugins/completion.py index cfdf901..42e7e17 100644 --- a/examples/data/uzbl/plugins/completion.py +++ b/examples/data/uzbl/plugins/completion.py @@ -9,7 +9,7 @@ import re UZBLS = {} # Completion level -NONE, ONCE, LIST = range(3) +NONE, ONCE, LIST, COMPLETE = range(4) # Default instance dict. DEFAULTS = {'completions': [], 'level': NONE, 'lock': False} @@ -97,7 +97,7 @@ def update_completion_list(uzbl, *args): return stop_completion(uzbl) d = get_completion_dict(uzbl) - if d['level'] != LIST: + if d['level'] < LIST: return hints = [h for h in d['completions'] if h.startswith(partial)] @@ -119,7 +119,7 @@ def start_completion(uzbl, *args): if not partial: return stop_completion(uzbl) - if d['level'] < LIST: + if d['level'] < COMPLETE: d['level'] += 1 hints = [h for h in d['completions'] if h.startswith(partial)] @@ -132,7 +132,7 @@ def start_completion(uzbl, *args): d['lock'] = False return - elif partial in hints: + elif partial in hints and d['level'] == COMPLETE: d['lock'] = True complete_completion(uzbl, partial, partial, set_completion) d['lock'] = False -- cgit v1.2.3 From 59f8345ba294b00db7ccb0b7fd3cbbdda6c26252 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Wed, 25 Nov 2009 19:01:32 +0800 Subject: Forgot to clear the keycmd if no default value being set. --- examples/data/uzbl/plugins/bind.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py index 5557aeb..509363d 100644 --- a/examples/data/uzbl/plugins/bind.py +++ b/examples/data/uzbl/plugins/bind.py @@ -290,6 +290,9 @@ def set_stack_mode(uzbl, prompt): # Go through uzbl-core to expand potential @-variables uzbl.send('event SET_KEYCMD %s' % set) + else: + uzbl.clear_keycmd() + def clear_stack(uzbl, mode): bind_dict = get_bind_dict(uzbl) -- cgit v1.2.3 From 780caeed5ecbf3d0b3fda7ec87c471bf50d6c777 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Thu, 26 Nov 2009 23:15:35 +0800 Subject: Removed stack mode requirement for stacked bindings in bind plugin. --- examples/config/uzbl/config | 9 ----- examples/data/uzbl/plugins/bind.py | 70 ++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index ed522cc..62b5315 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -273,7 +273,6 @@ menu_link_add Print Link = print \@SELECTED_URI # Define some mode specific uzbl configurations. set command = @mode_config command set insert = @mode_config insert -set stack = @mode_config stack # Command mode config. @command keycmd_style = foreground="red" @@ -284,14 +283,6 @@ set stack = @mode_config stack @insert status_background = #303030 @insert mode_indicator = Ins -# Multi-stage-binding mode config. -@stack keycmd_events = 1 -@stack modcmd_updates = 1 -@stack keycmd_style = foreground="red" -@stack prompt_style = foreground="#888" weight="light" -@stack status_background = #202020 -@stack mode_indicator = Bnd - set default_mode = command # Mode bindings: diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py index 509363d..4976a80 100644 --- a/examples/data/uzbl/plugins/bind.py +++ b/examples/data/uzbl/plugins/bind.py @@ -17,6 +17,7 @@ __export__ = ['bind', 'del_bind', 'del_bind_by_glob', 'get_binds'] # Hold the bind dicts for each uzbl instance. UZBLS = {} +DEFAULTS = {'binds': [], 'depth': 0, 'stack': [], 'args': []} # Commonly used regular expressions. starts_with_mod = re.compile('^<([A-Z][A-Za-z0-9-_]*)>') @@ -50,8 +51,7 @@ def split_glob(glob): def add_instance(uzbl, *args): - UZBLS[uzbl] = {'binds': [], 'depth': 0, 'stack': [], - 'args': [], 'last_mode': ''} + UZBLS[uzbl] = dict(DEFAULTS) def del_instance(uzbl, *args): @@ -276,39 +276,50 @@ def parse_bind_event(uzbl, args): bind(uzbl, glob, command) -def set_stack_mode(uzbl, prompt): - prompt, set = prompt - if uzbl.get_mode() != 'stack': - uzbl.set_mode('stack') +def clear_stack(uzbl, mode): + '''Clear everything related to stacked binds.''' + + bind_dict = get_bind_dict(uzbl) + bind_dict['stack'] = [] + bind_dict['depth'] = 0 + bind_dict['args'] = [] + + uzbl.set('keycmd_prompt', '') + + +def stack_bind(uzbl, bind, args, depth): + '''Increment the stack depth in the bind dict, generate filtered bind + list for stack mode and set keycmd prompt.''' + + bind_dict = get_bind_dict(uzbl) + if bind_dict['depth'] != depth: + if bind not in bind_dict['stack']: + bind_dict['stack'].append(bind) + + return + + globalcmds = [cmd for cmd in bind_dict['binds'] if cmd.is_global] + bind_dict['stack'] = [bind,] + globalcmds + bind_dict['args'] += args + bind_dict['depth'] = depth + 1 + uzbl.send('event BIND_STACK_LEVEL %d' % bind_dict['depth']) + + (prompt, set) = bind.prompts[depth] if prompt: - prompt = "%s: " % prompt + uzbl.set('keycmd_prompt', '%s:' % prompt) - uzbl.set('keycmd_prompt', prompt) + else: + uzbl.set('keycmd_prompt') if set: - # Go through uzbl-core to expand potential @-variables uzbl.send('event SET_KEYCMD %s' % set) else: uzbl.clear_keycmd() -def clear_stack(uzbl, mode): - bind_dict = get_bind_dict(uzbl) - if mode != "stack" and bind_dict['last_mode'] == "stack": - uzbl.set('keycmd_prompt', '') - - if mode != "stack": - bind_dict = get_bind_dict(uzbl) - bind_dict['stack'] = [] - bind_dict['depth'] = 0 - bind_dict['args'] = [] - - bind_dict['last_mode'] = mode - - -def match_and_exec(uzbl, bind, depth, keylet, mod_event=False): +def match_and_exec(uzbl, bind, depth, keylet): bind_dict = get_bind_dict(uzbl) (on_exec, has_args, mod_cmd, glob, more) = bind[depth] @@ -338,16 +349,7 @@ def match_and_exec(uzbl, bind, depth, keylet, mod_event=False): return True elif more: - if bind_dict['depth'] == depth: - globalcmds = [cmd for cmd in bind_dict['binds'] if cmd.is_global] - bind_dict['stack'] = [bind,] + globalcmds - bind_dict['args'] += args - bind_dict['depth'] = depth + 1 - - elif bind not in bind_dict['stack']: - bind_dict['stack'].append(bind) - - set_stack_mode(uzbl, bind.prompts[depth]) + stack_bind(uzbl, bind, args, depth) return False args = bind_dict['args'] + args -- cgit v1.2.3 From 932d77bd50196a2c665e5d65de732b1349ed1925 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sat, 28 Nov 2009 15:35:58 +0800 Subject: Added modkey addition to keycmd plugin. We are now able to remove the hardcoded "+ -> " and "+ -> " modkey transformations from the key_press and key_release functions. --- examples/config/uzbl/config | 9 ++- examples/data/uzbl/plugins/keycmd.py | 127 ++++++++++++++++++++++++++++------- 2 files changed, 111 insertions(+), 25 deletions(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 62b5315..dc91e59 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -19,6 +19,8 @@ set progress = request PROGRESS_CONFIG set modmap = request MODMAP # request IGNORE_KEY set ignore_key = request IGNORE_KEY +# request MODKEY_ADDITION +set modkey_addition = request MODKEY_ADDITION set set_mode = set mode = set set_status = set status_message = @@ -108,15 +110,20 @@ set socket_dir = /tmp # === Key modmapping and ignoring ============================================ -#modmap from to +#modmap @modmap @modmap @modmap +#modkey_addition +@modkey_addition +@modkey_addition + #ignore_key @ignore_key @ignore_key + # === Keyboard & Mouse bindings ============================================== # With this command you can enter in any command at runtime when prefixed with diff --git a/examples/data/uzbl/plugins/keycmd.py b/examples/data/uzbl/plugins/keycmd.py index 8a509bb..4c88fd8 100644 --- a/examples/data/uzbl/plugins/keycmd.py +++ b/examples/data/uzbl/plugins/keycmd.py @@ -3,7 +3,7 @@ import re # Map these functions/variables in the plugins namespace to the uzbl object. __export__ = ['clear_keycmd', 'set_keycmd', 'set_cursor_pos', 'get_keylet', 'clear_current', 'clear_modcmd', 'add_modmap', 'add_key_ignore', - 'append_keycmd', 'inject_keycmd'] + 'append_keycmd', 'inject_keycmd', 'add_modkey_addition'] # Hold the keylets. UZBLS = {} @@ -42,6 +42,7 @@ class Keylet(object): self.modmaps = {} self.ignores = {} + self.additions = {} # Keylet string repr cache. self._repr_cache = None @@ -76,6 +77,25 @@ class Keylet(object): return key + def find_addition(self, modkey): + '''Key has just been pressed, check if this key + the held list + results in a modkey addition. Return that addition and remove all + modkeys that created it.''' + + already_added = self.held & set(self.additions.keys()) + for key in already_added: + if modkey in self.additions[key]: + return key + + modkeys = set(list(self.held) + [modkey,]) + for (key, value) in self.additions.items(): + if modkeys.issuperset(value): + self.held = modkeys ^ value + return key + + return modkey + + def key_ignored(self, key): '''Check if the given key is ignored by any ignore rules.''' @@ -107,7 +127,20 @@ class Keylet(object): def add_modmap(uzbl, key, map): - '''Add modmaps.''' + '''Add modmaps. + + Examples: + set modmap = request MODMAP + @modmap + @modmap + ... + + Then: + @bind = + @bind x = + ... + + ''' assert len(key) modmaps = get_keylet(uzbl).modmaps @@ -131,7 +164,14 @@ def modmap_parse(uzbl, map): def add_key_ignore(uzbl, glob): - '''Add an ignore definition.''' + '''Add an ignore definition. + + Examples: + set ignore_key = request IGNORE_KEY + @ignore_key + @ignore_key + ... + ''' assert len(glob) > 1 ignores = get_keylet(uzbl).ignores @@ -144,6 +184,45 @@ def add_key_ignore(uzbl, glob): uzbl.event('NEW_KEY_IGNORE', glob) +def add_modkey_addition(uzbl, modkeys, result): + '''Add a modkey addition definition. + + Examples: + set mod_addition = request MODKEY_ADDITION + @mod_addition + @mod_addition + @mod_addition + ... + + Then: + @bind = + @bind o = + ... + ''' + + additions = get_keylet(uzbl).additions + modkeys = set(modkeys) + + assert len(modkeys) and result and result not in modkeys + + for (existing_result, existing_modkeys) in additions.items(): + if existing_result != result: + assert modkeys != existing_modkeys + + additions[result] = modkeys + uzbl.event('NEW_MODKEY_ADDITION', modkeys, result) + + +def modkey_addition_parse(uzbl, modkeys): + '''Parse modkey addition definition.''' + + keys = filter(None, map(unicode.strip, modkeys.split(" "))) + keys = ['<%s>' % key.strip("<>") for key in keys if key.strip("<>")] + + assert len(keys) > 1 + add_modkey_addition(uzbl, keys[:-1], keys[-1]) + + def add_instance(uzbl, *args): '''Create the Keylet object for this uzbl instance.''' @@ -259,14 +338,23 @@ def inject_str(str, index, inj): return "%s%s%s" % (str[:index], inj, str[index:]) -def chevronate(key): - '''If a modkey isn't already chevronated then chevronate it. Ignore all - other keys.''' +def get_keylet_and_key(uzbl, key): + '''Return the keylet and apply any transformations to the key as defined + by the modmapping or modkey addition rules. Return None if the key is + ignored.''' + keylet = get_keylet(uzbl) + key = keylet.modmap_key(key) if len(key) == 1: - return key + return (keylet, key) + + modkey = "<%s>" % key.strip("<>") + modkey = keylet.find_addition(modkey) + + if keylet.key_ignored(modkey): + return (keylet, None) - return "<%s>" % key.strip("<>") + return (keylet, modkey) def key_press(uzbl, key): @@ -279,10 +367,8 @@ def key_press(uzbl, key): 5. If in modcmd mode the pressed key is added to the held keys list. 6. Keycmd is updated and events raised if anything is changed.''' - k = get_keylet(uzbl) - key = chevronate(k.modmap_key(key.strip())) - - if k.key_ignored(key): + (k, key) = get_keylet_and_key(uzbl, key.strip()) + if not key: return if key.lower() == '' and not k.held and k.keycmd: @@ -304,9 +390,6 @@ def key_press(uzbl, key): elif len(key) > 1: k.is_modcmd = True - if key == '' and '' in k.held: - k.held.remove('') - if key not in k.held: k.held.add(key) @@ -325,14 +408,9 @@ def key_release(uzbl, key): 3. Check if any modkey is held, if so set modcmd mode. 4. Update the keycmd uzbl variable if anything changed.''' - k = get_keylet(uzbl) - key = chevronate(k.modmap_key(key)) - - if key in ['', ''] and '' in k.held: - key = '' - - elif key in ['', ''] and '' in k.held: - key = '' + (k, key) = get_keylet_and_key(uzbl, key.strip()) + if not key: + return if key in k.held: if k.is_modcmd: @@ -464,6 +542,7 @@ def init(uzbl): 'MODMAP': modmap_parse, 'APPEND_KEYCMD': append_keycmd, 'INJECT_KEYCMD': inject_keycmd, - 'IGNORE_KEY': add_key_ignore} + 'IGNORE_KEY': add_key_ignore, + 'MODKEY_ADDITION': modkey_addition_parse} uzbl.connect_dict(connects) -- cgit v1.2.3 From e62c36c07d360e73543f864af69e97bd5d348e73 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sat, 28 Nov 2009 17:35:52 +0800 Subject: Remove typo. --- examples/config/uzbl/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 62b5315..9820fda 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -125,7 +125,7 @@ set socket_dir = /tmp # Middle click # if clicked on a link open the link in a new uzbl window -# otherwise open the selection in the current window1 +# otherwise open the selection in the current window set load_from_xclip = sh 'echo "uri $(xclip -o)" > $4' set open_new_window = sh 'uzbl-browser -u \@SELECTED_URI' @bind = js if("\@SELECTED_URI") { Uzbl.run("\@open_new_window"); } else { Uzbl.run("\\\@load_from_xclip"); } -- cgit v1.2.3 From 6a33e0043932fbb2ab36d8e2557c5758d1f7004b Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sun, 29 Nov 2009 12:24:29 +0800 Subject: Refactor mode plugin, remove load_reset function. --- examples/data/uzbl/plugins/mode.py | 116 +++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/examples/data/uzbl/plugins/mode.py b/examples/data/uzbl/plugins/mode.py index 74e805a..568abc1 100644 --- a/examples/data/uzbl/plugins/mode.py +++ b/examples/data/uzbl/plugins/mode.py @@ -1,7 +1,7 @@ import sys import re -__export__ = ['set_mode', 'get_mode'] +__export__ = ['set_mode', 'get_mode', 'set_mode_config', 'get_mode_config'] UZBLS = {} @@ -12,19 +12,16 @@ DEFAULTS = { 'forward_keys': True, 'keycmd_events': False, 'modcmd_updates': False, - 'indicator': 'I'}, + 'mode_indicator': 'I'}, 'command': { 'forward_keys': False, 'keycmd_events': True, 'modcmd_updates': True, - 'indicator': 'C'}}} + 'mode_indicator': 'C'}}} FINDSPACES = re.compile("\s+") VALID_KEY = re.compile("^[\w_]+$").match -def error(msg): - sys.stderr.write("mode plugin: error: %s\n" % msg) - def add_instance(uzbl, *args): UZBLS[uzbl] = dict(DEFAULTS) @@ -36,6 +33,8 @@ def del_instance(uzbl, *args): def get_mode_dict(uzbl): + '''Return the mode dict for an instance.''' + if uzbl not in UZBLS: add_instance(uzbl) @@ -43,6 +42,8 @@ def get_mode_dict(uzbl): def get_mode_config(uzbl, mode): + '''Return the mode config for a given mode.''' + modes = get_mode_dict(uzbl)['modes'] if mode not in modes: modes[mode] = {} @@ -54,26 +55,13 @@ def get_mode(uzbl): return get_mode_dict(uzbl)['mode'] -def set_mode(uzbl, mode=None): - mode_dict = get_mode_dict(uzbl) - config = uzbl.get_config() - - if mode is None: - if 'default_mode' not in config: - return - - mode = config['default_mode'] +def mode_changed(uzbl, mode): + '''The mode has just been changed, now set the per-mode config.''' - if not VALID_KEY(mode): - raise KeyError("invalid mode name: %r" % mode) - - if 'mode' not in config or config['mode'] != mode: - config['mode'] = mode - return + get_mode_dict(uzbl)['mode'] = mode - mode_dict['mode'] = mode + config = uzbl.get_config() mode_config = get_mode_config(uzbl, mode) - for (key, value) in mode_config.items(): if key not in config: config[key] = value @@ -84,11 +72,38 @@ def set_mode(uzbl, mode=None): if 'mode_indicator' not in mode_config: config['mode_indicator'] = mode - uzbl.clear_keycmd() + +def set_mode(uzbl, mode=None): + '''Set the mode and raise the MODE_CHANGED event if the mode has changed. + Fallback on the default mode if no mode argument was given and the default + mode is not null.''' + + config = uzbl.get_config() + mode_dict = get_mode_dict(uzbl) + if mode is None: + mode_dict['mode'] = '' + if 'default_mode' in config: + mode = config['default_mode'] + + else: + mode = 'command' + + if not VALID_KEY(mode): + raise KeyError("invalid mode name: %r" % mode) + + if 'mode' not in config or config['mode'] != mode: + config['mode'] = mode + return + + elif get_mode(uzbl) == mode: + return + uzbl.event("MODE_CHANGED", mode) def config_changed(uzbl, key, value): + '''Check for mode related config changes.''' + value = None if not value else value if key == 'default_mode': if not get_mode(uzbl): @@ -98,11 +113,25 @@ def config_changed(uzbl, key, value): set_mode(uzbl, value) +def set_mode_config(uzbl, mode, key, value): + '''Set mode specific configs. If the mode being modified is the current + mode then apply the changes on the go.''' + + assert VALID_KEY(mode) and VALID_KEY(key) + + mode_config = get_mode_config(uzbl, mode) + mode_config[key] = value + + if get_mode(uzbl) == mode: + uzbl.set(key, value) + + def mode_config(uzbl, args): + '''Parse mode config events.''' split = map(unicode.strip, FINDSPACES.split(args.lstrip(), 1)) if len(split) != 2: - raise SyntaxError('invalid config syntax: %r' % args) + raise SyntaxError('invalid mode config syntax: %r' % args) mode, set = split split = map(unicode.strip, set.split('=', 1)) @@ -110,35 +139,22 @@ def mode_config(uzbl, args): raise SyntaxError('invalid set syntax: %r' % args) key, value = split - if not VALID_KEY(key): - raise KeyError('invalid config key: %r' % key) - - mode_config = get_mode_config(uzbl, mode) - mode_config[key] = value - - if get_mode(uzbl) == mode: - uzbl.set(key, value) - - -def load_reset(uzbl, *args): - config = uzbl.get_config() - if 'reset_on_commit' not in config or config['reset_on_commit'] == '1': - set_mode(uzbl) + set_mode_config(uzbl, mode, key, value) def toggle_modes(uzbl, modes): + '''Toggle or cycle between or through a list of modes.''' - modelist = [s.strip() for s in modes.split(' ') if s] - if not len(modelist): - return error("no modes specified to toggle") + assert len(modes.strip()) - mode_dict = get_mode_dict(uzbl) - oldmode = mode_dict['mode'] - if oldmode not in modelist: - return set_mode(uzbl, modelist[0]) + modelist = filter(None, map(unicode.strip, modes.split(' '))) + mode = get_mode(uzbl) + + index = 0 + if mode in modelist: + index = (modelist.index(mode)+1) % len(modelist) - newmode = modelist[(modelist.index(oldmode)+1) % len(modelist)] - set_mode(uzbl, newmode) + set_mode(uzbl, modelist[index]) def init(uzbl): @@ -147,7 +163,7 @@ def init(uzbl): 'INSTANCE_EXIT': del_instance, 'INSTANCE_START': add_instance, 'MODE_CONFIG': mode_config, - 'LOAD_START': load_reset, - 'TOGGLE_MODES': toggle_modes} + 'TOGGLE_MODES': toggle_modes, + 'MODE_CHANGED': mode_changed} uzbl.connect_dict(connects) -- cgit v1.2.3 From 5cecb5d6570df33c2ce9c700c563fad8b787f13e Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sun, 29 Nov 2009 18:27:07 +0800 Subject: Add force option to set in config plugin. --- examples/data/uzbl/plugins/config.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/data/uzbl/plugins/config.py b/examples/data/uzbl/plugins/config.py index 57c2403..47b59f9 100644 --- a/examples/data/uzbl/plugins/config.py +++ b/examples/data/uzbl/plugins/config.py @@ -22,12 +22,16 @@ def get_config(uzbl): return UZBLS[uzbl] -def set(uzbl, key, value=''): - '''Sends a: "set key = value" command to the uzbl instance.''' +def set(uzbl, key, value='', force=True): + '''Sends a: "set key = value" command to the uzbl instance. If force is + False then only send a set command if the values aren't equal.''' if type(value) == types.BooleanType: value = int(value) + else: + value = unicode(value) + if not _VALIDSETKEY(key): raise KeyError("%r" % key) @@ -35,6 +39,11 @@ def set(uzbl, key, value=''): if '\n' in value: value = value.replace("\n", "\\n") + if not force: + config = get_config(uzbl) + if key in config and config[key] == value: + return + uzbl.send('set %s = %s' % (key, value)) @@ -61,8 +70,7 @@ class ConfigDict(dict): def __setitem__(self, key, value): '''Makes "config[key] = value" a wrapper for the set function.''' - if key not in self or unicode(self[key]) != unicode(value): - set(self._uzbl, key, value) + set(self._uzbl, key, value, force=False) def variable_set(uzbl, args): -- cgit v1.2.3 From 50d4c84aa7e28167cedbe14cd064d98a605ca1ea Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sun, 29 Nov 2009 18:41:56 +0800 Subject: Correctly implemented stack mode usage in the bind plugin. Using the stack mode in the bind plugin is required when using a stack bind in a mode with "set keycmd_events = 0" and "set forward_keys = 1" otherwise no keycmd input would work. --- examples/config/uzbl/config | 12 +++++++++++- examples/data/uzbl/plugins/bind.py | 23 +++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 9820fda..5f70627 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -3,7 +3,7 @@ set prefix = /usr/local -# === Shortcuts ============================================================== +# === Shortcuts / Aliases =================================================== # request BIND = set bind = request BIND @@ -273,6 +273,7 @@ menu_link_add Print Link = print \@SELECTED_URI # Define some mode specific uzbl configurations. set command = @mode_config command set insert = @mode_config insert +set stack = @mode_config stack # Command mode config. @command keycmd_style = foreground="red" @@ -283,6 +284,15 @@ set insert = @mode_config insert @insert status_background = #303030 @insert mode_indicator = Ins +# Multi-stage-binding mode config. +@stack keycmd_events = 1 +@stack modcmd_updates = 1 +@stack forward_keys = 0 +@stack keycmd_style = foreground="red" +@stack prompt_style = foreground="#888" weight="light" +@stack status_background = #202020 +@stack mode_indicator = Bnd + set default_mode = command # Mode bindings: diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py index 4976a80..3169b15 100644 --- a/examples/data/uzbl/plugins/bind.py +++ b/examples/data/uzbl/plugins/bind.py @@ -17,7 +17,7 @@ __export__ = ['bind', 'del_bind', 'del_bind_by_glob', 'get_binds'] # Hold the bind dicts for each uzbl instance. UZBLS = {} -DEFAULTS = {'binds': [], 'depth': 0, 'stack': [], 'args': []} +DEFAULTS = {'binds': [], 'depth': 0, 'stack': [], 'args': [], 'last_mode': ''} # Commonly used regular expressions. starts_with_mod = re.compile('^<([A-Z][A-Za-z0-9-_]*)>') @@ -276,15 +276,25 @@ def parse_bind_event(uzbl, args): bind(uzbl, glob, command) -def clear_stack(uzbl, mode): +def mode_changed(uzbl, mode): + '''Clear the stack on all non-stack mode changes.''' + + if mode != 'stack': + clear_stack(uzbl) + + +def clear_stack(uzbl): '''Clear everything related to stacked binds.''' bind_dict = get_bind_dict(uzbl) bind_dict['stack'] = [] bind_dict['depth'] = 0 bind_dict['args'] = [] + if bind_dict['last_mode']: + uzbl.set_mode(bind_dict['last_mode']) + bind_dict['last_mode'] = '' - uzbl.set('keycmd_prompt', '') + uzbl.set('keycmd_prompt', force=False) def stack_bind(uzbl, bind, args, depth): @@ -298,6 +308,10 @@ def stack_bind(uzbl, bind, args, depth): return + if uzbl.get_mode() != 'stack': + bind_dict['last_mode'] = uzbl.get_mode() + uzbl.set_mode('stack') + globalcmds = [cmd for cmd in bind_dict['binds'] if cmd.is_global] bind_dict['stack'] = [bind,] + globalcmds bind_dict['args'] += args @@ -356,6 +370,7 @@ def match_and_exec(uzbl, bind, depth, keylet): exec_bind(uzbl, bind, *args) uzbl.set_mode() if not has_args: + clear_stack(uzbl) uzbl.clear_current() return True @@ -411,6 +426,6 @@ def init(uzbl): 'MODCMD_UPDATE': modcmd_update, 'KEYCMD_EXEC': keycmd_exec, 'MODCMD_EXEC': modcmd_exec, - 'MODE_CHANGED': clear_stack} + 'MODE_CHANGED': mode_changed} uzbl.connect_dict(connects) -- cgit v1.2.3 From 06dd36b6656e272c52b9628dfebc24d4c727b34a Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sun, 29 Nov 2009 18:50:44 +0800 Subject: Repair command insert toggle. --- examples/config/uzbl/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 7a2aaa0..29cb365 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -310,7 +310,7 @@ set default_mode = command set toggle_cmd_ins = @toggle_modes command insert @bind i = @toggle_cmd_ins -@bind = @toggle_cmd_ins +@bind i = @toggle_cmd_ins # === Post-load misc commands =============================================== -- cgit v1.2.3 From 3eb6abf97a1e04a0c9102329b25b300fd484906b Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sun, 29 Nov 2009 19:00:06 +0800 Subject: Revert "Merge branch 'security' of git://lug.rose-hulman.edu/~spenceal/uzbl into experimental" This reverts commit e1ffb7652d256efdbb7a145f39b0289ebb523d34, reversing changes made to f7eeee9955f99d4acbfc90c7dc00b50767a15e07. --- examples/data/uzbl/scripts/clipboard.sh | 2 +- examples/data/uzbl/scripts/download.sh | 4 ++-- examples/data/uzbl/scripts/scheme.py | 5 ++--- examples/data/uzbl/scripts/yank.sh | 7 +++++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/data/uzbl/scripts/clipboard.sh b/examples/data/uzbl/scripts/clipboard.sh index d493774..60567d3 100755 --- a/examples/data/uzbl/scripts/clipboard.sh +++ b/examples/data/uzbl/scripts/clipboard.sh @@ -11,7 +11,7 @@ url="$7" selection=`$clip -o` case $action in - "yank" ) echo -n "$url" | $clip;; + "yank" ) echo -n "$url" | eval "$clip";; "goto" ) echo "uri $selection" > "$fifo";; * ) echo "clipboard.sh: invalid action";; esac diff --git a/examples/data/uzbl/scripts/download.sh b/examples/data/uzbl/scripts/download.sh index 55b0cb2..c8eb6ba 100755 --- a/examples/data/uzbl/scripts/download.sh +++ b/examples/data/uzbl/scripts/download.sh @@ -16,7 +16,7 @@ test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; } # only changes the dir for the $get sub process if echo "$url" | grep -E '.*\.torrent' >/dev/null; then - ( cd "$dest"; $GET "$url" ) + ( cd "$dest"; eval "$GET" "$url") else - ( cd "$dest"; $GET "$url" ) + ( cd "$dest"; eval "$GET" "$url") fi diff --git a/examples/data/uzbl/scripts/scheme.py b/examples/data/uzbl/scripts/scheme.py index 0916466..a54476f 100755 --- a/examples/data/uzbl/scripts/scheme.py +++ b/examples/data/uzbl/scripts/scheme.py @@ -16,9 +16,8 @@ if __name__ == '__main__': uri = sys.argv[8] u = urlparse.urlparse(uri) if u.scheme == 'mailto': - detach_open(['xterm', '-e', 'mail', u.path]) + detach_open(['xterm', '-e', 'mail %r' % u.path]) elif u.scheme == 'xmpp': - # Someone check for safe arguments to gajim-remote detach_open(['gajim-remote', 'open_chat', uri]) elif u.scheme == 'git': - detach_open(['git', 'clone', '--', uri], cwd=os.path.expanduser('~/src')) + detach_open(['git', 'clone', uri], cwd=os.path.expanduser('~/src')) diff --git a/examples/data/uzbl/scripts/yank.sh b/examples/data/uzbl/scripts/yank.sh index 6785d64..376b7e2 100755 --- a/examples/data/uzbl/scripts/yank.sh +++ b/examples/data/uzbl/scripts/yank.sh @@ -9,6 +9,9 @@ clip=xclip which $clip &>/dev/null || exit 1 -[ "$9" = primary -o "$9" = secondary -o "$9" = clipboard ] || exit 2 +[ "x$9" = xprimary -o "x$9" = xsecondary -o "x$9" = xclipboard ] || exit 2 -echo -n "$8" | $clip -selection $9 +value=`eval "echo -n \\${$8}"` # bash: value = ${!8} + +echo "echo -n '${value}' | $clip -selection $9" +echo -n "'${value}' | $clip -selection $9" -- cgit v1.2.3 From efb04a3a19b026dc1a304f52c5e0351f84988dc2 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Sun, 29 Nov 2009 19:05:02 +0800 Subject: Clear keycmd & modcmd on mode change. --- examples/data/uzbl/plugins/mode.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/data/uzbl/plugins/mode.py b/examples/data/uzbl/plugins/mode.py index 568abc1..52b104a 100644 --- a/examples/data/uzbl/plugins/mode.py +++ b/examples/data/uzbl/plugins/mode.py @@ -72,6 +72,9 @@ def mode_changed(uzbl, mode): if 'mode_indicator' not in mode_config: config['mode_indicator'] = mode + uzbl.clear_keycmd() + uzbl.clear_modcmd() + def set_mode(uzbl, mode=None): '''Set the mode and raise the MODE_CHANGED event if the mode has changed. -- cgit v1.2.3