mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Fix #5767
This commit is contained in:
@@ -108,6 +108,9 @@ func (s escaped_string) MarshalJSON() ([]byte, error) {
|
|||||||
a('"')
|
a('"')
|
||||||
for _, r := range src {
|
for _, r := range src {
|
||||||
if ' ' <= r && r <= 126 {
|
if ' ' <= r && r <= 126 {
|
||||||
|
if r == '\\' || r == '"' {
|
||||||
|
buf = append(buf, '\\')
|
||||||
|
}
|
||||||
buf = append(buf, byte(r))
|
buf = append(buf, byte(r))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -122,10 +125,6 @@ func (s escaped_string) MarshalJSON() ([]byte, error) {
|
|||||||
a('\\', 'f')
|
a('\\', 'f')
|
||||||
case '\b':
|
case '\b':
|
||||||
a('\\', 'b')
|
a('\\', 'b')
|
||||||
case '\\':
|
|
||||||
a('\\', '\\')
|
|
||||||
case '"':
|
|
||||||
a('\\', '"')
|
|
||||||
default:
|
default:
|
||||||
a('\\', 'u')
|
a('\\', 'u')
|
||||||
for s := 12; s >= 0; s -= 4 {
|
for s := 12; s >= 0; s -= 4 {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ func TestEncodeJSON(t *testing.T) {
|
|||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
"a b\nc\td\a": `a b\nc\td\u0007`,
|
"a b\nc\td\a": `a b\nc\td\u0007`,
|
||||||
"•": `\u2022`,
|
"•": `\u2022`,
|
||||||
|
`a"b`: `a\"b`,
|
||||||
"\U0001f123": `\ud83c\udd23`,
|
"\U0001f123": `\ud83c\udd23`,
|
||||||
}
|
}
|
||||||
var s escaped_string
|
var s escaped_string
|
||||||
|
|||||||
@@ -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)
|
return fmt.Errorf("Could not detect the MIME type for: %s use --mime to specify it manually", arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
for _, o := range outputs {
|
for _, o := range outputs {
|
||||||
if o.dest != nil {
|
if o.dest != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user