View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001512 | Xdebug | Step Debugging | public | 2018-01-05 12:45 | 2018-01-22 18:21 |
| Reporter | LanaZem | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 2.6.0beta1 | ||||
| Target Version | 2.6.0 | Fixed in Version | 2.6.0rc1 | ||
| Summary | 0001512: Xdebug does not properly encode and escape properties with quotes and \0 characters. | ||||
| Description | If class fqn is included in property name Xdebug will escape "name" and "fullname" in 'property_get' response. If no fqn is included then only "fullname" will be escaped. | ||||
| Steps To Reproduce | 1) Create a php file namespace TestA\TestB\TestC; class A
} class B extends A { (new B())->foo(); 2) Put breakpoint inside 'foo' method and start debugging. 3) Call 'property_get' command for 'TestA\TestB\TestC\Aitems'. Expected: Actual: 4) Call 'property_get' command for '$v[0]' Expected: Actual: | ||||
| Tags | No tags attached. | ||||
| Operating System | |||||
| PHP Version | 7.1.0-7.1.4 | ||||
|
|
Xdebug's, and your's, assumption that you should escape the \ already when doing property_get in step 3 is actually wrong: <- property_get -i 18 -n $this->TestA\TestB\TestC\Aitems -d 0 -c 0 -p 0 It should be either: <- property_get -i 18 -n "$this->TestA\TestB\TestC\Aitems" -d 0 -c 0 -p 0 or <- property_get -i 18 -n $this->TestA\TestB\TestC\Aitems -d 0 -c 0 -p 0 Xdebug does currently not do this correctly either. The DBGp specs say (in https://xdebug.org/docs-dbgp.php#message-packets):
As Xdebug has returned, through XML, just: fullname="$this->TestA\TestB\TestC\Aitems" which, after XML decoding shows: $this->TestA\TestB\TestC\Aitems There is no space in this, so there is no NEED to enclose them in "'s, or does the spec say anything about escaping the \'s. The spec hints that if you enclose them in "'s, you must also escape the \'s. I propose we do the following:
This is likely going to break existing behaviour, so you might want to change behaviour depending on Xdebug version, send to PhpStorm in the init package with: |
|
|
I've added a PR for DBGp, please review: https://github.com/derickr/dbgp/pull/17 |
|
|
Looks good for me. From IDE side the behaviour is the same as for Xdebug 2.5 and earlier. |
|
|
That's not 100% true - please see this again: Your assumption that you should escape the \ already when doing <- property_get -i 18 -n $this->TestA\TestB\TestC\Aitems -d 0 -c 0 -p 0 It should be either: <- property_get -i 18 -n "$this->TestA\TestB\TestC\Aitems" -d 0 -c 0 -p 0 or <- property_get -i 18 -n $this->TestA\TestB\TestC\Aitems -d 0 -c 0 -p 0 |
|
|
Do you mean Xdebug 2.5 doesn't require escaping inside quotes? For me, the command with escaped value works perfectly fine with Xdebug 2.5.5 + PHP 7.1.1 or PHP 5.6.30 <- property_get -i 23 -n "$this->PhpStormBug917319\ParentClass_attributes['Three\s Stuff']" -d 0 -c 0 -p 0 |
|
|
Inside double quotes, you MUST escape, like you do: property_get -i 23 -n "$this->PhpStormBug917319\ParentClass_attributes['Three\s Stuff']" And I showed with: property_get -i 18 -n "$this->TestA\TestB\TestC\Aitems" -d 0 -c 0 -p 0 Not using double quotes, you MUST NOT escape, like I showed with: <- property_get -i 18 -n $this->TestA\TestB\TestC\Aitems -d 0 -c 0 -p 0 In the original description of the bug, you wrote: 3) Call 'property_get' command for 'TestA\TestB\TestC\Aitems'. But this uses escaped \ characters outside double quotes, which is incorrect. Xdebug 2.5 would allow this, but should not have. Xdebug 2.6 will not allow this, after my merge of https://github.com/xdebug/xdebug/commit/307009a46ff63f15ea6e1e1e3c66637314089ab8 |
|
|
I understand that your suggestion in comments is different from the issue description. I'm saying that Xdebug 2.5 does follow the same rules, e.g. The command with escaped blackslashes will fail in Xdebug 2.5 too: |