# for spammers' address harvesters - getting this wrong
# would make the freenode #commits channel into harvester heaven.
self.author = self.author.replace("<", "").split("@")[0].split()[-1]
+ self.maxchannels = 0
def load_preferences(extractor, conf):
"Load preferences from a file in the repository root."
val = True
if val.lower() == "false":
val = False
+ # User cannot set maxchannels - only a command-line arg can do that.
+ if fld == "maxchannels":
+ return
setattr(extractor, fld, val)
class SvnExtractor:
self.template = '%(project)s: %(author)s %(repo)s * %(rev)s / %(files)s: %(logmsg)s %(url)s'
self.urlprefix = "viewcvs"
self.tinyifier = default_tinyifier
+ self.maxchannels = 0
load_preferences(self, os.path.join(self.repository, "irker.conf"))
def svnlook(self, info):
return do("svnlook %s %s --revision %s" % (shellquote(info), shellquote(self.repository), shellquote(self.commit)))
# Each argument of the form <key>=<value> can override the
# <key> member of the extractor class.
booleans = ["tcp"]
+ numerics = ["maxchannels"]
for tok in arguments:
for key in extractor.__dict__:
if tok.startswith(key + "="):
setattr(extractor, key, True)
elif val.lower() == "false":
setattr(extractor, key, False)
+ elif key in numerics:
+ setattr(extractor, key, int(val))
else:
setattr(extractor, key, val)
privmsg = extractor.template % extractor.__dict__
channel_list = extractor.channels.split(",")
+ if extractor.maxchannels != 0:
+ channel_list = channel_list[:extractor.maxchannels]
structure = {"to":channel_list, "privmsg":privmsg}
message = json.dumps(structure)
if not notify:
will take up less space in the notification line.</para>
</listitem>
</varlistentry>
+<varlistentry>
+<term>maxchannels</term>
+<listitem>
+<para>Interpreted as an integer. If not zero, limits the number of
+channels the hook will interpret from the "channels" variable.</para>
+
+<para>This variable cannot be set through VCS configuration variables
+or <filename>irker.conf</filename>; it can only be set with a command-line
+argument. Thus, on a forge site in which repository owners are not
+allowed to modify their post-commit scripts, a site administrator can set it
+to prevent shotgun spamming by malicious project owners. Setting it to
+a value less than 2, however, would probably be unwise.</para>
+</listitem>
+</varlistentry>
</variablelist>
<refsect2 id="git"><title>git</title>