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 a22858b

Browse filesBrowse files
committed
Merge branch '2.4' into 2.5
* 2.4: Fixed failed config schema loads due to libxml_disable_entity_loader usage. enabled PHP 5.6 for tests [Process] Fix ExecutableFinder with open basedir Refactored the CssSelector to remove the circular object graph Fix mocks to support >=5.5.14 and >=5.4.30 [ClassLoader] fixed PHP warning on PHP 5.3 [Validator] added Lithuanian translation for empty file Added missing dutch translations [Components][Serializer] optional constructor arguments can be omitted during the denormalization process [DomCrawler] properly handle buttons with single and double quotes inside the name attribute Added missing pt and pt_BR translations
2 parents 4450197 + 5b2e34f commit a22858b
Copy full SHA for a22858b

File tree

Expand file treeCollapse file tree

19 files changed

+388
-56
lines changed
Filter options
Expand file treeCollapse file tree

19 files changed

+388
-56
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ php:
1010

1111
matrix:
1212
allow_failures:
13-
- php: 5.6
1413
- php: hhvm-nightly
1514

1615
services: mongodb

‎src/Symfony/Component/ClassLoader/ClassMapGenerator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ClassLoader/ClassMapGenerator.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14+
if (!defined('T_TRAIT')) {
15+
define('T_TRAIT', 0);
16+
}
17+
1418
/**
1519
* ClassMapGenerator
1620
*
@@ -84,7 +88,6 @@ private static function findClasses($path)
8488
{
8589
$contents = file_get_contents($path);
8690
$tokens = token_get_all($contents);
87-
$T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT;
8891

8992
$classes = array();
9093

@@ -111,7 +114,7 @@ private static function findClasses($path)
111114
break;
112115
case T_CLASS:
113116
case T_INTERFACE:
114-
case $T_TRAIT:
117+
case T_TRAIT:
115118
// Find the classname
116119
while (($t = $tokens[++$i]) && is_array($t)) {
117120
if (T_STRING === $t[0]) {

‎src/Symfony/Component/Config/Util/XmlUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Util/XmlUtils.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public static function loadFile($file, $schemaOrCallable = null)
8080
$valid = false;
8181
}
8282
} elseif (!is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) {
83-
$valid = @$dom->schemaValidate($schemaOrCallable);
83+
$schemaSource = file_get_contents((string) $schemaOrCallable);
84+
$valid = @$dom->schemaValidateSource($schemaSource);
8485
} else {
8586
libxml_use_internal_errors($internalErrors);
8687

‎src/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ interface ExtensionInterface
2424
/**
2525
* Returns node translators.
2626
*
27+
* These callables will receive the node as first argument and the translator as second argument.
28+
*
2729
* @return callable[]
2830
*/
2931
public function getNodeTranslators();

‎src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php
+32-31Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class NodeExtension extends AbstractExtension
2929
const ATTRIBUTE_NAME_IN_LOWER_CASE = 2;
3030
const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4;
3131

32-
/**
33-
* @var Translator
34-
*/
35-
private $translator;
36-
3732
/**
3833
* @var int
3934
*/
@@ -42,12 +37,10 @@ class NodeExtension extends AbstractExtension
4237
/**
4338
* Constructor.
4439
*
45-
* @param Translator $translator
46-
* @param int $flags
40+
* @param int $flags
4741
*/
48-
public function __construct(Translator $translator, $flags = 0)
42+
public function __construct($flags = 0)
4943
{
50-
$this->translator = $translator;
5144
$this->flags = $flags;
5245
}
5346

@@ -100,33 +93,36 @@ public function getNodeTranslators()
10093

10194
/**
10295
* @param Node\SelectorNode $node
96+
* @param Translator $translator
10397
*
10498
* @return XPathExpr
10599
*/
106-
public function translateSelector(Node\SelectorNode $node)
100+
public function translateSelector(Node\SelectorNode $node, Translator $translator)
107101
{
108-
return $this->translator->nodeToXPath($node->getTree());
102+
return $translator->nodeToXPath($node->getTree());
109103
}
110104

111105
/**
112106
* @param Node\CombinedSelectorNode $node
107+
* @param Translator $translator
113108
*
114109
* @return XPathExpr
115110
*/
116-
public function translateCombinedSelector(Node\CombinedSelectorNode $node)
111+
public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator)
117112
{
118-
return $this->translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector());
113+
return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector());
119114
}
120115

121116
/**
122117
* @param Node\NegationNode $node
118+
* @param Translator $translator
123119
*
124120
* @return XPathExpr
125121
*/
126-
public function translateNegation(Node\NegationNode $node)
122+
public function translateNegation(Node\NegationNode $node, Translator $translator)
127123
{
128-
$xpath = $this->translator->nodeToXPath($node->getSelector());
129-
$subXpath = $this->translator->nodeToXPath($node->getSubSelector());
124+
$xpath = $translator->nodeToXPath($node->getSelector());
125+
$subXpath = $translator->nodeToXPath($node->getSubSelector());
130126
$subXpath->addNameTest();
131127

132128
if ($subXpath->getCondition()) {
@@ -138,34 +134,37 @@ public function translateNegation(Node\NegationNode $node)
138134

139135
/**
140136
* @param Node\FunctionNode $node
137+
* @param Translator $translator
141138
*
142139
* @return XPathExpr
143140
*/
144-
public function translateFunction(Node\FunctionNode $node)
141+
public function translateFunction(Node\FunctionNode $node, Translator $translator)
145142
{
146-
$xpath = $this->translator->nodeToXPath($node->getSelector());
143+
$xpath = $translator->nodeToXPath($node->getSelector());
147144

148-
return $this->translator->addFunction($xpath, $node);
145+
return $translator->addFunction($xpath, $node);
149146
}
150147

151148
/**
152149
* @param Node\PseudoNode $node
150+
* @param Translator $translator
153151
*
154152
* @return XPathExpr
155153
*/
156-
public function translatePseudo(Node\PseudoNode $node)
154+
public function translatePseudo(Node\PseudoNode $node, Translator $translator)
157155
{
158-
$xpath = $this->translator->nodeToXPath($node->getSelector());
156+
$xpath = $translator->nodeToXPath($node->getSelector());
159157

160-
return $this->translator->addPseudoClass($xpath, $node->getIdentifier());
158+
return $translator->addPseudoClass($xpath, $node->getIdentifier());
161159
}
162160

163161
/**
164162
* @param Node\AttributeNode $node
163+
* @param Translator $translator
165164
*
166165
* @return XPathExpr
167166
*/
168-
public function translateAttribute(Node\AttributeNode $node)
167+
public function translateAttribute(Node\AttributeNode $node, Translator $translator)
169168
{
170169
$name = $node->getAttribute();
171170
$safe = $this->isSafeName($name);
@@ -181,37 +180,39 @@ public function translateAttribute(Node\AttributeNode $node)
181180

182181
$attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
183182
$value = $node->getValue();
184-
$xpath = $this->translator->nodeToXPath($node->getSelector());
183+
$xpath = $translator->nodeToXPath($node->getSelector());
185184

186185
if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) {
187186
$value = strtolower($value);
188187
}
189188

190-
return $this->translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value);
189+
return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value);
191190
}
192191

193192
/**
194193
* @param Node\ClassNode $node
194+
* @param Translator $translator
195195
*
196196
* @return XPathExpr
197197
*/
198-
public function translateClass(Node\ClassNode $node)
198+
public function translateClass(Node\ClassNode $node, Translator $translator)
199199
{
200-
$xpath = $this->translator->nodeToXPath($node->getSelector());
200+
$xpath = $translator->nodeToXPath($node->getSelector());
201201

202-
return $this->translator->addAttributeMatching($xpath, '~=', '@class', $node->getName());
202+
return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName());
203203
}
204204

205205
/**
206206
* @param Node\HashNode $node
207+
* @param Translator $translator
207208
*
208209
* @return XPathExpr
209210
*/
210-
public function translateHash(Node\HashNode $node)
211+
public function translateHash(Node\HashNode $node, Translator $translator)
211212
{
212-
$xpath = $this->translator->nodeToXPath($node->getSelector());
213+
$xpath = $translator->nodeToXPath($node->getSelector());
213214

214-
return $this->translator->addAttributeMatching($xpath, '=', '@id', $node->getId());
215+
return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId());
215216
}
216217

217218
/**

‎src/Symfony/Component/CssSelector/XPath/Translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/XPath/Translator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function __construct(ParserInterface $parser = null)
7676
$this->mainParser = $parser ?: new Parser();
7777

7878
$this
79-
->registerExtension(new Extension\NodeExtension($this))
79+
->registerExtension(new Extension\NodeExtension())
8080
->registerExtension(new Extension\CombinationExtension())
8181
->registerExtension(new Extension\FunctionExtension())
8282
->registerExtension(new Extension\PseudoClassExtension())
@@ -207,7 +207,7 @@ public function nodeToXPath(NodeInterface $node)
207207
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
208208
}
209209

210-
return call_user_func($this->nodeTranslators[$node->getNodeName()], $node);
210+
return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
211211
}
212212

213213
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Crawler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ public function selectButton($value)
674674
{
675675
$translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")';
676676
$xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' '.$value.' ')).
677-
sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id="%s" or @name="%s"] ', $translate, static::xpathLiteral(' '.$value.' '), $value, $value).
678-
sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id="%s" or @name="%s"]', static::xpathLiteral(' '.$value.' '), $value, $value);
677+
sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)).
678+
sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value));
679679

680680
return $this->filterRelativeXPath($xpath);
681681
}

‎src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,48 @@ public function testSelectButton()
569569
$this->assertEquals(1, $crawler->selectButton('FooBarName')->count(), '->selectButton() selects buttons with form attribute too');
570570
}
571571

572+
public function testSelectButtonWithSingleQuotesInNameAttribute()
573+
{
574+
$html = <<<HTML
575+
<!DOCTYPE html>
576+
<html lang="en">
577+
<body>
578+
<div id="action">
579+
<a href="/index.php?r=site/login">Login</a>
580+
</div>
581+
<form id="login-form" action="/index.php?r=site/login" method="post">
582+
<button type="submit" name="Click 'Here'">Submit</button>
583+
</form>
584+
</body>
585+
</html>
586+
HTML;
587+
588+
$crawler = new Crawler($html);
589+
590+
$this->assertCount(1, $crawler->selectButton('Click \'Here\''));
591+
}
592+
593+
public function testSelectButtonWithDoubleQuotesInNameAttribute()
594+
{
595+
$html = <<<HTML
596+
<!DOCTYPE html>
597+
<html lang="en">
598+
<body>
599+
<div id="action">
600+
<a href="/index.php?r=site/login">Login</a>
601+
</div>
602+
<form id="login-form" action="/index.php?r=site/login" method="post">
603+
<button type="submit" name='Click "Here"'>Submit</button>
604+
</form>
605+
</body>
606+
</html>
607+
HTML;
608+
609+
$crawler = new Crawler($html);
610+
611+
$this->assertCount(1, $crawler->selectButton('Click "Here"'));
612+
}
613+
572614
public function testLink()
573615
{
574616
$crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo');

‎src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
1515
use Symfony\Component\Form\Tests\AbstractRequestHandlerTest;
1616
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\HttpFoundation\File\UploadedFile;
1718

1819
/**
1920
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -47,8 +48,6 @@ protected function getRequestHandler()
4748

4849
protected function getMockFile()
4950
{
50-
return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
51-
->setConstructorArgs(array(__DIR__.'/../../Fixtures/foo', 'foo'))
52-
->getMock();
51+
return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo');
5352
}
5453
}
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundation\Resources\stubs;
13+
14+
use Symfony\Component\HttpFoundation\File\File as OrigFile;
15+
16+
class FakeFile extends OrigFile
17+
{
18+
private $realpath;
19+
20+
public function __construct($realpath, $path)
21+
{
22+
$this->realpath = $realpath;
23+
parent::__construct($path, false);
24+
}
25+
26+
public function isReadable()
27+
{
28+
return true;
29+
}
30+
31+
public function getRealpath()
32+
{
33+
return $this->realpath;
34+
}
35+
36+
public function getSize()
37+
{
38+
return 42;
39+
}
40+
41+
public function getMTime()
42+
{
43+
return time();
44+
}
45+
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
+2-12Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpFoundation\BinaryFileResponse;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
17+
use Symfony\Component\HttpFoundation\Resources\stubs\FakeFile;
1718

1819
class BinaryFileResponseTest extends ResponseTestCase
1920
{
@@ -179,18 +180,7 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
179180
$request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect');
180181
$request->headers->set('X-Accel-Mapping', $mapping);
181182

182-
$file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
183-
->setConstructorArgs(array(__DIR__.'/File/Fixtures/test'))
184-
->getMock();
185-
$file->expects($this->any())
186-
->method('getRealPath')
187-
->will($this->returnValue($realpath));
188-
$file->expects($this->any())
189-
->method('isReadable')
190-
->will($this->returnValue(true));
191-
$file->expects($this->any())
192-
->method('getMTime')
193-
->will($this->returnValue(time()));
183+
$file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test');
194184

195185
BinaryFileResponse::trustXSendFileTypeHeader();
196186
$response = new BinaryFileResponse($file);

‎src/Symfony/Component/Process/ExecutableFinder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/ExecutableFinder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function addSuffix($suffix)
5353
public function find($name, $default = null, array $extraDirs = array())
5454
{
5555
if (ini_get('open_basedir')) {
56-
$searchPath = explode(PATH_SEPARATOR, getenv('open_basedir'));
56+
$searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
5757
$dirs = array();
5858
foreach ($searchPath as $path) {
5959
if (is_dir($path)) {

0 commit comments

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