@@ -29,6 +29,8 @@ func ParseArr(str string) ([]string, error) {
29
29
newstr = strings .ReplaceAll (newstr , " ]" , "]" )
30
30
newstr = strings .ReplaceAll (newstr , "[ " , "[" )
31
31
newstr = strings .ReplaceAll (newstr , " " , " " )
32
+ // 特殊处理 ', 不进行转义分析
33
+ newstr = strings .ReplaceAll (newstr , "'" , "@&@" )
32
34
newstr = strings .TrimSpace (newstr )
33
35
if len (newstr ) == len (str ) {
34
36
break
@@ -75,6 +77,10 @@ func ParseArr(str string) ([]string, error) {
75
77
kend = i
76
78
key = str [kstart :kend ]
77
79
kstart = i + 1
80
+ key = strings .TrimSpace (key )
81
+ key = strings .TrimPrefix (key , `"` )
82
+ key = strings .TrimSuffix (key , `"` )
83
+ key = strings .ReplaceAll (key , `@&@` , `'` )
78
84
result = append (result , key )
79
85
}
80
86
continue
@@ -86,6 +92,10 @@ func ParseArr(str string) ([]string, error) {
86
92
return nil , errors .New ("grammar error for:" + str )
87
93
}
88
94
key = str [kstart :kend ]
95
+ key = strings .TrimSpace (key )
96
+ key = strings .TrimPrefix (key , `"` )
97
+ key = strings .TrimSuffix (key , `"` )
98
+ key = strings .ReplaceAll (key , `@&@` , `'` )
89
99
result = append (result , key )
90
100
return result , nil
91
101
} else {
@@ -109,6 +119,8 @@ func ParseKV(str string) (map[string]string, error) {
109
119
newstr = strings .ReplaceAll (newstr , ": " , ":" )
110
120
newstr = strings .ReplaceAll (newstr , " ," , "," )
111
121
newstr = strings .ReplaceAll (newstr , " " , " " )
122
+ // 特殊处理 ', 不进行转义分析
123
+ newstr = strings .ReplaceAll (newstr , "'" , "@&@" )
112
124
newstr = strings .TrimSpace (newstr )
113
125
if len (newstr ) == len (str ) {
114
126
break
@@ -171,7 +183,11 @@ func ParseKV(str string) (map[string]string, error) {
171
183
if strings .HasSuffix (value , "," ) {
172
184
value = strings .TrimSuffix (value , "," )
173
185
}
174
- result [strings .TrimSpace (key )] = strings .TrimSpace (value )
186
+ value = strings .TrimSpace (value )
187
+ value = strings .TrimPrefix (value , `"` )
188
+ value = strings .TrimSuffix (value , `"` )
189
+ value = strings .ReplaceAll (value , `@&@` , `'` )
190
+ result [strings .TrimSpace (key )] = value
175
191
}
176
192
continue
177
193
}
@@ -189,7 +205,11 @@ func ParseKV(str string) (map[string]string, error) {
189
205
if strings .HasSuffix (value , "," ) {
190
206
value = strings .TrimSuffix (value , "," )
191
207
}
192
- result [strings .TrimSpace (key )] = strings .TrimSpace (value )
208
+ value = strings .TrimSpace (value )
209
+ value = strings .TrimPrefix (value , `"` )
210
+ value = strings .TrimSuffix (value , `"` )
211
+ value = strings .ReplaceAll (value , `@&@` , `'` )
212
+ result [strings .TrimSpace (key )] = value
193
213
return result , nil
194
214
} else {
195
215
if dq && sq {
0 commit comments