Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DomCrawler] added support for query string with slash #7427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a4ec677
[DomCrawler] Fix relative path handling in links
lazyhammer Mar 2, 2013
73bead7
[ClassLoader] made DebugClassLoader idempotent
kriswallsmith Mar 2, 2013
bb08247
[ClassLoader] tweaked test
kriswallsmith Mar 3, 2013
b9cdb9a
[HttpKernel] Fixed possible profiler token collision (closes #7272, c…
fabpot Mar 6, 2013
1d3da29
[FrameworkBundle] avoids cache:clear to break if new/old folders alre…
jfsimon Mar 4, 2013
82f6389
merged branch jfsimon/issue-6502 (PR #7260)
fabpot Mar 6, 2013
f9d683e
merged branch lazyhammer/crawler-relative-links-2.1 (PR #7244)
fabpot Mar 6, 2013
a31deeb
Update RouteCompiler.php
sualko Mar 5, 2013
7241be9
[Finder] fixed a potential issue on Solaris where INF value is wrong …
fabpot Mar 6, 2013
95af84c
Fixed test to use Reflection
merk Mar 8, 2013
27cc0df
Merge pull request #1 from merk/class-loader/idempotent
kriswallsmith Mar 8, 2013
ee495f8
merged branch kriswallsmith/class-loader/idempotent (PR #7245)
fabpot Mar 8, 2013
547350c
[FrameworkBundle] Fix code status in dockblock
franmomu Mar 9, 2013
a27f7d8
merged branch franmomu/patch-1 (PR #7317)
fabpot Mar 10, 2013
e3547c6
[TwigBridge] fixes
jfsimon Mar 6, 2013
e508ecc
merged branch jfsimon/issue-6747 (PR #7281)
fabpot Mar 12, 2013
5bc30bb
[Translation] added xliff loader/dumper with resname support
jfsimon Mar 8, 2013
d77b97c
merged branch jfsimon/issue-5940 (PR #7304)
fabpot Mar 12, 2013
ae0b8ea
[Translation] removed wriong 'use'
jfsimon Mar 12, 2013
fc47589
[BrowserKit] added ability to ignored malformed set-cookie header
jfsimon Mar 12, 2013
c5e999a
[TwigBridge] fixed non probant tests & added new one
jfsimon Mar 12, 2013
fe4cc24
[TwigBridge] fixed fixed scope & trans_default_domain node visitor
jfsimon Mar 12, 2013
5ad4bd1
[TwigBridge] now enter/leave scope on Twig_Node_Module
jfsimon Mar 12, 2013
1bc6f7b
merged branch jfsimon/issue-7304 (PR #7345)
fabpot Mar 12, 2013
1b5674e
merged branch jfsimon/issue-7281 (PR #7348)
fabpot Mar 12, 2013
940d591
merged branch jfsimon/issue-7039 (PR #7347)
fabpot Mar 12, 2013
7d87ecd
[FrameworkBundle] fixed cahe:clear command's warmup
jfsimon Mar 13, 2013
c423f16
[2.1][TwigBridge] Fixes Issue #7342 in TwigBridge
Mar 12, 2013
8f2c875
merged branch benbender/2.1 (PR #7344)
fabpot Mar 13, 2013
175cdc0
[TwigBridge] removed double var initialization (refs #7344)
fabpot Mar 13, 2013
7216cb0
[Validator] fix showing wrong max file size for upload errors
Tobion Mar 13, 2013
cefc820
merged branch Tobion/max-filesize-validator (PR #7362)
fabpot Mar 13, 2013
6575df6
[Security] use current request attributes to generate redirect url?
jfsimon Mar 11, 2013
e4896da
merged branch jfsimon/security-redirect-attributes (PR #7325)
fabpot Mar 13, 2013
ef53456
[DoctrineBridge] Avoids blob values to be logged by doctrine
jfsimon Mar 7, 2013
18cd187
merged branch jfsimon/issue-7012 (PR #7297)
fabpot Mar 13, 2013
cc3a40e
[FrameworkBundle] changed temp kernel name in cache:clear
jfsimon Mar 14, 2013
f2ef6bc
[FrameworkBundle] removed BC break
jfsimon Mar 14, 2013
cdd89fb
merged branch jfsimon/issue-6203 (PR #7360)
fabpot Mar 14, 2013
e51432a
sub-requests are now created with the same class as their parent
jfsimon Mar 14, 2013
4ae667d
merged branch jfsimon/issue-7185-2.1 (PR #7381)
fabpot Mar 15, 2013
b9c37f2
changed sub-requests creation to '::create()'
jfsimon Mar 15, 2013
6c0d2b9
merged branch jfsimon/issue-7185-2.1 (PR #7388)
fabpot Mar 15, 2013
bd38483
[Security] fixed HttpUtils class tests
jfsimon Mar 15, 2013
67fbbac
[DoctrineBridge] Fixed non-utf-8 recognition
saro0h Mar 15, 2013
358689c
merged branch saro0h/issue-7297 (PR #7392)
fabpot Mar 16, 2013
3a03f3e
merged branch jfsimon/issue-7325 (PR #7393)
fabpot Mar 16, 2013
54609b9
[HttpCache] added a test (cached content should be kept after purging)
bamarni Mar 17, 2013
17dc2ff
[HttpRequest] fixes Request::getLanguages() bug
mweimerskirch Jan 31, 2013
70ec4f6
merged branch jfsimon/issue-6928 (PR #7378)
fabpot Mar 18, 2013
366bba6
Add a public modifier to an interface method
elnur Mar 15, 2013
7b76392
merged branch elnur/interface-public-modifier (PR #7397)
fabpot Mar 18, 2013
46341e1
merged branch bamarni/issue-6830 (PR #7408)
fabpot Mar 18, 2013
e6b7515
[DomCrawler] added support for query string with slash
Mar 20, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
class DbalLogger implements SQLLogger
{
const MAX_STRING_LENGTH = 32;
const BINARY_DATA_VALUE = '(binary value)';

protected $logger;
protected $stopwatch;

Expand All @@ -46,6 +49,26 @@ public function startQuery($sql, array $params = null, array $types = null)
$this->stopwatch->start('doctrine', 'doctrine');
}

if (is_array($params)) {
foreach ($params as $index => $param) {
if (!is_string($params[$index])) {
continue;
}

// non utf-8 strings break json encoding
if (!preg_match('#[\p{L}\p{N} ]#u', $params[$index])) {
$params[$index] = self::BINARY_DATA_VALUE;
continue;
}

// too long string must be shorten
if (self::MAX_STRING_LENGTH < strlen($params[$index])) {
$params[$index] = substr($params[$index], self::MAX_STRING_LENGTH - 6).' [...]';
continue;
}
}
}

if (null !== $this->logger) {
$this->log($sql, null === $params ? array() : $params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
protected function getExtensions()
{
$manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');

$manager->expects($this->any())
->method('getManager')
->will($this->returnValue($this->em));

$manager->expects($this->any())
->method('getManagerForClass')
->will($this->returnValue($this->em));

return array(
new CoreExtension(),
new DoctrineOrmExtension($manager)
Expand Down
32 changes: 30 additions & 2 deletions src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bridge\Doctrine\Tests\Logger;

use Symfony\Bridge\Doctrine\Logger\DbalLogger;

class DbalLoggerTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -59,12 +61,38 @@ public function testLogNonUtf8()
$dbalLogger
->expects($this->once())
->method('log')
->with('SQL', array('utf8' => 'foo', 'nonutf8' => "\x7F\xFF"))
->with('SQL', array('utf8' => 'foo', 'nonutf8' => DbalLogger::BINARY_DATA_VALUE))
;

$dbalLogger->startQuery('SQL', array(
'utf8' => 'foo',
'nonutf8' => "\x7F\xFF"
'nonutf8' => "\x7F\xFF",
));
}

public function testLogLongString()
{
$logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');

$dbalLogger = $this
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
->setConstructorArgs(array($logger, null))
->setMethods(array('log'))
->getMock()
;

$shortString = str_repeat('a', DbalLogger::MAX_STRING_LENGTH);
$longString = str_repeat('a', DbalLogger::MAX_STRING_LENGTH + 1);

$dbalLogger
->expects($this->once())
->method('log')
->with('SQL', array('short' => $shortString, 'long' => substr($longString, DbalLogger::MAX_STRING_LENGTH - 6).' [...]'))
;

$dbalLogger->startQuery('SQL', array(
'short' => $shortString,
'long' => $longString,
));
}
}
126 changes: 126 additions & 0 deletions src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

namespace Symfony\Bridge\Twig\NodeVisitor;

/**
* @author Jean-François Simon <[email protected]>
*/
class Scope
{
/**
* @var Scope|null
*/
private $parent;

/**
* @var Scope[]
*/
private $children;

/**
* @var array
*/
private $data;

/**
* @var boolean
*/
private $left;

/**
* @param Scope $parent
*/
public function __construct(Scope $parent = null)
{
$this->parent = $parent;
$this->left = false;
$this->data = array();
}

/**
* Opens a new child scope.
*
* @return Scope
*/
public function enter()
{
$child = new self($this);
$this->children[] = $child;

return $child;
}

/**
* Closes current scope and returns parent one.
*
* @return Scope|null
*/
public function leave()
{
$this->left = true;

return $this->parent;
}

/**
* Stores data into current scope.
*
* @param string $key
* @param mixed $value
*
* @throws \LogicException
*
* @return Scope Current scope
*/
public function set($key, $value)
{
if ($this->left) {
throw new \LogicException('Left scope is not mutable.');
}

$this->data[$key] = $value;

return $this;
}

/**
* Tests if a data is visible from current scope.
*
* @param string $key
*
* @return boolean
*/
public function has($key)
{
if (array_key_exists($key, $this->data)) {
return true;
}

if (null === $this->parent) {
return false;
}

return $this->parent->has($key);
}

/**
* Returns data visible from current scope.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null)
{
if (array_key_exists($key, $this->data)) {
return $this->data[$key];
}

if (null === $this->parent) {
return $default;
}

return $this->parent->get($key, $default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,43 @@
*/
class TranslationDefaultDomainNodeVisitor implements \Twig_NodeVisitorInterface
{
private $domain;
/**
* @var Scope
*/
private $scope;

/**
* Constructor.
*/
public function __construct()
{
$this->scope = new Scope();
}

/**
* {@inheritdoc}
*/
public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
{
if ($node instanceof \Twig_Node_Module) {
$this->domain = null;
if ($node instanceof \Twig_Node_Block || $node instanceof \Twig_Node_Module) {
$this->scope = $this->scope->enter();
}

if ($node instanceof TransDefaultDomainNode) {
if ($node->getNode('expr') instanceof \Twig_Node_Expression_Constant) {
$this->domain = $node->getNode('expr');
$this->scope->set('domain', $node->getNode('expr'));

return $node;
} else {
$var = $env->getParser()->getVarName();
$name = new \Twig_Node_Expression_AssignName($var, $node->getLine());
$this->domain = new \Twig_Node_Expression_Name($var, $node->getLine());
$this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getLine()));

return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getLine());
}
}

if (null === $this->domain) {
if (!$this->scope->has('domain')) {
return $node;
}

Expand All @@ -58,11 +69,11 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
$arguments->setNode($ind - 1, new \Twig_Node_Expression_Array(array(), $node->getLine()));
}

$arguments->setNode($ind, $this->domain);
$arguments->setNode($ind, $this->scope->get('domain'));
}
} elseif ($node instanceof TransNode) {
if (null === $node->getNode('domain')) {
$node->setNode('domain', $this->domain);
$node->setNode('domain', $this->scope->get('domain'));
}
}

Expand All @@ -78,6 +89,10 @@ public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
return false;
}

if ($node instanceof \Twig_Node_Block || $node instanceof \Twig_Node_Module) {
$this->scope = $this->scope->leave();
}

return $node;
}

Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/NodeVisitor/ScopeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Symfony\Bridge\Twig\Tests\NodeVisitor;

use Symfony\Bridge\Twig\NodeVisitor\Scope;
use Symfony\Bridge\Twig\Tests\TestCase;

class ScopeTest extends TestCase
{
public function testScopeInitiation()
{
$scope = new Scope();
$scope->enter();
$this->assertNull($scope->get('test'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase
public function testDefaultDomainAssignment(\Twig_Node $node)
{
$env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));

$visitor = new TranslationDefaultDomainNodeVisitor();

// visit trans_default_domain tag
$defaultDomain = TwigNodeProvider::getTransDefaultDomainTag('domain');
$defaultDomain = TwigNodeProvider::getTransDefaultDomainTag(self::$domain);
$visitor->enterNode($defaultDomain, $env);
$visitor->leaveNode($defaultDomain, $env);

Expand All @@ -38,12 +37,38 @@ public function testDefaultDomainAssignment(\Twig_Node $node)
$this->assertEquals(array(array(self::$message, self::$domain)), $visitor->getMessages());
}

/** @dataProvider getDefaultDomainAssignmentTestData */
public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node)
{
$env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
$visitor = new TranslationDefaultDomainNodeVisitor();

// visit trans_default_domain tag
$newModule = TwigNodeProvider::getModule('test');
$visitor->enterNode($newModule, $env);
$visitor->leaveNode($newModule, $env);

// visit tested node
$enteredNode = $visitor->enterNode($node, $env);
$leavedNode = $visitor->leaveNode($node, $env);
$this->assertSame($node, $enteredNode);
$this->assertSame($node, $leavedNode);

// extracting tested node messages
$visitor = new TranslationNodeVisitor();
$visitor->enable();
$visitor->enterNode($node, $env);
$visitor->leaveNode($node, $env);

$this->assertEquals(array(array(self::$message, null)), $visitor->getMessages());
}

public function getDefaultDomainAssignmentTestData()
{
return array(
array(TwigNodeProvider::getTransFilter(self::$message, self::$domain)),
array(TwigNodeProvider::getTransChoiceFilter(self::$message, self::$domain)),
array(TwigNodeProvider::getTransTag(self::$message, self::$domain)),
array(TwigNodeProvider::getTransFilter(self::$message)),
array(TwigNodeProvider::getTransChoiceFilter(self::$message)),
array(TwigNodeProvider::getTransTag(self::$message)),
);
}
}
13 changes: 13 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

class TwigNodeProvider
{
public static function getModule($content)
{
return new \Twig_Node_Module(
new \Twig_Node_Expression_Constant($content, 0),
null,
new \Twig_Node_Expression_Array(array(), 0),
new \Twig_Node_Expression_Array(array(), 0),
new \Twig_Node_Expression_Array(array(), 0),
null,
null
);
}

public static function getTransFilter($message, $domain = null)
{
$arguments = $domain ? array(
Expand Down
Loading