is_valid_scheme is missing an end anchor, so invalid schemes are accepted and URLs mis-parsed
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start by locating is_valid_scheme and compare its regex with the module's other validators, which use both anchors. Reproduce the issue with furl('a b:c'), then verify that invalid schemes leave the whole input as the path while valid schemes continue to parse correctly.
Written by the indexing model from the issue text.
Description
Summary
is_valid_scheme matches the scheme regex with re.match, but the pattern lacks a trailing $ anchor — unlike the module's other validators, which use ^...$. Any string whose prefix looks like a scheme is therefore accepted, so a URL like a b:c is mis-parsed as scheme a b + path c, instead of no scheme and path a b:c.
Reproduction
from furl import furl
f = furl('a b:c')
print(f.scheme) # 'a b' <- expected None
print(str(f.path)) # 'c' <- expected 'a b:c'
Expected
a b is not a valid scheme (it contains a space), so f.scheme is None and the whole string is the path.
Actual
Scheme 'a b' is extracted and stored; the parse is corrupted.
Fix sketch
Anchor the scheme regex with $ (or use re.fullmatch), matching the module's other validators.
Environment
furl 2.1.4 (master @ 46d9ea7), Python 3.12.
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from gruns/furl
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Kind/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
-
Kind/Bug Kind/Compatibility
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100