@@ -187,7 +187,6 @@ impl DbgpClient {
187187 if xml. is_empty ( ) {
188188 return Err ( anyhow:: anyhow!( "Empty XML response" ) ) ;
189189 }
190- debug ! ( "[dbgp] << {}" , xml) ;
191190 parse_xml ( xml. as_str ( ) )
192191 }
193192
@@ -390,17 +389,24 @@ fn parse_context_get(element: &mut Element) -> Result<ContextGetResponse, anyhow
390389 while let Some ( mut child) = element. take_child ( "property" ) {
391390 let encoding = child. attributes . get ( "encoding" ) . map ( |s| s. to_string ( ) ) ;
392391 let p = Property {
393- name : child
392+ name : match child
394393 . attributes
395- . get ( "name" )
396- . expect ( "Expected name to be set" )
397- . to_string ( ) ,
398- fullname : child
394+ . get ( "name" ) {
395+ Some ( name) => name. to_string ( ) ,
396+ None => decode_element ( child. get_child ( "name" ) ) . unwrap_or ( "" . to_string ( ) )
397+ } ,
398+ fullname : match child
399399 . attributes
400- . get ( "name" )
401- . expect ( "Expected fullname to be set" )
402- . to_string ( ) ,
403- classname : child. attributes . get ( "classname" ) . map ( |s| s. to_string ( ) ) ,
400+ . get ( "fullname" ) {
401+ Some ( name) => name. to_string ( ) ,
402+ None => decode_element ( child. get_child ( "fullname" ) ) . unwrap_or ( "" . to_string ( ) )
403+ } ,
404+ classname : match child
405+ . attributes
406+ . get ( "classname" ) {
407+ Some ( name) => Some ( name. to_string ( ) ) ,
408+ None => decode_element ( child. get_child ( "classname" ) )
409+ } ,
404410 page : child
405411 . attributes
406412 . get ( "page" )
@@ -424,23 +430,33 @@ fn parse_context_get(element: &mut Element) -> Result<ContextGetResponse, anyhow
424430 address : child. attributes . get ( "address" ) . map ( |name| name. to_string ( ) ) ,
425431 encoding : encoding. clone ( ) ,
426432 children : parse_context_get ( & mut child) . unwrap ( ) . properties ,
427- value : match child. children . first ( ) {
428- Some ( XMLNode :: CData ( cdata) ) => Some ( match encoding {
433+ value : decode_element ( Some ( & child) ) ,
434+ } ;
435+ properties. push ( p) ;
436+ }
437+ Ok ( ContextGetResponse { properties } )
438+ }
439+
440+ fn decode_element ( element : Option < & Element > ) -> Option < String > {
441+ match element {
442+ Some ( e) => {
443+ let encoding = e. attributes . get ( "encoding" ) ;
444+ match e. children . first ( ) {
445+ Some ( XMLNode :: CData ( cdata) ) => match encoding {
429446 Some ( encoding) => match encoding. as_str ( ) {
430447 "base64" => {
431- String :: from_utf8 ( general_purpose:: STANDARD . decode ( cdata) . unwrap ( ) )
432- . unwrap ( )
448+ Some ( String :: from_utf8 ( general_purpose:: STANDARD . decode ( cdata) . unwrap ( ) )
449+ . unwrap ( ) )
433450 }
434- _ => cdata. to_string ( ) ,
451+ _ => Some ( cdata. to_string ( ) ) ,
435452 } ,
436- _ => cdata. to_string ( ) ,
437- } ) ,
453+ _ => Some ( cdata. to_string ( ) ) ,
454+ } ,
438455 _ => None ,
439- } ,
440- } ;
441- properties . push ( p ) ;
456+ }
457+ }
458+ None => None ,
442459 }
443- Ok ( ContextGetResponse { properties } )
444460}
445461
446462fn parse_stack_get ( element : & Element ) -> StackGetResponse {
@@ -594,6 +610,7 @@ function call_function(string $hello) {
594610 <property name="bar" fullname="$this->bar" facet="public" type="string" size="3" encoding="base64"><![CDATA[Zm9v]]></property>
595611 <property name="handle" fullname="$this->handle" facet="private" type="resource"><![CDATA[resource id='18' type='stream']]></property>
596612 </property>
613+ <property type="array"><name encoding="base64"><![CDATA[JGFycvCfmLhheQ==]]></name><fullname encoding="base64"><![CDATA[JGFycvCfmLhheQ==]]></fullname></property>
597614 </response>"# ,
598615 ) ?;
599616
@@ -675,7 +692,7 @@ function call_function(string $hello) {
675692 children: vec![
676693 Property {
677694 name: "true" . to_string( ) ,
678- fullname: "true" . to_string( ) ,
695+ fullname: "$this-> true" . to_string( ) ,
679696 classname: None ,
680697 page: None ,
681698 pagesize: None ,
@@ -690,7 +707,7 @@ function call_function(string $hello) {
690707 } ,
691708 Property {
692709 name: "bar" . to_string( ) ,
693- fullname: "bar" . to_string( ) ,
710+ fullname: "$this-> bar" . to_string( ) ,
694711 classname: None ,
695712 page: None ,
696713 pagesize: None ,
@@ -705,7 +722,7 @@ function call_function(string $hello) {
705722 } ,
706723 Property {
707724 name: "handle" . to_string( ) ,
708- fullname: "handle" . to_string( ) ,
725+ fullname: "$this-> handle" . to_string( ) ,
709726 classname: None ,
710727 page: None ,
711728 pagesize: None ,
@@ -724,6 +741,21 @@ function call_function(string $hello) {
724741 encoding: None ,
725742 value: None ,
726743 } ,
744+ Property {
745+ name: "$arr😸ay" . to_string( ) ,
746+ fullname: "$arr😸ay" . to_string( ) ,
747+ classname: None ,
748+ page: None ,
749+ pagesize: None ,
750+ property_type: PropertyType :: Array ,
751+ facet: None ,
752+ size: None ,
753+ children: vec![ ] ,
754+ key: None ,
755+ address: None ,
756+ encoding: None ,
757+ value: None ,
758+ } ,
727759 ] ,
728760 } ;
729761 assert_eq ! ( expected, response)
0 commit comments