mirror of
https://github.com/containous/traefik.git
synced 2025-11-05 16:23:55 +03:00
Fix access log field parsing
This commit is contained in:
committed by
Traefiker Bot
parent
450471d30a
commit
993caf5058
@@ -88,6 +88,11 @@ func (f *FieldNames) Get() interface{} {
|
|||||||
// Set's argument is a string to be parsed to set the flag.
|
// Set's argument is a string to be parsed to set the flag.
|
||||||
// It's a space-separated list, so we split it.
|
// It's a space-separated list, so we split it.
|
||||||
func (f *FieldNames) Set(value string) error {
|
func (f *FieldNames) Set(value string) error {
|
||||||
|
// When arguments are passed through YAML, escaped double quotes
|
||||||
|
// might be added to this string, and they would break the last
|
||||||
|
// key/value pair. This ensures the string is clean.
|
||||||
|
value = strings.Trim(value, "\"")
|
||||||
|
|
||||||
fields := strings.Fields(value)
|
fields := strings.Fields(value)
|
||||||
|
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
@@ -123,6 +128,11 @@ func (f *FieldHeaderNames) Get() interface{} {
|
|||||||
// Set's argument is a string to be parsed to set the flag.
|
// Set's argument is a string to be parsed to set the flag.
|
||||||
// It's a space-separated list, so we split it.
|
// It's a space-separated list, so we split it.
|
||||||
func (f *FieldHeaderNames) Set(value string) error {
|
func (f *FieldHeaderNames) Set(value string) error {
|
||||||
|
// When arguments are passed through YAML, escaped double quotes
|
||||||
|
// might be added to this string, and they would break the last
|
||||||
|
// key/value pair. This ensures the string is clean.
|
||||||
|
value = strings.Trim(value, "\"")
|
||||||
|
|
||||||
fields := strings.Fields(value)
|
fields := strings.Fields(value)
|
||||||
|
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
|
|||||||
@@ -301,6 +301,14 @@ func TestFieldsHeadersNamesSet(t *testing.T) {
|
|||||||
"X-HEADER-2": "bar",
|
"X-HEADER-2": "bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "Two values separated by space with escaped double quotes should return FieldNames of size 2",
|
||||||
|
value: "\"X-HEADER-1=foo X-HEADER-2=bar\"",
|
||||||
|
expected: &FieldHeaderNames{
|
||||||
|
"X-HEADER-1": "foo",
|
||||||
|
"X-HEADER-2": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
|
|||||||
Reference in New Issue
Block a user