Explorar o código

[DomCrawler] fix Form::getUri() when the form action attribute contains only a sharp (#) character.

hhamon %!s(int64=14) %!d(string=hai) anos
pai
achega
b687e52835

+ 1 - 1
src/Symfony/Component/DomCrawler/Form.php

@@ -174,7 +174,7 @@ class Form implements \ArrayAccess
         $uri = $this->node->getAttribute('action');
         $urlHaveScheme = 'http' === substr($uri, 0, 4);
 
-        if (!$uri) {
+        if (!$uri || '#' === $uri) {
             $uri = $this->path;
         }
 

+ 6 - 0
tests/Symfony/Tests/Component/DomCrawler/FormTest.php

@@ -341,6 +341,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
                 array(),
                 '/?foo=foo',
             ),
+            array(
+                'chooses the path if the action attribute value is a sharp (#)',
+                '<form action="#" method="post"><input type="text" name="foo" value="foo" /><input type="submit" /></form>',
+                array(),
+                '/',
+            ),
         );
     }