Merge pull request #542 from router-for-me/aistudio
docker-image / docker (push) Has been cancelled
goreleaser / goreleaser (push) Has been cancelled

This commit is contained in:
Chén Mù
2025-12-15 09:13:25 +08:00
committed by GitHub
@@ -384,9 +384,17 @@ func ensureColonSpacedJSON(payload []byte) []byte {
for i := 0; i < len(indented); i++ { for i := 0; i < len(indented); i++ {
ch := indented[i] ch := indented[i]
if ch == '"' && (i == 0 || indented[i-1] != '\\') { if ch == '"' {
// A quote is escaped only when preceded by an odd number of consecutive backslashes.
// For example: "\\\"" keeps the quote inside the string, but "\\\\" closes the string.
backslashes := 0
for j := i - 1; j >= 0 && indented[j] == '\\'; j-- {
backslashes++
}
if backslashes%2 == 0 {
inString = !inString inString = !inString
} }
}
if !inString { if !inString {
if ch == '\n' || ch == '\r' { if ch == '\n' || ch == '\r' {