Skip to content

Commit d0a82d9

Browse files
Merge branch '5.1' into 5.2
* 5.1: [PhpUnitBridge] CS fix [Notifier] Only use sprintf instead of sprintf and string concat [PhpUnitBridge] Fix PHP 5.5 compatibility Add missing param annotation abouts $fileLinkFormat [Form] Fixed StringUtil::trim() to trim ZERO WIDTH SPACE (U+200B) and SOFT HYPHEN (U+00AD) 23412 Stop treating multiline resources as globs
2 parents ca6cd15 + 85464ec commit d0a82d9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Loader/FileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getLocator()
7171
*/
7272
public function import($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, $exclude = null)
7373
{
74-
if (\is_string($resource) && \strlen($resource) !== $i = strcspn($resource, '*?{[')) {
74+
if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && false === strpos($resource, "\n")) {
7575
$excluded = [];
7676
foreach ((array) $exclude as $pattern) {
7777
foreach ($this->glob($pattern, true, $_, false, true) as $path => $info) {

Tests/Loader/FileLoaderTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ public function testImportWithGlobLikeResource()
7777
$this->assertSame('[foo]', $loader->import('[foo]'));
7878
}
7979

80+
public function testImportWithGlobLikeResourceWhichContainsSlashes()
81+
{
82+
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
83+
$locatorMock->expects($this->once())->method('locate')->willReturn('');
84+
$loader = new TestFileLoader($locatorMock);
85+
86+
$this->assertNull($loader->import('foo/bar[foo]'));
87+
}
88+
89+
public function testImportWithGlobLikeResourceWhichContainsMultipleLines()
90+
{
91+
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
92+
$loader = new TestFileLoader($locatorMock);
93+
94+
$this->assertSame("foo\nfoobar[foo]", $loader->import("foo\nfoobar[foo]"));
95+
}
96+
97+
public function testImportWithGlobLikeResourceWhichContainsSlashesAndMultipleLines()
98+
{
99+
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
100+
$loader = new TestFileLoader($locatorMock);
101+
102+
$this->assertSame("foo\nfoo/bar[foo]", $loader->import("foo\nfoo/bar[foo]"));
103+
}
104+
80105
public function testImportWithNoGlobMatch()
81106
{
82107
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();

0 commit comments

Comments
 (0)