Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0544b1f

Browse filesBrowse files
committed
Merge branch '2.3' into 2.7
* 2.3: [DomCrawler] Dont use LIBXML_PARSEHUGE by default [Filesystem] Reduce complexity of ->remove() added tests for non-trusted proxies add 'guid' to list of exception to filter out Ensure backend slashes for symlinks on Windows systems [Filesystem] Try to delete broken symlinks
2 parents 9851928 + 5b577dd commit 0544b1f
Copy full SHA for 0544b1f

File tree

Expand file treeCollapse file tree

5 files changed

+57
-30
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+57
-30
lines changed

‎src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ public function getEntitiesByIds($identifier, array $values)
106106
$values = array_values(array_filter($values, function ($v) {
107107
return (string) $v === (string) (int) $v;
108108
}));
109+
} elseif ('guid' === $metadata->getTypeOfField($identifier)) {
110+
$parameterType = Connection::PARAM_STR_ARRAY;
111+
112+
// Like above, but we just filter out empty strings.
113+
$values = array_values(array_filter($values, function ($v) {
114+
return (string) $v !== '';
115+
}));
109116
} else {
110117
$parameterType = Connection::PARAM_STR_ARRAY;
111118
}

‎src/Symfony/Component/DomCrawler/Crawler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Crawler.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,11 @@ function ($m) {
229229
*
230230
* @param string $content The XML content
231231
* @param string $charset The charset
232+
* @param int $options Bitwise OR of the libxml option constants
233+
* LIBXML_PARSEHUGE is dangerous, see
234+
* http://symfony.com/blog/security-release-symfony-2-0-17-released
232235
*/
233-
public function addXmlContent($content, $charset = 'UTF-8')
236+
public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NONET)
234237
{
235238
// remove the default namespace if it's the only namespace to make XPath expressions simpler
236239
if (!preg_match('/xmlns:/', $content)) {
@@ -244,7 +247,7 @@ public function addXmlContent($content, $charset = 'UTF-8')
244247
$dom->validateOnParse = true;
245248

246249
if ('' !== trim($content)) {
247-
@$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0));
250+
@$dom->loadXML($content, $options);
248251
}
249252

250253
libxml_use_internal_errors($internalErrors);

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+22-20Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,23 @@ public function remove($files)
158158
$files = iterator_to_array($this->toIterator($files));
159159
$files = array_reverse($files);
160160
foreach ($files as $file) {
161-
if (!$this->exists($file) && !is_link($file)) {
162-
continue;
163-
}
164-
165-
if (is_dir($file) && !is_link($file)) {
161+
if (is_link($file)) {
162+
// Workaround https://bugs.php.net/52176
163+
if (!@unlink($file) && !@rmdir($file)) {
164+
$error = error_get_last();
165+
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message']));
166+
}
167+
} elseif (is_dir($file)) {
166168
$this->remove(new \FilesystemIterator($file));
167169

168-
if (true !== @rmdir($file)) {
169-
throw new IOException(sprintf('Failed to remove directory "%s".', $file), 0, null, $file);
170+
if (!@rmdir($file)) {
171+
$error = error_get_last();
172+
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message']));
170173
}
171-
} else {
172-
// https://bugs.php.net/bug.php?id=52176
173-
if ('\\' === DIRECTORY_SEPARATOR && is_dir($file)) {
174-
if (true !== @rmdir($file)) {
175-
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
176-
}
177-
} else {
178-
if (true !== @unlink($file)) {
179-
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
180-
}
174+
} elseif ($this->exists($file)) {
175+
if (!@unlink($file)) {
176+
$error = error_get_last();
177+
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message']));
181178
}
182179
}
183180
}
@@ -308,10 +305,15 @@ private function isReadable($filename)
308305
*/
309306
public function symlink($originDir, $targetDir, $copyOnWindows = false)
310307
{
311-
if ('\\' === DIRECTORY_SEPARATOR && $copyOnWindows) {
312-
$this->mirror($originDir, $targetDir);
308+
if ('\\' === DIRECTORY_SEPARATOR) {
309+
$originDir = strtr($originDir, '/', '\\');
310+
$targetDir = strtr($targetDir, '/', '\\');
313311

314-
return;
312+
if ($copyOnWindows) {
313+
$this->mirror($originDir, $targetDir);
314+
315+
return;
316+
}
315317
}
316318

317319
$this->mkdir(dirname($targetDir));

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+16-8Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function testRemoveCleansFilesAndDirectoriesIteratively()
278278

279279
$this->filesystem->remove($basePath);
280280

281-
$this->assertTrue(!is_dir($basePath));
281+
$this->assertFileNotExists($basePath);
282282
}
283283

284284
public function testRemoveCleansArrayOfFilesAndDirectories()
@@ -294,8 +294,8 @@ public function testRemoveCleansArrayOfFilesAndDirectories()
294294

295295
$this->filesystem->remove($files);
296296

297-
$this->assertTrue(!is_dir($basePath.'dir'));
298-
$this->assertTrue(!is_file($basePath.'file'));
297+
$this->assertFileNotExists($basePath.'dir');
298+
$this->assertFileNotExists($basePath.'file');
299299
}
300300

301301
public function testRemoveCleansTraversableObjectOfFilesAndDirectories()
@@ -311,8 +311,8 @@ public function testRemoveCleansTraversableObjectOfFilesAndDirectories()
311311

312312
$this->filesystem->remove($files);
313313

314-
$this->assertTrue(!is_dir($basePath.'dir'));
315-
$this->assertTrue(!is_file($basePath.'file'));
314+
$this->assertFileNotExists($basePath.'dir');
315+
$this->assertFileNotExists($basePath.'file');
316316
}
317317

318318
public function testRemoveIgnoresNonExistingFiles()
@@ -327,7 +327,7 @@ public function testRemoveIgnoresNonExistingFiles()
327327

328328
$this->filesystem->remove($files);
329329

330-
$this->assertTrue(!is_dir($basePath.'dir'));
330+
$this->assertFileNotExists($basePath.'dir');
331331
}
332332

333333
public function testRemoveCleansInvalidLinks()
@@ -339,11 +339,19 @@ public function testRemoveCleansInvalidLinks()
339339
mkdir($basePath);
340340
mkdir($basePath.'dir');
341341
// create symlink to nonexistent file
342-
@symlink($basePath.'file', $basePath.'link');
342+
@symlink($basePath.'file', $basePath.'file-link');
343+
344+
// create symlink to dir using trailing forward slash
345+
$this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
346+
$this->assertTrue(is_dir($basePath.'dir-link'));
347+
348+
// create symlink to nonexistent dir
349+
rmdir($basePath.'dir');
350+
$this->assertFalse(is_dir($basePath.'dir-link'));
343351

344352
$this->filesystem->remove($basePath);
345353

346-
$this->assertTrue(!is_dir($basePath));
354+
$this->assertFileNotExists($basePath);
347355
}
348356

349357
public function testFilesExists()

‎src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,13 @@ public function testTrustedProxies()
15661566
$this->assertEquals(80, $request->getPort());
15671567
$this->assertFalse($request->isSecure());
15681568

1569+
// request is forwarded by a non-trusted proxy
1570+
Request::setTrustedProxies(array('2.2.2.2'));
1571+
$this->assertEquals('3.3.3.3', $request->getClientIp());
1572+
$this->assertEquals('example.com', $request->getHost());
1573+
$this->assertEquals(80, $request->getPort());
1574+
$this->assertFalse($request->isSecure());
1575+
15691576
// trusted proxy via setTrustedProxies()
15701577
Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2'));
15711578
$this->assertEquals('1.1.1.1', $request->getClientIp());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.