diff options
author | 2018-07-08 17:38:46 -0400 | |
---|---|---|
committer | 2018-07-08 17:38:46 -0400 | |
commit | b3a92f1622e33076e5378eeb547f07afaa1aac9b (patch) | |
tree | 9cc4b7acd800adb23eceeb20c426c60532335e42 /plugin | |
parent | 774546243036c52ff6e3ad524594e68b59c3a919 (diff) | |
download | coredns-b3a92f1622e33076e5378eeb547f07afaa1aac9b.tar.gz coredns-b3a92f1622e33076e5378eeb547f07afaa1aac9b.tar.zst coredns-b3a92f1622e33076e5378eeb547f07afaa1aac9b.zip |
- compliance with metadata contract. If metadata value is empty, ignore rewrite - like if metadata does not exist. (#1953)
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/rewrite/edns0.go | 5 | ||||
-rw-r--r-- | plugin/rewrite/rewrite_test.go | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/plugin/rewrite/edns0.go b/plugin/rewrite/edns0.go index 074dd3ebf..e97f04d95 100644 --- a/plugin/rewrite/edns0.go +++ b/plugin/rewrite/edns0.go @@ -203,7 +203,10 @@ func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Reque fetcher := metadata.ValueFunc(ctx, rule.variable[1:len(rule.variable)-1]) if fetcher != nil { - return []byte(fetcher()), nil + value := fetcher() + if len(value) > 0 { + return []byte(value), nil + } } return nil, fmt.Errorf("unable to extract data for variable %s", rule.variable) diff --git a/plugin/rewrite/rewrite_test.go b/plugin/rewrite/rewrite_test.go index f70933c3c..670467664 100644 --- a/plugin/rewrite/rewrite_test.go +++ b/plugin/rewrite/rewrite_test.go @@ -523,8 +523,8 @@ func TestRewriteEDNS0LocalVariable(t *testing.T) { { []dns.EDNS0{}, []string{"local", "set", "0xffee", "{test/empty}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("")}}, - true, + nil, + false, }, { []dns.EDNS0{}, |