Skip to content

Commit 0579a4a

Browse files
authored
Always escape values in comments as per specification (#217)
* Always escape values in comments as per specification * escape
1 parent 36ce7d3 commit 0579a4a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

go/core/core.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type CommenterOptions struct {
5757
}
5858

5959
func encodeURL(k string) string {
60-
return url.QueryEscape(string(k))
60+
return url.QueryEscape(k)
6161
}
6262

6363
func GetFunctionName(i interface{}) string {
@@ -71,7 +71,7 @@ func ConvertMapToComment(tags map[string]string) string {
7171
var sb strings.Builder
7272
i, sz := 0, len(tags)
7373

74-
//sort by keys
74+
// sort by keys
7575
sortedKeys := make([]string, 0, len(tags))
7676
for k := range tags {
7777
sortedKeys = append(sortedKeys, k)
@@ -80,9 +80,9 @@ func ConvertMapToComment(tags map[string]string) string {
8080

8181
for _, key := range sortedKeys {
8282
if i == sz-1 {
83-
sb.WriteString(fmt.Sprintf("%s=%v", encodeURL(key), encodeURL(tags[key])))
83+
sb.WriteString(fmt.Sprintf("%s='%s'", encodeURL(key), encodeURL(tags[key])))
8484
} else {
85-
sb.WriteString(fmt.Sprintf("%s=%v,", encodeURL(key), encodeURL(tags[key])))
85+
sb.WriteString(fmt.Sprintf("%s='%s',", encodeURL(key), encodeURL(tags[key])))
8686
}
8787
i++
8888
}

0 commit comments

Comments
 (0)