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) {
119119} ;
120120
121121var 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 ( val . match ( / ^ \\ x / ) ) {
123+ // new 'hex' style response (pg >9.0)
124+ return new Buffer ( val . replace ( / ^ \\ x / , '' ) , '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 . substring ( i + 1 , i + 4 ) . match ( / ( [ 0 - 7 ] ) { 3 } / ) ) {
134+ out += String . fromCharCode ( parseInt ( val . substring ( i + 1 , i + 4 ) , 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+ }
125148}
126149
127150var maxLen = Number . MAX_VALUE . toString ( ) . length
You can’t perform that action at this time.
0 commit comments