Skip to content

Commit

Permalink
Merge pull request #48 from jeroenseegers/reppy-compatibility
Browse files Browse the repository at this point in the history
Add equal-sign to parse safe characters
  • Loading branch information
wRAR authored Apr 4, 2024
2 parents 94ebfa3 + 37546bf commit a6d84dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/protego.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _quote_pattern(self, pattern):

parts = urlparse(pattern)
pattern = self._unquote(parts.path, ignore="/*$%")
pattern = quote(pattern, safe="/*%")
pattern = quote(pattern, safe="/*%=")

parts = ParseResult(
"", "", pattern + last_char, parts.params, parts.query, parts.fragment
Expand Down
7 changes: 7 additions & 0 deletions tests/test_protego.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,13 @@ def test_parse_time_period(self):
self.assertEqual(start_time, time(5, 0))
self.assertEqual(end_time, time(6, 0))

def test_disallow_query_wildcard(self):
content = "User-agent: * \nDisallow: /*s="
rp = Protego.parse(content=content)
self.assertTrue(rp.can_fetch("https://www.site.local/", "*"))
self.assertTrue(rp.can_fetch("https://www.site.local/s/", "*"))
self.assertFalse(rp.can_fetch("https://www.site.local/?s=asd", "*"))


@pytest.mark.parametrize(
"allow,disallow,url,allowed",
Expand Down

0 comments on commit a6d84dd

Please sign in to comment.