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