Fabien Potencier преди 15 години
родител
ревизия
269651235a
променени са 2 файла, в които са добавени 13 реда и са изтрити 5 реда
  1. 6 2
      src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php
  2. 7 3
      src/Symfony/Components/Routing/Loader/XmlFileLoader.php

+ 6 - 2
src/Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php

@@ -250,6 +250,10 @@ class XmlFileLoader extends FileLoader
 
         $imports = '';
         foreach ($schemaLocations as $namespace => $location) {
+            $parts = explode('/', $location);
+            $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts) : '';
+            $location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
+
             $imports .= sprintf('  <xsd:import namespace="%s" schemaLocation="%s" />'."\n", $namespace, $location);
         }
 
@@ -266,11 +270,11 @@ $imports
 EOF
         ;
 
-        libxml_use_internal_errors(true);
+        $current = libxml_use_internal_errors(true);
         if (!$dom->schemaValidateSource($source)) {
             throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors()));
         }
-        libxml_use_internal_errors(false);
+        libxml_use_internal_errors($current);
     }
 
     /**

+ 7 - 3
src/Symfony/Components/Routing/Loader/XmlFileLoader.php

@@ -138,11 +138,15 @@ class XmlFileLoader extends FileLoader
      */
     protected function validate($dom, $file)
     {
-        libxml_use_internal_errors(true);
-        if (!$dom->schemaValidate(__DIR__.'/schema/routing/routing-1.0.xsd')) {
+        $parts = explode('/', str_replace('\\', '/', __DIR__.'/schema/routing/routing-1.0.xsd'));
+        $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts) : '';
+        $location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
+
+        $current = libxml_use_internal_errors(true);
+        if (!$dom->schemaValidate($location)) {
             throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors()));
         }
-        libxml_use_internal_errors(false);
+        libxml_use_internal_errors($current);
     }
 
     protected function getXmlErrors()