From 95ac68b6d7aaa97415e7e4d7e116fc66fe7ad86e Mon Sep 17 00:00:00 2001 From: Dean Karn Date: Tue, 11 May 2021 17:37:28 -0700 Subject: [PATCH] fix url_encoded regex (#769) --- regexes.go | 2 +- validator_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/regexes.go b/regexes.go index 9ecf4b1..ddcf785 100644 --- a/regexes.go +++ b/regexes.go @@ -45,7 +45,7 @@ const ( ethAddressRegexString = `^0x[0-9a-fA-F]{40}$` ethAddressUpperRegexString = `^0x[0-9A-F]{40}$` ethAddressLowerRegexString = `^0x[0-9a-f]{40}$` - uRLEncodedRegexString = `(%[A-Fa-f0-9]{2})` + uRLEncodedRegexString = `^(?:[^%]|%[0-9A-Fa-f]{2})*$` hTMLEncodedRegexString = `&#[x]?([0-9a-fA-F]{2})|(>)|(<)|(")|(&)+[;]?` hTMLRegexString = `<[/]?([a-zA-Z]+).*?>` splitParamsRegexString = `'[^']*'|\S+` diff --git a/validator_test.go b/validator_test.go index db5bf73..5dcd00e 100644 --- a/validator_test.go +++ b/validator_test.go @@ -9537,6 +9537,9 @@ func TestURLEncodedValidation(t *testing.T) { {"a%b", false}, {"1%2", false}, {"%%a%%", false}, + {"hello", true}, + {"", true}, + {"+", true}, } validate := New()