Skip to content

Commit

Permalink
Escaping only necessary signs
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlif committed Jun 3, 2022
1 parent c6c5c68 commit 1c0dc40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions extract/extractors/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,8 @@ func prepareString(s string) string {

for _, r := range s {
switch r {
case '\\':
b.WriteString(`\\`)
case '"':
b.WriteString(`\"`)
case '\t':
b.WriteString(`\t`)
default:
b.WriteRune(r)
}
Expand Down
6 changes: 6 additions & 0 deletions extract/extractors/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func TestExtractStringLiteral(t *testing.T) {
wantStr: "This is an \\\"Test\\\" abc",
wantFound: true,
},
{
name: "Escaping",
code: `"\\caf\u00e9"`,
wantStr: `\café`,
wantFound: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 1c0dc40

Please sign in to comment.