mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-10 23:22:57 +03:00
fix: mark any callback url as valid if they contain a wildcard (#1006)
This commit is contained in:
@@ -67,14 +67,12 @@ func ValidateClientID(clientID string) bool {
|
||||
|
||||
// ValidateCallbackURL validates callback URLs with support for wildcards
|
||||
func ValidateCallbackURL(raw string) bool {
|
||||
if raw == "*" {
|
||||
// Don't validate if it contains a wildcard
|
||||
if strings.Contains(raw, "*") {
|
||||
return true
|
||||
}
|
||||
|
||||
// Replace all '*' with 'x' to check if the rest is still a valid URI
|
||||
test := strings.ReplaceAll(raw, "*", "x")
|
||||
|
||||
u, err := url.Parse(test)
|
||||
u, err := url.Parse(raw)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -14,9 +14,11 @@ export const callbackUrlSchema = z
|
||||
.nonempty()
|
||||
.refine(
|
||||
(val) => {
|
||||
if (val === '*') return true;
|
||||
if (val.includes('*')) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
new URL(val.replace(/\*/g, 'x'));
|
||||
new URL(val);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user