Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions spiderfoot/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,6 @@ def extractUrlsFromRobotsTxt(robotsTxtData: str) -> typing.List[str]:

Todo:
Check and parse User-Agent.

Fix whitespace parsing; ie, " " is not a valid disallowed path
"""
returnArr: typing.List[str] = list()

Expand All @@ -941,7 +939,11 @@ def extractUrlsFromRobotsTxt(robotsTxtData: str) -> typing.List[str]:

for line in robotsTxtData.splitlines():
if line.lower().startswith('disallow:'):
m = re.match(r'disallow:\s*(.[^ #]*)', line, re.IGNORECASE)
# Use \S to match the first non-whitespace character so that
# "Disallow: " (whitespace-only or empty path) is correctly
# ignored. Previously the pattern used '.' which also matched
# spaces, causing " " to be returned as a disallowed path.
m = re.match(r'disallow:\s*(\S[^ #]*)', line, re.IGNORECASE)
if m:
returnArr.append(m.group(1))

Expand Down