@@ -10,12 +10,13 @@ import (
10
10
11
11
var (
12
12
// escapes from xml.Encode
13
- escQuot = []byte (""" ) // shorter than """, \"
14
- escApos = []byte ("'" ) // shorter than "'", \'
15
- escTab = []byte ("	" )
16
- escNL = []byte ("
" )
17
- escCR = []byte ("
" )
18
- escFFFD = []byte ("\uFFFD " ) // Unicode replacement character
13
+ escQuot = []byte (""" ) // shorter than """, \"
14
+ escApos = []byte ("'" ) // shorter than "'", \'
15
+ escTab = []byte ("	" )
16
+ escNL = []byte ("
" )
17
+ escCR = []byte ("
" )
18
+ escBacktick = []byte ("`" )
19
+ escFFFD = []byte ("\uFFFD " ) // Unicode replacement character
19
20
20
21
// escapes for irods
21
22
irodsEscQuot = []byte (""" )
@@ -122,6 +123,10 @@ func correctXMLRequest(in []byte, newXML bool) ([]byte, error) {
122
123
out .WriteByte ('\'' )
123
124
}
124
125
buf = buf [len (escApos ):]
126
+ // turn ` into '
127
+ case buf [0 ] == '`' && ! newXML :
128
+ out .Write (irodsEscApos )
129
+ buf = buf [1 :]
125
130
// irods does not decode encoded tabs
126
131
case bytes .HasPrefix (buf , escTab ):
127
132
out .WriteByte ('\t' )
@@ -134,10 +139,6 @@ func correctXMLRequest(in []byte, newXML bool) ([]byte, error) {
134
139
case bytes .HasPrefix (buf , escNL ):
135
140
out .WriteByte ('\n' )
136
141
buf = buf [len (escNL ):]
137
- // turn ` into '
138
- case buf [0 ] == '`' && ! newXML :
139
- out .Write (irodsEscApos )
140
- buf = buf [1 :]
141
142
// pass utf8 characters
142
143
default :
143
144
r , size := utf8 .DecodeRune (buf )
@@ -203,12 +204,19 @@ func correctXMLResponse(in []byte, newXML bool) ([]byte, error) {
203
204
204
205
for len (buf ) > 0 {
205
206
switch {
206
- // turn " into `
207
+ // turn " into "
207
208
case bytes .HasPrefix (buf , irodsEscQuot ) && ! newXML :
208
- out .WriteByte ( '`' )
209
+ out .Write ( escQuot )
209
210
buf = buf [len (irodsEscQuot ):]
210
- // turn ' into '
211
- case buf [0 ] == '\'' && ! newXML :
211
+ // turn ' into ' or `
212
+ case bytes .HasPrefix (buf , irodsEscApos ):
213
+ if newXML {
214
+ out .Write (escApos )
215
+ } else {
216
+ out .Write (escBacktick )
217
+ }
218
+ buf = buf [len (irodsEscApos ):]
219
+ case buf [0 ] == '\'' :
212
220
out .Write (escApos )
213
221
buf = buf [1 :]
214
222
// check utf8 characters for validity
0 commit comments