is_valid_scheme is missing an end anchor, so invalid schemes are accepted and URLs mis-parsed
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
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
```python
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.
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100