From 56b68d689391333bd17401d1ea300544c26d26c4 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 4 Dec 2003 08:50:49 +0000 Subject: [PATCH] Fixed bug #853904. --- plugins/Http.py | 7 ++++--- test/test_Http.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/Http.py b/plugins/Http.py index 6b9ae3245..d4ae1a887 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -81,6 +81,7 @@ class Http(callbacks.Privmsg): except webutils.WebError, e: irc.error(msg, str(e)) + _doctypeRe = re.compile(r'(]+>)', re.M) def doctype(self, irc, msg, args): """ @@ -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) diff --git a/test/test_Http.py b/test/test_Http.py index 408c8e7bc..21a4947be 100644 --- a/test/test_Http.py +++ b/test/test_Http.py @@ -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')