DEVELOPMENT ENVIRONMENT

~liljamo/felu

274ac5771394ba4aec10dd768851ad76cd2ac429 — Jonni Liljamo 1 year, 1 month ago 718ba8a
feat: check that domains are only ascii letters and numbers
1 files changed, 7 insertions(+), 0 deletions(-)

M internal/handlers/domains.go
M internal/handlers/domains.go => internal/handlers/domains.go +7 -0
@@ 10,6 10,7 @@ import (
	"log"
	"net"
	"net/http"
	"regexp"
	"strings"

	"git.src.quest/~skye/felu-ddns/internal/db"


@@ 40,6 41,12 @@ func PostDomain() gin.HandlerFunc {
			c.Abort()
			return
		}
		// NOTE: I doubt doing a little regex here will matter, just the easiest for now.
		if !regexp.MustCompile(`^[A-Za-z0-9]*$`).MatchString(data.Domain) {
			c.String(http.StatusBadRequest, "Domain contains invalid chars")
			c.Abort()
			return
		}
		if net.ParseIP(data.ARecord).To4() == nil {
			c.String(http.StatusBadRequest, "The A record is invalid")
			c.Abort()