This commit is contained in:
Kovid Goyal 2022-12-13 10:20:02 +05:30
parent fefafda9a0
commit 0ab618c2dc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 5 additions and 4 deletions

View File

@ -108,6 +108,9 @@ func (s escaped_string) MarshalJSON() ([]byte, error) {
a('"')
for _, r := range src {
if ' ' <= r && r <= 126 {
if r == '\\' || r == '"' {
buf = append(buf, '\\')
}
buf = append(buf, byte(r))
continue
}
@ -122,10 +125,6 @@ func (s escaped_string) MarshalJSON() ([]byte, error) {
a('\\', 'f')
case '\b':
a('\\', 'b')
case '\\':
a('\\', '\\')
case '"':
a('\\', '"')
default:
a('\\', 'u')
for s := 12; s >= 0; s -= 4 {

View File

@ -14,6 +14,7 @@ func TestEncodeJSON(t *testing.T) {
tests := map[string]string{
"a b\nc\td\a": `a b\nc\td\u0007`,
"•": `\u2022`,
`a"b`: `a\"b`,
"\U0001f123": `\ud83c\udd23`,
}
var s escaped_string

View File

@ -302,6 +302,7 @@ func run_get_loop(opts *Options, args []string) (err error) {
return fmt.Errorf("Could not detect the MIME type for: %s use --mime to specify it manually", arg)
}
}
defer func() {
for _, o := range outputs {
if o.dest != nil {