Fixed #862645 - unquoted spaces getting sent in HTTP request

This commit is contained in:
Daniel DiPaolo 2003-12-19 01:58:49 +00:00
parent b6c780cff3
commit 1474c16a5f
2 changed files with 4 additions and 1 deletions

View File

@ -41,6 +41,7 @@ import re
import sets
import getopt
import socket
import urllib
import urllib2
import xml.dom.minidom
from itertools import imap, ifilter
@ -354,7 +355,7 @@ class Http(callbacks.Privmsg):
"""
acronym = privmsgs.getArgs(args)
url = 'http://www.acronymfinder.com/' \
'af-query.asp?String=exact&Acronym=%s' % acronym
'af-query.asp?String=exact&Acronym=%s' % urllib.quote(acronym)
request = urllib2.Request(url, headers={'User-agent':
'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})
html = webutils.getUrl(request)

View File

@ -93,6 +93,8 @@ class HttpTest(PluginTestCase, PluginDocumentation):
self.assertRegexp('acronym ASAP', 'as soon as possible')
self.assertNotRegexp('acronym asap', 'Definition')
self.assertNotRegexp('acronym UNIX', 'not an acronym')
# Used to pass requests with spaces ... make sure that stays fixed
self.assertNotError('acronym W T F')
def testNetcraft(self):
self.assertNotError('netcraft slashdot.org')