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:
|
except webutils.WebError, e:
|
||||||
irc.error(msg, str(e))
|
irc.error(msg, str(e))
|
||||||
|
|
||||||
|
_doctypeRe = re.compile(r'(<!DOCTYPE[^>]+>)', re.M)
|
||||||
def doctype(self, irc, msg, args):
|
def doctype(self, irc, msg, args):
|
||||||
"""<url>
|
"""<url>
|
||||||
|
|
||||||
@ -93,9 +94,9 @@ class Http(callbacks.Privmsg):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
s = webutils.getUrl(url, size=self.maxSize)
|
s = webutils.getUrl(url, size=self.maxSize)
|
||||||
if 'DOCTYPE' in s and '\n' in s:
|
m = self._doctypeRe.search(s)
|
||||||
line = s.splitlines()[0]
|
if m:
|
||||||
s = utils.normalizeWhitespace(line.strip())
|
s = utils.normalizeWhitespace(m.group(0))
|
||||||
irc.reply(msg, '%s has the following doctype: %s' % (url, s))
|
irc.reply(msg, '%s has the following doctype: %s' % (url, s))
|
||||||
else:
|
else:
|
||||||
irc.reply(msg, '%s has no specified doctype.' % url)
|
irc.reply(msg, '%s has no specified doctype.' % url)
|
||||||
|
@ -40,6 +40,8 @@ class HttpTest(PluginTestCase, PluginDocumentation):
|
|||||||
def testDoctype(self):
|
def testDoctype(self):
|
||||||
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
||||||
self.assertNotError('doctype http://www.slashdot.org/')
|
self.assertNotError('doctype http://www.slashdot.org/')
|
||||||
|
m = self.getMsg('doctype http://moobot.sf.net/')
|
||||||
|
self.failUnless(m.args[1].endswith('>'))
|
||||||
|
|
||||||
def testSize(self):
|
def testSize(self):
|
||||||
self.assertError('size ftp://ftp.cdrom.com/pub/linux')
|
self.assertError('size ftp://ftp.cdrom.com/pub/linux')
|
||||||
|
Loading…
Reference in New Issue
Block a user