From 1cda5023c8df4c47acbfacbd2091c4b9f751a3c3 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 2 Aug 2016 22:56:59 -0700 Subject: [PATCH] changehost: copy args before cloning, make $host expansion optional --- plugins/changehost.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/changehost.py b/plugins/changehost.py index ffe6d3c..cecebfd 100644 --- a/plugins/changehost.py +++ b/plugins/changehost.py @@ -30,6 +30,12 @@ def _changehost(irc, target, args): "Changehost will not function correctly!", irc.name) return + args = args.copy() + if not changehost_conf.get('force_host_expansion'): + del args['host'] + + log.debug('(%s) Changehost args: %s', irc.name, args) + for host_glob, host_template in changehost_hosts.items(): if irc.matchHost(host_glob, target): # This uses template strings for simple substitution: @@ -38,10 +44,17 @@ def _changehost(irc, target, args): # Substitute using the fields provided the hook data. This means # that the following variables are available for substitution: - # $uid, $ts, $nick, $realhost, $ident, and $ip. $host is explicitly - # forbidden because it can cause recursive loops. + # $uid, $ts, $nick, $realhost, $ident, and $ip. + + # $host is explicitly forbidden by default because it can cause + # recursive loops when IP or real host masks are used to match a + # target. vHost updates do not affect these fields, so any further + # execution of 'applyhosts' will cause $host to expand again to + # the user's new host, causing the vHost to grow rapidly in size. + # That said, it is possible to get away with this expansion if + # you're careful with what you're doing, and that is why this + # hidden option exists. -GLolol - del args['host'] new_host = template.substitute(args) # Replace characters that are not allowed in hosts with "-".