fix(rln-relay): regex pattern match for extended domains (#2444)

* fix(rln-relay): regex pattern match for extended domains

* fix: enable localhost too
This commit is contained in:
Aaryamann Challani 2024-02-16 22:42:35 +05:30 committed by GitHub
parent 2060cfab67
commit 29b0c0b8da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -322,8 +322,8 @@ proc parseCmdArg*(T: type EthRpcUrl, s: string): T =
## https://url:port/path?query
## disallowed patterns:
## any valid/invalid ws or wss url
var httpPattern = re2"^(https?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
var wsPattern = re2"^(wss?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
var httpPattern = re2"^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
var wsPattern = re2"^(wss?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
if regex.match(s, wsPattern):
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
if not regex.match(s, httpPattern):

View File

@ -133,8 +133,8 @@ proc parseCmdArg*(T: type EthRpcUrl, s: string): T =
## https://url:port/path?query
## disallowed patterns:
## any valid/invalid ws or wss url
var httpPattern = re2"^(https?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
var wsPattern = re2"^(wss?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
var httpPattern = re2"^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
var wsPattern = re2"^(wss?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
if regex.match(s, wsPattern):
echo "here"
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")

View File

@ -619,8 +619,8 @@ proc parseCmdArg*(T: type EthRpcUrl, s: string): T =
## https://url:port/path?query
## disallowed patterns:
## any valid/invalid ws or wss url
var httpPattern = re2"^(https?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
var wsPattern = re2"^(wss?:\/\/)(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))"
var httpPattern = re2"^(https?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
var wsPattern = re2"^(wss?):\/\/((localhost)|([\w_-]+(?:(?:\.[\w_-]+)+)))(:[0-9]{1,5})?([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])*"
if regex.match(s, wsPattern):
raise newException(ValueError, "Websocket RPC URL is not supported, Please use an HTTP URL")
if not regex.match(s, httpPattern):