Revert "Added function to sanitize strings by escaping quotes (#2360)" (#2367)

This reverts commit fe5e5f592b.
This commit is contained in:
Ankit Chawla
2022-02-21 15:34:38 +05:30
committed by GitHub
parent fe5e5f592b
commit 1d22b7596c
7 changed files with 1 additions and 61 deletions
-6
View File
@@ -205,9 +205,3 @@ func DownloadUrl(ctx context.Context, httpClient *http.Client, url string, local
return nil
}
func EscapeQuotes(str string) string {
replacer := strings.NewReplacer("\n", "", "\r", "", "\t", "", `"`, `\"`)
str = replacer.Replace(str)
return str
}
-37
View File
@@ -81,40 +81,3 @@ func TestGetChecksum(t *testing.T) {
})
}
}
func TestEscapeQuotes(t *testing.T) {
tests := []struct {
name string
src string
want string
}{
{
name: "Testing tab escape sequence",
src: "This\tis\ta\ttest\t string.",
want: "Thisisatest string.",
},
{
name: "Testing carriage return",
src: "This is a \rtest string. \r This is the second test string\r.",
want: "This is a test string. This is the second test string.",
},
{
name: "Testing next line escape sequence",
src: "This is a \ntest string. \n This is the second test string\n.",
want: "This is a test string. This is the second test string.",
},
{
name: "Testing quotes",
src: `This is a "test string"". This is" the second test string "."`,
want: `This is a \"test string\"\". This is\" the second test string \".\"`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := EscapeQuotes(tt.src)
if got != tt.want {
t.Errorf("EscapeQuotes() got = %v, want = %v", got, tt.want)
}
})
}
}