Remove unused helper fieldValueComponet
This commit is contained in:
parent
b6f83d55b8
commit
ee9d9d1b7a
3 changed files with 5 additions and 40 deletions
|
@ -281,14 +281,9 @@ var (
|
||||||
"shouldLoadAuthDigestModule": shouldLoadAuthDigestModule,
|
"shouldLoadAuthDigestModule": shouldLoadAuthDigestModule,
|
||||||
"buildServerName": buildServerName,
|
"buildServerName": buildServerName,
|
||||||
"buildCorsOriginRegex": buildCorsOriginRegex,
|
"buildCorsOriginRegex": buildCorsOriginRegex,
|
||||||
"fieldValueComponet": fieldValueComponet,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
headerFieldValueTokenChars = regexp.MustCompile("^[!#$%&'*+.^_`|~0-9A-Za-z-]+$")
|
|
||||||
)
|
|
||||||
|
|
||||||
// escapeLiteralDollar will replace the $ character with ${literal_dollar}
|
// escapeLiteralDollar will replace the $ character with ${literal_dollar}
|
||||||
// which is made to work via the following configuration in the http section of
|
// which is made to work via the following configuration in the http section of
|
||||||
// the template:
|
// the template:
|
||||||
|
@ -1859,12 +1854,3 @@ func buildCorsOriginRegex(corsOrigins []string) string {
|
||||||
originsRegex = originsRegex + ")$ ) { set $cors 'true'; }"
|
originsRegex = originsRegex + ")$ ) { set $cors 'true'; }"
|
||||||
return originsRegex
|
return originsRegex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Token containing character other than tchar must be quoted using
|
|
||||||
// double-quote marks (section 3.2.6 of RFC 7230).
|
|
||||||
func fieldValueComponet(s string) string {
|
|
||||||
if headerFieldValueTokenChars.MatchString(s) {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%q", s)
|
|
||||||
}
|
|
||||||
|
|
|
@ -2237,24 +2237,3 @@ func TestCleanConf(t *testing.T) {
|
||||||
t.Errorf("cleanConf result don't match with expected: %s", diff)
|
t.Errorf("cleanConf result don't match with expected: %s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFieldValueComponet(t *testing.T) {
|
|
||||||
testCases := map[string]struct {
|
|
||||||
input string
|
|
||||||
expect string
|
|
||||||
}{
|
|
||||||
"empty": {"", `""`},
|
|
||||||
"spaces": {" ", `" "`},
|
|
||||||
"ipv4": {"1.2.3.4", `1.2.3.4`},
|
|
||||||
"ipv6": {"[::1]", `"[::1]"`},
|
|
||||||
"obfuscated identifier": {"_hidden", `_hidden`},
|
|
||||||
"ipv4 port": {"1.2.3.4:80", `"1.2.3.4:80"`},
|
|
||||||
"domain": {"example.com", `example.com`},
|
|
||||||
"http schema": {"http", `http`},
|
|
||||||
}
|
|
||||||
for name, tc := range testCases {
|
|
||||||
if comp := fieldValueComponet(tc.input); comp != tc.expect {
|
|
||||||
t.Errorf("%v: expected '%v' but returned '%v'", name, tc.expect, comp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ http {
|
||||||
{{ if $cfg.EnableForwardedRFC7239 }}
|
{{ if $cfg.EnableForwardedRFC7239 }}
|
||||||
# Enabled standard forwarded (RFC 7239).
|
# Enabled standard forwarded (RFC 7239).
|
||||||
|
|
||||||
# Used to declare constant variables.
|
# Used to declare variables as constants.
|
||||||
map $nginx_version $nginx_constant {
|
map $nginx_version $nginx_constant {
|
||||||
default '';
|
default '';
|
||||||
}
|
}
|
||||||
|
@ -476,9 +476,9 @@ http {
|
||||||
default "for=unknown";
|
default "for=unknown";
|
||||||
}
|
}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
# Set proxy_forwarded_rfc2379_for as a constant string.
|
# Set proxy_forwarded_rfc2379_for as a obfuscated string.
|
||||||
map $nginx_constant $proxy_forwarded_rfc2379_for {
|
map $nginx_constant $proxy_forwarded_rfc2379_for {
|
||||||
default {{ $cfg.ForwardedRFC7239For | fieldValueComponet | printf "for=%s" | quote }};
|
default "for={{ $cfg.ForwardedRFC7239For }}";
|
||||||
}
|
}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
@ -496,9 +496,9 @@ http {
|
||||||
default "by=unknown";
|
default "by=unknown";
|
||||||
}
|
}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
# Set proxy_forwarded_rfc2379_by as a constant string.
|
# Set proxy_forwarded_rfc2379_by as a static obfuscated string.
|
||||||
map $nginx_constant $proxy_forwarded_rfc2379_by {
|
map $nginx_constant $proxy_forwarded_rfc2379_by {
|
||||||
default {{ $cfg.ForwardedRFC7239By | fieldValueComponet | printf "by=%s" | quote }};
|
default "by={{ $cfg.ForwardedRFC7239By }}";
|
||||||
}
|
}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue