mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Fixed bug #853904.
This commit is contained in:
parent
41fd7c7887
commit
56b68d6893
@ -81,6 +81,7 @@ class Http(callbacks.Privmsg):
|
||||
except webutils.WebError, e:
|
||||
irc.error(msg, str(e))
|
||||
|
||||
_doctypeRe = re.compile(r'(<!DOCTYPE[^>]+>)', re.M)
|
||||
def doctype(self, irc, msg, args):
|
||||
"""<url>
|
||||
|
||||
@ -93,9 +94,9 @@ class Http(callbacks.Privmsg):
|
||||
return
|
||||
try:
|
||||
s = webutils.getUrl(url, size=self.maxSize)
|
||||
if 'DOCTYPE' in s and '\n' in s:
|
||||
line = s.splitlines()[0]
|
||||
s = utils.normalizeWhitespace(line.strip())
|
||||
m = self._doctypeRe.search(s)
|
||||
if m:
|
||||
s = utils.normalizeWhitespace(m.group(0))
|
||||
irc.reply(msg, '%s has the following doctype: %s' % (url, s))
|
||||
else:
|
||||
irc.reply(msg, '%s has no specified doctype.' % url)
|
||||
|
@ -40,6 +40,8 @@ class HttpTest(PluginTestCase, PluginDocumentation):
|
||||
def testDoctype(self):
|
||||
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
||||
self.assertNotError('doctype http://www.slashdot.org/')
|
||||
m = self.getMsg('doctype http://moobot.sf.net/')
|
||||
self.failUnless(m.args[1].endswith('>'))
|
||||
|
||||
def testSize(self):
|
||||
self.assertError('size ftp://ftp.cdrom.com/pub/linux')
|
||||
|
Loading…
Reference in New Issue
Block a user