diff --git a/apps/chat2/config_chat2.nim b/apps/chat2/config_chat2.nim index a23683e930..c847ed406a 100644 --- a/apps/chat2/config_chat2.nim +++ b/apps/chat2/config_chat2.nim @@ -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): diff --git a/apps/networkmonitor/networkmonitor_config.nim b/apps/networkmonitor/networkmonitor_config.nim index cb06418210..a1c83ba948 100644 --- a/apps/networkmonitor/networkmonitor_config.nim +++ b/apps/networkmonitor/networkmonitor_config.nim @@ -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") diff --git a/apps/wakunode2/external_config.nim b/apps/wakunode2/external_config.nim index 82ed60bc81..72bd64a170 100644 --- a/apps/wakunode2/external_config.nim +++ b/apps/wakunode2/external_config.nim @@ -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):