@@ -398,7 +398,7 @@ export class SourceResponse extends Response {
398398 source : string
399399 constructor ( document : XMLDocument , connection : Connection ) {
400400 super ( document , connection )
401- this . source = new Buffer ( document . documentElement . textContent ! , 'base64' ) . toString ( )
401+ this . source = Buffer . from ( document . documentElement . textContent ! , 'base64' ) . toString ( )
402402 }
403403}
404404
@@ -464,20 +464,28 @@ export abstract class BaseProperty {
464464 constructor ( propertyNode : Element ) {
465465 if ( propertyNode . hasAttribute ( 'name' ) ) {
466466 this . name = propertyNode . getAttribute ( 'name' ) !
467+ } else if ( propertyNode . getElementsByTagName ( 'name' ) . length > 0 ) {
468+ this . name = decodeTag ( propertyNode , 'name' )
467469 }
468470 this . type = propertyNode . getAttribute ( 'type' ) !
469471 if ( propertyNode . hasAttribute ( 'classname' ) ) {
470472 this . class = propertyNode . getAttribute ( 'classname' ) !
473+ } else if ( propertyNode . getElementsByTagName ( 'classname' ) . length > 0 ) {
474+ this . class = decodeTag ( propertyNode , 'classname' )
471475 }
472476 this . hasChildren = ! ! parseInt ( propertyNode . getAttribute ( 'children' ) ! )
473477 if ( this . hasChildren ) {
474478 this . numberOfChildren = parseInt ( propertyNode . getAttribute ( 'numchildren' ) ! )
475479 } else {
476- const encoding = propertyNode . getAttribute ( 'encoding' )
477- if ( encoding ) {
478- this . value = iconv . encode ( propertyNode . textContent ! , encoding ) + ''
480+ if ( propertyNode . getElementsByTagName ( 'value' ) . length > 0 ) {
481+ this . value = decodeTag ( propertyNode , 'value' )
479482 } else {
480- this . value = propertyNode . textContent !
483+ const encoding = propertyNode . getAttribute ( 'encoding' )
484+ if ( encoding ) {
485+ this . value = iconv . encode ( propertyNode . textContent ! , encoding ) + ''
486+ } else {
487+ this . value = propertyNode . textContent !
488+ }
481489 }
482490 }
483491 }
@@ -498,7 +506,11 @@ export class Property extends BaseProperty {
498506 */
499507 constructor ( propertyNode : Element , context : Context ) {
500508 super ( propertyNode )
501- this . fullName = propertyNode . getAttribute ( 'fullname' ) !
509+ if ( propertyNode . hasAttribute ( 'fullname' ) ) {
510+ this . fullName = propertyNode . getAttribute ( 'fullname' ) !
511+ } else if ( propertyNode . getElementsByTagName ( 'fullname' ) . length > 0 ) {
512+ this . fullName = decodeTag ( propertyNode , 'fullname' )
513+ }
502514 this . context = context
503515 if ( this . hasChildren ) {
504516 this . children = Array . from ( propertyNode . childNodes ) . map (
@@ -518,6 +530,16 @@ export class Property extends BaseProperty {
518530 }
519531}
520532
533+ function decodeTag ( propertyNode : Element , tagName : string ) : string {
534+ const tag = propertyNode . getElementsByTagName ( tagName ) . item ( 0 ) !
535+ const encoding = tag . getAttribute ( 'encoding' )
536+ if ( encoding ) {
537+ return iconv . encode ( tag . textContent ! , encoding ) + ''
538+ } else {
539+ return tag . textContent !
540+ }
541+ }
542+
521543/** The response to a context_get command */
522544export class ContextGetResponse extends Response {
523545 /** the available properties inside the context */
@@ -741,7 +763,7 @@ export class Connection extends DbgpConnection {
741763 commandString += ' ' + command . args
742764 }
743765 if ( command . data ) {
744- commandString += ' -- ' + new Buffer ( command . data ) . toString ( 'base64' )
766+ commandString += ' -- ' + Buffer . from ( command . data ) . toString ( 'base64' )
745767 }
746768 commandString += '\0'
747769 const data = iconv . encode ( commandString , ENCODING )
0 commit comments