View Issue Details

IDProjectCategoryView StatusLast Update
0001682XdebugRemote Debuggingpublic2019-07-19 13:34
Reporterarnaud-lbAssigned Toderick 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version2.7.2 
Target Version2.8.0devFixed in Version2.8.0dev 
Summary0001682: Invalid character reference (null byte) in debugger XML
DescriptionWhen 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.events[name](self.__session_handler).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.
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)
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