Skip to content

Commit

Permalink
Web: Fix nesting of commands (bug introduced in d8a4ef8).
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Aug 20, 2013
1 parent d14f5df commit 790bda4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions plugins/Web/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ def handle_entityref(self, name):
self.title += self.entitydefs[name]

class DelayedIrc:
def __init__(self, irc, msg):
def __init__(self, irc):
self._irc = irc
self._msg = msg
self._replies = []
def reply(self, *args, **kwargs):
self._replies.append(callbacks.reply(self._msg, *args, **kwargs))
self._replies.append(('reply', args, kwargs))
def error(self, *args, **kwargs):
self._replies.append(callbacks.error(self._msg, *args, **kwargs))
self._replies.append(('error', args, kwargs))
def __getattr__(self, name):
assert name not in ('reply', 'error', '_irc', '_msg', '_replies')
return getattr(self._irc, name)
Expand All @@ -86,7 +85,7 @@ def fetch_sandbox(f):
"""Runs a command in a forked process with limited memory resources
to prevent memory bomb caused by specially crafted http responses."""
def process(self, irc, msg, *args, **kwargs):
delayed_irc = DelayedIrc(irc, msg)
delayed_irc = DelayedIrc(irc)
f(self, delayed_irc, msg, *args, **kwargs)
return delayed_irc._replies
def newf(self, irc, *args):
Expand All @@ -97,8 +96,8 @@ def newf(self, irc, *args):
except commands.ProcessTimeoutError:
raise utils.web.Error(_('Page is too big.'))
else:
for reply in replies:
irc.queueMsg(reply)
for (method, args, kwargs) in replies:
getattr(irc, method)(*args, **kwargs)
newf.__doc__ = f.__doc__
return newf

Expand Down

0 comments on commit 790bda4

Please sign in to comment.