Skip to content

RobotParser stops at the first find on the disallow/allow list #148951

Description

@cnicodeme

Bug report

Bug description:

I took Wordpress's robots.txt file for testing : https://wordpress.com/robots.txt

It contains the following:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Testing for "/wp-admin/admin-ajax.php" will return False instead of True

Reproducible sample:

from urllib.robotparser import RobotFileParser

ra = RobotFileParser()
ra.parse('''User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php'''.splitlines())

assert ra.can_fetch('GoogleBot', 'https://wordpress.com/wp-admin/') is False
assert ra.can_fetch('GoogleBot', 'https://wordpress.com/wp-admin/admin-ajax.php') is True  # Fails here

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions