@@ -629,6 +629,36 @@ public function testParsePTRResponse()
629629 $ this ->assertSame ('google-public-dns-b.google.com ' , $ response ->answers [0 ]->data );
630630 }
631631
632+ public function testParsePTRResponseWithSpecialCharactersEscaped ()
633+ {
634+ $ data = "" ;
635+ $ data .= "5d d8 81 80 00 01 00 01 00 00 00 00 " ; // header
636+ $ data .= "08 5f 70 72 69 6e 74 65 72 04 5f 74 63 70 06 64 6e 73 2d 73 64 03 6f 72 67 00 " ; // question: _printer._tcp.dns-sd.org
637+ $ data .= "00 0c 00 01 " ; // question: type PTR, class IN
638+ $ data .= "c0 0c " ; // answer: offset pointer to rdata
639+ $ data .= "00 0c 00 01 " ; // answer: type PTR, class IN
640+ $ data .= "00 01 51 7f " ; // answer: ttl 86399
641+ $ data .= "00 17 " ; // answer: rdlength 23
642+ $ data .= "14 33 72 64 2e 20 46 6c 6f 6f 72 20 43 6f 70 79 20 52 6f 6f 6d " ; // answer: rdata "3rd. Floor Copy Room" …
643+ $ data .= "c0 0c " ; // answer: offset pointer to rdata
644+
645+ $ data = $ this ->convertTcpDumpToBinary ($ data );
646+
647+ $ response = $ this ->parser ->parseMessage ($ data );
648+
649+ $ this ->assertCount (1 , $ response ->questions );
650+ $ this ->assertSame ('_printer._tcp.dns-sd.org ' , $ response ->questions [0 ]->name );
651+ $ this ->assertSame (Message::TYPE_PTR , $ response ->questions [0 ]->type );
652+ $ this ->assertSame (Message::CLASS_IN , $ response ->questions [0 ]->class );
653+
654+ $ this ->assertCount (1 , $ response ->answers );
655+ $ this ->assertSame ('_printer._tcp.dns-sd.org ' , $ response ->answers [0 ]->name );
656+ $ this ->assertSame (Message::TYPE_PTR , $ response ->answers [0 ]->type );
657+ $ this ->assertSame (Message::CLASS_IN , $ response ->answers [0 ]->class );
658+ $ this ->assertSame (86399 , $ response ->answers [0 ]->ttl );
659+ $ this ->assertSame ('3rd\.\ Floor\ Copy\ Room._printer._tcp.dns-sd.org ' , $ response ->answers [0 ]->data );
660+ }
661+
632662 /**
633663 * @expectedException InvalidArgumentException
634664 */
0 commit comments