domain_new.go: reject domains with /

This commit is contained in:
Adhityaa Chandrasekar 2019-05-01 18:48:25 -04:00
parent feeda79923
commit a9c48a8394
2 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"net/http" "net/http"
"strings"
"time" "time"
) )
@ -10,6 +11,10 @@ func domainNew(ownerHex string, name string, domain string) error {
return errorMissingField return errorMissingField
} }
if strings.Contains(domain, "/") {
return errorInvalidDomain
}
statement := ` statement := `
INSERT INTO INSERT INTO
domains (ownerHex, name, domain, creationDate) domains (ownerHex, name, domain, creationDate)

View File

@ -45,3 +45,4 @@ var errorThreadLocked = errors.New("This thread is locked. You cannot add new co
var errorDatabaseMigration = errors.New("Encountered error applying database migration.") var errorDatabaseMigration = errors.New("Encountered error applying database migration.")
var errorNoSuchUnsubscribeSecretHex = errors.New("Invalid unsubscribe link.") var errorNoSuchUnsubscribeSecretHex = errors.New("Invalid unsubscribe link.")
var errorEmptyPaths = errors.New("Empty paths field.") var errorEmptyPaths = errors.New("Empty paths field.")
var errorInvalidDomain = errors.New("Invalid domain name. Do not include the URL path after the forward slash.")