Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL validator has incorrect regexp range for scheme #841

Open
maspling opened this issue Mar 31, 2024 · 1 comment
Open

URL validator has incorrect regexp range for scheme #841

maspling opened this issue Mar 31, 2024 · 1 comment
Labels
bug Unexpected behavior

Comments

@maspling
Copy link

maspling commented Mar 31, 2024

The URL validator supports a scheme, at 3.1.2 the validator regex support ^[a-z]+:// while according to RFC 1738 (https://datatracker.ietf.org/doc/html/rfc1738#section-2.1) :

Scheme names consist of a sequence of characters. The lower case
   letters "a"--"z", digits, and the characters plus ("+"), period
   ("."), and hyphen ("-") are allowed.

This might break the flow of apps where you would be redirected to a url with a custom scheme causing an app to trigger, such as oauth client registrations. (https://datatracker.ietf.org/doc/html/rfc8252#section-7.1 as an example)

Actual Behavior

import wtforms
from wtforms.validators import URL

class F(wtforms.Form):
    foo = wtforms.StringField(
        validators=[URL(require_tld=False)]
    )

result = F(foo="com.example.app://callback").validate()
print(result)
> False

### Expected Behavior

```python

import wtforms
from wtforms.validators import URL

class F(wtforms.Form):
    foo = wtforms.StringField(
        validators=[URL(require_tld=False)]
    )

result = F(foo="com.example.app://callback").validate()
print(result)
> True

Environment

  • Python version: 3.11.6
  • wtforms version: 3.1.2
@azmeuk
Copy link
Member

azmeuk commented Oct 11, 2024

Might be fixed by #847

@azmeuk azmeuk added the bug Unexpected behavior label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior
Development

No branches or pull requests

2 participants