mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-22 21:25:48 +00:00
Fix off-by-one error in cookie domain matching code.
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3850 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
97cf700e04
commit
7b2a21c133
3 changed files with 25 additions and 7 deletions
|
|
@ -61,6 +61,12 @@
|
|||
Type: bugfix
|
||||
Changed: linkcheck/robotparser2.py
|
||||
|
||||
* Fix off-by-one error in cookie domain matching code. Prevented
|
||||
some cookie files to work properly.
|
||||
Type: bugfix
|
||||
Changed: linkcheck/cookies.py
|
||||
Closes: SF bug #2016451
|
||||
|
||||
4.9 "Michael Clayton" (released 25.4.2008)
|
||||
|
||||
* Parse Shockwave Flash (SWF) for URLs to check
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ class HttpCookie (object):
|
|||
if not domain.endswith(cdomain):
|
||||
# any suffix matches
|
||||
return False
|
||||
if "." in domain[:-len(cdomain)]:
|
||||
if "." in domain[:-(len(cdomain)+1)]:
|
||||
# prefix must be dot-free
|
||||
return False
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import linkcheck.cookies
|
|||
|
||||
|
||||
class TestCookies (unittest.TestCase):
|
||||
"""
|
||||
Test list dictionary routines.
|
||||
"""
|
||||
"""Test cookie routines."""
|
||||
|
||||
def test_netscape_cookie1 (self):
|
||||
data = (
|
||||
|
|
@ -99,6 +97,22 @@ class TestCookies (unittest.TestCase):
|
|||
cookie = linkcheck.cookies.NetscapeCookie(value, scheme, host, path)
|
||||
self.assert_(cookie.is_expired())
|
||||
|
||||
def test_netscape_cookie6 (self):
|
||||
data = (
|
||||
("Foo", "Bar"),
|
||||
("Domain", "example.org"),
|
||||
("Path", "/"),
|
||||
)
|
||||
# note: values are without quotes
|
||||
value = "; ".join('%s=%s' % (key, value) for key, value in data)
|
||||
scheme = "http"
|
||||
host = "example.org"
|
||||
path = "/"
|
||||
cookie = linkcheck.cookies.NetscapeCookie(value, scheme, host, path)
|
||||
self.assertTrue(cookie.is_valid_for("http", "example.org", 80, "/"))
|
||||
self.assertTrue(cookie.is_valid_for("http", "www.example.org", 80, "/"))
|
||||
self.assertFalse(cookie.is_valid_for("http", "www.b.example.org", 80, "/"))
|
||||
|
||||
def test_rfc_cookie1 (self):
|
||||
data = (
|
||||
("Foo", "Bar"),
|
||||
|
|
@ -199,9 +213,7 @@ class TestCookies (unittest.TestCase):
|
|||
|
||||
|
||||
def test_suite ():
|
||||
"""
|
||||
Build and return a TestSuite.
|
||||
"""
|
||||
"""Build and return a TestSuite."""
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestCookies))
|
||||
return suite
|
||||
|
|
|
|||
Loading…
Reference in a new issue