From 02b5f0b7e6782a76c2ed8d8e650302ae4ce4807c Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 2 Aug 2016 22:17:23 -0700 Subject: [PATCH] changehost: explicitly forbid $host from being expanded This will cause recursion whenever applyhost is ran and a user matches a mask based on real host or IP, which haven't changed. Any suffix or prefix applied to $host will be reapplied, often leading to invalid hosts that are too long. --- example-conf.yml | 2 +- plugins/changehost.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index ecf6e4c..eefdade 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -370,7 +370,7 @@ changehost: # This sets the hostmasks that Changehost should look for. Whenever someone # with a matching nick!user@host connects, their host will be set to the # text defined. The following substitutions are available here: - # $uid, $ts (time of connection), $nick, $realhost, $host, $ident, $ip. + # $uid, $ts (time of connection), $nick, $realhost, $ident, amd $ip. # Invalid characters in hosts are replaced with a "-". # Also, make sure you quote each entry so the YAML parser treats them as # raw strings. diff --git a/plugins/changehost.py b/plugins/changehost.py index fe5603c..ffe6d3c 100644 --- a/plugins/changehost.py +++ b/plugins/changehost.py @@ -38,7 +38,10 @@ 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, $host, $ident, $ip + # $uid, $ts, $nick, $realhost, $ident, and $ip. $host is explicitly + # forbidden because it can cause recursive loops. + + del args['host'] new_host = template.substitute(args) # Replace characters that are not allowed in hosts with "-".