Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d411301

Browse files
committed
bug #25816 Problem in phar see mergerequest #25579 (betzholz)
This PR was squashed before being merged into the 2.7 branch (closes #25816). Discussion ---------- Problem in phar see mergerequest #25579 | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> If packed into phar the old version creates path like 'file:///phar%3A/'. see #25579 Commits ------- 3e0c8ff Problem in phar see mergerequest #25579
2 parents e6e235b + 3e0c8ff commit d411301

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,16 +458,20 @@ public function validateSchema(\DOMDocument $dom)
458458
$imports = '';
459459
foreach ($schemaLocations as $namespace => $location) {
460460
$parts = explode('/', $location);
461+
$locationstart = 'file:///';
461462
if (0 === stripos($location, 'phar://')) {
462463
$tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
463464
if ($tmpfile) {
464465
copy($location, $tmpfile);
465466
$tmpfiles[] = $tmpfile;
466467
$parts = explode('/', str_replace('\\', '/', $tmpfile));
468+
} else {
469+
array_shift($parts);
470+
$locationstart = 'phar:///';
467471
}
468472
}
469473
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
470-
$location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
474+
$location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts));
471475

472476
$imports .= sprintf(' <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location);
473477
}

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,19 @@ private function parseFile($file)
129129

130130
$location = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd';
131131
$parts = explode('/', $location);
132+
$locationstart = 'file:///';
132133
if (0 === stripos($location, 'phar://')) {
133134
$tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
134135
if ($tmpfile) {
135136
copy($location, $tmpfile);
136137
$parts = explode('/', str_replace('\\', '/', $tmpfile));
138+
} else {
139+
array_shift($parts);
140+
$locationstart = 'phar:///';
137141
}
138142
}
139143
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
140-
$location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
144+
$location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts));
141145

142146
$source = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-1.2-strict.xsd');
143147
$source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source);

0 commit comments

Comments
 (0)