]> granicus.if.org Git - python/commitdiff
Merged revisions 83209 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Wed, 28 Jul 2010 16:30:46 +0000 (16:30 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Wed, 28 Jul 2010 16:30:46 +0000 (16:30 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83209 | senthil.kumaran | 2010-07-28 21:57:56 +0530 (Wed, 28 Jul 2010) | 3 lines

  Fix Issue6325 - robotparse to honor urls with query strings.
........

Lib/test/test_robotparser.py
Lib/urllib/robotparser.py

index 4c3b5363fd1f28a8c979cbc69ab99970f6d9faff..9d3040547e50249445acbd4249873911ce234153 100644 (file)
@@ -205,6 +205,17 @@ bad = ['/folder1/anotherfile.html']
 RobotTest(13, doc, good, bad, agent="googlebot")
 
 
+# 14. For issue #6325 (query string support)
+doc = """
+User-agent: *
+Disallow: /some/path?name=value
+"""
+
+good = ['/some/path']
+bad = ['/some/path?name=value']
+
+RobotTest(14, doc, good, bad)
+
 
 class NetworkTestCase(unittest.TestCase):
 
index bafb611a1c56007dc34a3c65df7cccd92da96983..30baa055d2a8be95bc4589596f98fc184b47a903 100644 (file)
@@ -129,8 +129,10 @@ class RobotFileParser:
             return True
         # search for given user agent matches
         # the first match counts
-        url = urllib.parse.quote(
-            urllib.parse.urlparse(urllib.parse.unquote(url))[2])
+        parsed_url = urllib.parse.urlparse(urllib.parse.unquote(url))
+        url = urllib.parse.urlunparse(('','',parsed_url.path,
+            parsed_url.params,parsed_url.query, parsed_url.fragment))
+        url = urllib.parse.quote(url)
         if not url:
             url = "/"
         for entry in self.entries: