commit b6eeb8f1d4739b896abddc403c81931f7a797c5f
parent fa9e1a189c8a8f09abce98feefb6ad863ddb58ff
Author: parazyd <parazyd@dyne.org>
Date: Wed, 13 Dec 2017 02:48:39 +0100
Validate v3 hidden service addresses in ValidateOnionAddress
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pkg/damlib/validate.go b/pkg/damlib/validate.go
@@ -14,11 +14,11 @@ import (
// ValidateOnionAddress matches a string against a regular expression matching
// a Tor hidden service address. Returns true on success and false on failure.
func ValidateOnionAddress(addr string) bool {
- re, _ := regexp.Compile("^[a-z2-7]{16}\\.onion$")
- if len(re.FindString(addr)) != 22 {
- return false
+ re, _ := regexp.Compile("^[a-z2-7](?:.{55}|.{15})\\.onion")
+ if len(re.FindString(addr)) == 22 || len(re.FindString(addr)) == 62 {
+ return true
}
- return true
+ return false
}
// sanityCheck performs basic sanity checks against the incoming request.