Skip to content

Commit 671ee89

Browse files
bug #19950 [FrameworkBundle] Parse source link maps using json_decode() instead of parse_str() (nicolas-grekas)
This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Parse source link maps using json_decode() instead of parse_str() | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | updated code exists only on master | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19807 | License | MIT | Doc PR | symfony/symfony-docs#6944 Because `parse_str()` turns some characters into underscores in keys (e.g. `.`). Commits ------- 9b174fb [FrameworkBundle] Parse source link maps using json_decode() instead of parse_str()
2 parents 7178d8c + 1077fa8 commit 671ee89

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Extension/CodeExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function __construct($fileLinkFormat, $rootDir, $charset)
3434
$fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
3535
if ($fileLinkFormat && !is_array($fileLinkFormat)) {
3636
$i = max(strpos($fileLinkFormat, '%f'), strpos($fileLinkFormat, '%l'));
37-
$i = strpos($fileLinkFormat, '#', $i) ?: strlen($fileLinkFormat);
37+
$i = strpos($fileLinkFormat, '#"', $i) ?: strlen($fileLinkFormat);
3838
$fileLinkFormat = array(substr($fileLinkFormat, 0, $i), substr($fileLinkFormat, $i + 1));
39-
parse_str($fileLinkFormat[1], $fileLinkFormat[1]);
39+
$fileLinkFormat[1] = @json_decode('{'.$fileLinkFormat[1].'}', true) ?: array();
4040
}
4141
$this->fileLinkFormat = $fileLinkFormat;
4242
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR;

Tests/Extension/CodeExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ public function testGetName()
6464

6565
protected function getExtension()
6666
{
67-
return new CodeExtension('proto://%f#&line=%l#'.substr(__FILE__, 0, 5).'=foobar', '/root', 'UTF-8');
67+
return new CodeExtension('proto://%f#&line=%l#'.json_encode(substr(__FILE__, 0, 5)).':"foobar"', '/root', 'UTF-8');
6868
}
6969
}

0 commit comments

Comments
 (0)