Repository: coredns/coredns (go)

Issue:
Wildcard records do not resolve correctly when using the Route53 plugin
**What happened**: Trying to resolve wildcard records while using the route53 plugin results in a NXDOMAIN response.

**What you expected to happen**: Wildcard records to be resolved and the correct response to be returned.

**How to reproduce it (as minimally and precisely as possible)**: Create a private hosted zone called `okd.myc.io`, create either a A or CNAME wildcard record with the following name '*.apps.okd.myc.io' and any value depending on the record type, configure CoreDNS, start it and try to resolve the record using:

`dig -p 1053 @localhost test.apps.okd.myc.io`

**Anything else we need to know?**: Specific records work great, wildcards do not.

**Environment**: 

- the version of CoreDNS: 1.7.0
- Corefile:

```
(common) {
    errors
    log . {
      class denial error
    }
    nsid
}

okd.myc.io:1053 {
    import common
    route53 okd.myc.io.:PRIVATE_HOSTED_ZONE_ID {
      aws_access_key AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
    }
}

```

- logs, if applicable:

```
[INFO] [::1]:52256 - 23778 "A IN test.apps.okd.myc.io. udp 51 false 4096" NXDOMAIN qr,aa,rd 139 0.000084316s
[INFO] [::1]:57990 - 3275 "CNAME IN test.apps.okd.myc.io. udp 51 false 4096" NXDOMAIN qr,aa,rd 139 0.000071072s
```

- OS (e.g: `cat /etc/os-release`): Fedora CoreOS 32.20200715.3.0

- Others: Tested on Fedora CoreOS running CoreDNS 1.7.0 using podman and CoreDNS 1.7.0 binary running on macOS. AWS hosted zone name is `okd.myc.io`, tested with A and CNAME record with name `*.apps.okd.myc.io` and respective value `10.0.255.3`, `lb-web-pub.fsn1.okd.myc.io`.

And also thank you for building this awesome tool!

Pull request:
Fix wildcard records issue in rout53 plugin

<!--
Thank you for contributing to CoreDNS!
Please provide the following information to help us make the most of your pull request:
-->

### 1. Why is this pull request needed and what does it do?

This PR tries to address #4035 where wild card records does not return
correctly in route53 plugin. The issue was that `strings.Index(s, substr string)`
expect substr to be a string but the code defines as char.

### 2. Which issues (if any) are related?


This PR fixes #4035.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>


Patch:
diff --git a/plugin/route53/route53.go b/plugin/route53/route53.go
index c86d5f0f5..c1e495fbf 100644
--- a/plugin/route53/route53.go
+++ b/plugin/route53/route53.go
@@ -148,7 +148,7 @@ func (h *Route53) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
 	return dns.RcodeSuccess, nil
 }
 
-const escapeSeq = `\\`
+const escapeSeq = "\\"
 
 // maybeUnescape parses s and converts escaped ASCII codepoints (in octal) back
 // to its ASCII representation.


Test patch:
diff --git a/plugin/route53/route53_test.go b/plugin/route53/route53_test.go
index 4b3fe1ebe..cc5540b6b 100644
--- a/plugin/route53/route53_test.go
+++ b/plugin/route53/route53_test.go
@@ -37,7 +37,7 @@ func (fakeRoute53) ListResourceRecordSetsPagesWithContext(_ aws.Context, in *rou
 	}{
 		{"A", "example.org.", "1.2.3.4", "1234567890"},
 		{"A", "www.example.org", "1.2.3.4", "1234567890"},
-		{"CNAME", `\\052.www.example.org`, "www.example.org", "1234567890"},
+		{"CNAME", `\052.www.example.org`, "www.example.org", "1234567890"},
 		{"AAAA", "example.org.", "2001:db8:85a3::8a2e:370:7334", "1234567890"},
 		{"CNAME", "sample.example.org.", "example.org", "1234567890"},
 		{"PTR", "example.org.", "ptr.example.org.", "1234567890"},
@@ -275,17 +275,17 @@ func TestMaybeUnescape(t *testing.T) {
 		// 1. non-escaped sequence.
 		{escaped: "example.com.", want: "example.com."},
 		// 2. escaped `*` as first label - OK.
-		{escaped: `\\052.example.com`, want: "*.example.com"},
+		{escaped: `\052.example.com`, want: "*.example.com"},
 		// 3. Escaped dot, 'a' and a hyphen. No idea why but we'll allow it.
-		{escaped: `weird\\055ex\\141mple\\056com\\056\\056`, want: "weird-example.com.."},
+		{escaped: `weird\055ex\141mple\056com\056\056`, want: "weird-example.com.."},
 		// 4. escaped `*` in the middle - NOT OK.
-		{escaped: `e\\052ample.com`, wantErr: errors.New("`*' only supported as wildcard (leftmost label)")},
+		{escaped: `e\052ample.com`, wantErr: errors.New("`*' only supported as wildcard (leftmost label)")},
 		// 5. Invalid character.
-		{escaped: `\\000.example.com`, wantErr: errors.New(`invalid character: \\000`)},
+		{escaped: `\000.example.com`, wantErr: errors.New(`invalid character: \000`)},
 		// 6. Invalid escape sequence in the middle.
-		{escaped: `example\\0com`, wantErr: errors.New(`invalid escape sequence: '\\0co'`)},
+		{escaped: `example\0com`, wantErr: errors.New(`invalid escape sequence: '\0co'`)},
 		// 7. Invalid escape sequence at the end.
-		{escaped: `example.com\\0`, wantErr: errors.New(`invalid escape sequence: '\\0'`)},
+		{escaped: `example.com\0`, wantErr: errors.New(`invalid escape sequence: '\0'`)},
 	} {
 		got, gotErr := maybeUnescape(tc.escaped)
 		if tc.wantErr != gotErr && !reflect.DeepEqual(tc.wantErr, gotErr) {