23412 Stop treating multiline resources as globs
This commit is contained in:
parent
b60bb6e2d6
commit
1e3baad386
|
@ -78,7 +78,7 @@ abstract class FileLoader extends Loader
|
||||||
}
|
}
|
||||||
$exclude = \func_num_args() >= 5 ? func_get_arg(4) : null;
|
$exclude = \func_num_args() >= 5 ? func_get_arg(4) : null;
|
||||||
|
|
||||||
if (\is_string($resource) && \strlen($resource) !== $i = strcspn($resource, '*?{[')) {
|
if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && false === strpos($resource, "\n")) {
|
||||||
$excluded = [];
|
$excluded = [];
|
||||||
foreach ((array) $exclude as $pattern) {
|
foreach ((array) $exclude as $pattern) {
|
||||||
foreach ($this->glob($pattern, true, $_, false, true) as $path => $info) {
|
foreach ($this->glob($pattern, true, $_, false, true) as $path => $info) {
|
||||||
|
|
|
@ -77,6 +77,31 @@ class FileLoaderTest extends TestCase
|
||||||
$this->assertSame('[foo]', $loader->import('[foo]'));
|
$this->assertSame('[foo]', $loader->import('[foo]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportWithGlobLikeResourceWhichContainsSlashes()
|
||||||
|
{
|
||||||
|
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
|
||||||
|
$locatorMock->expects($this->once())->method('locate')->willReturn('');
|
||||||
|
$loader = new TestFileLoader($locatorMock);
|
||||||
|
|
||||||
|
$this->assertNull($loader->import('foo/bar[foo]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testImportWithGlobLikeResourceWhichContainsMultipleLines()
|
||||||
|
{
|
||||||
|
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
|
||||||
|
$loader = new TestFileLoader($locatorMock);
|
||||||
|
|
||||||
|
$this->assertSame("foo\nfoobar[foo]", $loader->import("foo\nfoobar[foo]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testImportWithGlobLikeResourceWhichContainsSlashesAndMultipleLines()
|
||||||
|
{
|
||||||
|
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
|
||||||
|
$loader = new TestFileLoader($locatorMock);
|
||||||
|
|
||||||
|
$this->assertSame("foo\nfoo/bar[foo]", $loader->import("foo\nfoo/bar[foo]"));
|
||||||
|
}
|
||||||
|
|
||||||
public function testImportWithNoGlobMatch()
|
public function testImportWithNoGlobMatch()
|
||||||
{
|
{
|
||||||
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
|
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
|
||||||
|
|
Reference in New Issue