File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -119,9 +119,32 @@ var parseInterval = function(val) {
119
119
} ;
120
120
121
121
var parseByteA = function ( val ) {
122
- return new Buffer ( val . replace ( / \\ ( [ 0 - 7 ] { 3 } ) / g, function ( full_match , code ) {
123
- return String . fromCharCode ( parseInt ( code , 8 ) ) ;
124
- } ) . replace ( / \\ \\ / g, "\\" ) , "binary" ) ;
122
+ if ( / ^ \\ x / . test ( val ) ) {
123
+ // new 'hex' style response (pg >9.0)
124
+ return new Buffer ( val . substr ( 2 ) , 'hex' ) ;
125
+ } else {
126
+ out = ""
127
+ i = 0
128
+ while ( i < val . length ) {
129
+ if ( val [ i ] != "\\" ) {
130
+ out += val [ i ]
131
+ ++ i
132
+ } else {
133
+ if ( val . substr ( i + 1 , 3 ) . match ( / [ 0 - 7 ] { 3 } / ) ) {
134
+ out += String . fromCharCode ( parseInt ( val . substr ( i + 1 , 3 ) , 8 ) )
135
+ i += 4
136
+ } else {
137
+ backslashes = 1
138
+ while ( i + backslashes < val . length && val [ i + backslashes ] == "\\" )
139
+ backslashes ++
140
+ for ( k = 0 ; k < Math . floor ( backslashes / 2 ) ; ++ k )
141
+ out += "\\"
142
+ i += Math . floor ( backslashes / 2 ) * 2
143
+ }
144
+ }
145
+ }
146
+ return new Buffer ( out , "binary" ) ;
147
+ }
125
148
}
126
149
127
150
var maxLen = Number . MAX_VALUE . toString ( ) . length
You can’t perform that action at this time.
0 commit comments