View Issue Details

IDProjectCategoryView StatusLast Update
0001682XdebugStep Debuggingpublic2019-07-25 14:19
Reporterarnaud-lb Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version2.7.2 
Target Version2.8.0devFixed in Version2.8.0beta1 
Summary0001682: Invalid character reference (null byte) in debugger XML
Description

When debugging, the XML might contain encoded null bytes (�). These appear to not be allowed in XML, and they cause a parse error in libxml.

Example:

classname="class@anonymous�/tmp/phpstan-tests/cache/nette.configurator/Container_6005a4979b.php0x7fbf3b58444b"

In vim/vdebug, this results in the following error:

An error occured: <class 'xml.etree.ElementTree.ParseError'>
Traceback (most recent call last):
File "/home/mention/.config/nvim/plugged/vdebug/python3/vdebug/event.py", line 722, in dispatch_event
Dispatcher.eventsname.run(*args)
File "/home/mention/.config/nvim/plugged/vdebug/python3/vdebug/event.py", line 601, in run
self.ui.windows.watch().accept_renderer(rend)
File "/home/mention/.config/nvim/plugged/vdebug/python3/vdebug/ui/vimui.py", line 540, in accept_renderer
self.write(renderer.render())
File "/home/mention/.config/nvim/plugged/vdebug/python3/vdebug/ui/vimui.py", line 788, in render
properties = self.response.get_context()
File "/home/mention/.config/nvim/plugged/vdebug/python3/vdebug/dbgp.py", line 127, in get_context
for c in list(self.as_xml()):
File "<string>", line None
xml.etree.ElementTree.ParseError: reference to invalid character number: line 2, column 5855

TagsNo tags attached.
Attached Files
Operating System
PHP Version7.3.5-7.3.9

Activities

arnaud-lb

2019-07-11 08:10

reporter   ~0005053

Mantis apparently converted my xml-encoded null bytes to actual null bytes. Please read &#0; instead of �

derick

2019-07-11 08:42

administrator   ~0005054

Can you please add the additional information as is requested at https://xdebug.org/support.php#remote ?

arnaud-lb

2019-07-11 18:18

reporter   ~0005055

Sure! Here is a reproducing script, and the xdebug.log. You can see the encoded null byte at line 25, after the <code>context_get -i 7 -c 0 -d 0</code> command.

bug.php (42 bytes)   
<?php

$a = new class { };

var_dump($a);
bug.php (42 bytes)   
xdebug.log (3,280 bytes)   
[28489] Log opened at 2019-07-11 18:09:24
[28489] I: Connecting to configured address/port: 127.0.0.1:9000.
[28489] I: Connected to client. :-)
[28489] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///home/mention/xdebug1682/bug.php" language="PHP" xdebug:language_version="7.1.24" protocol_version="1.0" appid="28489" idekey="xdebug"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[28489]
[28489] <- context_names -i 1
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_names" transaction_id="1"><context name="Locals" id="0"></context><context name="Superglobals" id="1"></context><context name="User defined constants" id="2"></context></response>
[28489]
[28489] <- step_into -i 2
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file:///home/mention/xdebug1682/bug.php" lineno="3"></xdebug:message></response>
[28489]
[28489] <- stack_get -i 3
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="3"><stack where="{main}" level="0" type="file" filename="file:///home/mention/xdebug1682/bug.php" lineno="3"></stack></response>
[28489]
[28489] <- context_get -i 4 -c 0 -d 0
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="$a" fullname="$a" type="uninitialized"></property></response>
[28489]
[28489] <- step_over -i 5
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_over" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file:///home/mention/xdebug1682/bug.php" lineno="5"></xdebug:message></response>
[28489]
[28489] <- stack_get -i 6
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="6"><stack where="{main}" level="0" type="file" filename="file:///home/mention/xdebug1682/bug.php" lineno="5"></stack></response>
[28489]
[28489] <- context_get -i 7 -c 0 -d 0
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="7" context="0"><property name="$a" fullname="$a" type="object" classname="class@anonymous&#0;/home/mention/xdebug1682/bug.php0x7f45a3d6d018" children="0" numchildren="0" page="0" pagesize="32"></property></response>
[28489]
[28489] <- stop -i 8
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="8" status="stopped" reason="ok"></response>
[28489]
[28489] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="8" status="stopping" reason="ok"></response>
[28489]
[28489] Log closed at 2019-07-11 18:09:41
[28489]
xdebug.log (3,280 bytes)   

derick

2019-07-15 14:48

administrator   ~0005059

Fixed in GitHub for 2.8.0alpha2

arnaud-lb

2019-07-17 11:25

reporter   ~0005065

Thanks !

derick

2019-07-17 11:44

administrator   ~0005066

Please note that your IDE still needs to set that extended_properties feature for this to work.

derick

2019-07-19 13:34

administrator   ~0005076

Hi,

(seem that I wrote this note, but never posted it)

I did have a look, and although there is a bug here, it is not the one you've brought up. The DBGp protocol has a specific feature to turn on "extended_properties" (https://xdebug.org/docs-dbgp.php#extended-properties) that IDEs need to opt into to work around the problem if having invalid XML characters in attribute values. This is an opt-in feature, as otherwise IDEs that don't enable it might get data back they originally did not expect.

The bug here is that when either of the "name, fullname, classname or value" elements needs to be encoded, all need to be encoded. And Xdebug does not do that at the moment: it will only do the "classname" as extended property if invalid XML characters are found, but not name or fullname.

The latter is now fixed for Xdebug 2.8.0alpha2.

cheers,
Derick

Issue History

Date Modified Username Field Change
2019-07-11 08:08 arnaud-lb New Issue
2019-07-11 08:10 arnaud-lb Note Added: 0005053
2019-07-11 08:42 derick Assigned To => derick
2019-07-11 08:42 derick Status new => feedback
2019-07-11 08:42 derick Note Added: 0005054
2019-07-11 18:18 arnaud-lb File Added: bug.php
2019-07-11 18:18 arnaud-lb File Added: xdebug.log
2019-07-11 18:18 arnaud-lb Note Added: 0005055
2019-07-11 18:18 arnaud-lb Status feedback => assigned
2019-07-11 19:32 derick Status assigned => confirmed
2019-07-11 19:32 derick Target Version => 2.8.0dev
2019-07-15 14:48 derick Status confirmed => closed
2019-07-15 14:48 derick Resolution open => fixed
2019-07-15 14:48 derick Fixed in Version => 2.8.0dev
2019-07-15 14:48 derick Note Added: 0005059
2019-07-17 11:25 arnaud-lb Note Added: 0005065
2019-07-17 11:44 derick Note Added: 0005066
2019-07-19 13:34 derick Note Added: 0005076
2019-07-25 14:19 derick Fixed in Version 2.8.0dev => 2.8.0beta1
2020-03-12 16:33 derick Category Remote Debugging => Step Debugging