diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
index 316bd13f2f6ed..c055d46f2ebf4 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php
@@ -31,6 +31,7 @@ class WebProfilerExtensionTest extends TestCase
public static function assertSaneContainer(Container $container, $message = '', $knownPrivates = array())
{
$errors = array();
+ $knownPrivates[] = 'debug.file_link_formatter.url_format';
foreach ($container->getServiceIds() as $id) {
if (in_array($id, $knownPrivates, true)) { // to be removed in 4.0
continue;
diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php
index 97470cb6b4d01..f22b70f6e8c6f 100644
--- a/src/Symfony/Component/Debug/ExceptionHandler.php
+++ b/src/Symfony/Component/Debug/ExceptionHandler.php
@@ -40,7 +40,7 @@ public function __construct($debug = true, $charset = null, $fileLinkFormat = nu
{
$this->debug = $debug;
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
- $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
+ $this->fileLinkFormat = $fileLinkFormat;
}
/**
@@ -355,13 +355,29 @@ private function formatClass($class)
private function formatPath($path, $line)
{
$file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path);
- $fmt = $this->fileLinkFormat;
+ $fmt = $this->fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
+
+ if (!$fmt) {
+ return sprintf('
in %s%s', $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : '');
+ }
+
+ if (\is_string($fmt)) {
+ $i = strpos($f = $fmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f);
+ $fmt = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE);
+
+ for ($i = 1; isset($fmt[$i]); ++$i) {
+ if (0 === strpos($path, $k = $fmt[$i++])) {
+ $path = substr_replace($path, $fmt[$i], 0, strlen($k));
+ break;
+ }
+ }
- if ($fmt && $link = is_string($fmt) ? strtr($fmt, array('%f' => $path, '%l' => $line)) : $fmt->format($path, $line)) {
- return sprintf('
in %s (line %d)', $this->escapeHtml($link), $file, $line);
+ $link = strtr($fmt[0], array('%f' => $path, '%l' => $line));
+ } else {
+ $link = $fmt->format($path, $line);
}
- return sprintf('
in %s (line %d)', $this->escapeHtml($path), $file, $line);
+ return sprintf('
in %s%s', $this->escapeHtml($link), $file, 0 < $line ? ' line '.$line : '');
}
/**