Fix URL validator scheme regex to allow RFC 1738 characters#885
Closed
bysiber wants to merge 1 commit intopallets-eco:mainfrom
Closed
Fix URL validator scheme regex to allow RFC 1738 characters#885bysiber wants to merge 1 commit intopallets-eco:mainfrom
bysiber wants to merge 1 commit intopallets-eco:mainfrom
Conversation
The URL validator regex only accepted lowercase letters in the scheme (`^[a-z]+://`), but RFC 1738 allows digits, `+`, `.`, and `-` after the first letter. This caused valid URLs like `com.example.app://callback` to be rejected. Changed the regex to `^[a-z][a-z0-9+\-.]*://` to match the RFC spec. Added test cases for schemes containing these characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #841.
The URL validator regex for the scheme part uses
^[a-z]+://, which only accepts lowercase letters. Per RFC 1738 §2.1, scheme names can also contain digits,+,., and-after the initial letter. This means URLs with schemes likecom.example.app://callback(common in OAuth custom URI schemes per RFC 8252 §7.1) are incorrectly rejected.Changed the scheme regex to
^[a-z][a-z0-9+\-.]*://to match the spec. Also added test cases covering schemes with digits,+,.,-, a complex dot-separated scheme, and a negative test for a scheme starting with a digit.