Skip to content

Commit 1357564

Browse files
committed
Merge pull request #112 from marekk/master
sfBrowserBase - don't post unnamed submit fields
2 parents b376a6b + 3fe91ec commit 1357564

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

lib/autoload/sfCoreAutoload.class.php

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ static public function make()
163163
$class = basename($file, false === strpos($file, '.class.php') ? '.php' : '.class.php');
164164

165165
$contents = file_get_contents($file);
166-
if (false !== stripos($contents, 'class '.$class) || false !== stripos($contents, 'interface '.$class))
166+
if (false !== stripos($contents, 'class '.$class)
167+
|| false !== stripos($contents, 'interface '.$class)
168+
|| false !== stripos($contents, 'trait '.$class))
167169
{
168170
$classes .= sprintf(" '%s' => '%s',\n", strtolower($class), substr(str_replace($libDir, '', $file), 1));
169171
}

lib/autoload/sfSimpleAutoload.class.php

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function addFile($file, $register = true)
286286
$this->cacheChanged = true;
287287
}
288288

289-
preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface)\s+(\w+)~mi', file_get_contents($file), $classes);
289+
preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface|trait)\s+(\w+)~mi', file_get_contents($file), $classes);
290290
foreach ($classes[1] as $class)
291291
{
292292
$this->classes[strtolower($class)] = $file;

lib/config/sfAutoloadConfigHandler.class.php

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function parse(array $configFiles)
126126
static public function parseFile($path, $file, $prefix)
127127
{
128128
$mapping = array();
129-
preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface)\s+(\w+)~mi', file_get_contents($file), $classes);
129+
preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface|trait)\s+(\w+)~mi', file_get_contents($file), $classes);
130130
foreach ($classes[1] as $class)
131131
{
132132
$localPrefix = '';

lib/util/sfBrowserBase.class.php

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,11 @@ public function doClickElement(DOMElement $item, $arguments = array(), $options
778778
}
779779
else if ('button' == $item->nodeName || ('input' == $item->nodeName && in_array($item->getAttribute('type'), array('submit', 'button', 'image'))))
780780
{
781-
// add the item's value to the arguments
782-
$this->parseArgumentAsArray($item->getAttribute('name'), $item->getAttribute('value'), $arguments);
781+
// add the item's value to the arguments if name is provided
782+
if ($item->getAttribute('name'))
783+
{
784+
$this->parseArgumentAsArray($item->getAttribute('name'), $item->getAttribute('value'), $arguments);
785+
}
783786

784787
// use the ancestor form element
785788
do

test/unit/util/sfBrowserTest.php

100644100755
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
require_once(__DIR__.'/../../bootstrap/unit.php');
1212

13-
$t = new lime_test(74);
13+
$t = new lime_test(76);
1414

1515
// ->click()
1616
$t->diag('->click()');
@@ -127,6 +127,11 @@ public function getDefaultServerArray($name)
127127
</span></div>
128128
</form>
129129
130+
<form action="/myform7" method="post">
131+
<input type="text" name="text_default_value" value="default" />
132+
<input type="submit" value="submit7" />
133+
</form>
134+
130135
<a href="/myotherlink">test link</a>
131136
<a href="/submitlink">submit</a>
132137
<a href="/submitimagelink"><img src="myimage.gif" alt="submit" /></a>
@@ -353,3 +358,9 @@ public function getDefaultServerArray($name)
353358
list($method, $uri, $parameters) = $b->click('submit6');
354359
$t->is($parameters['bar'], 'bar', '->click() overrides input elements defined several times');
355360
$t->is($parameters['foo']['bar'], 'bar', '->click() overrides input elements defined several times');
361+
362+
// bug #106
363+
$t->diag('bug #106');
364+
list($method, $uri, $parameters) = $b->click('submit7');
365+
$t->is(isset($parameters['']), false, 'submit without name is not submitted');
366+
$t->is($parameters['text_default_value'], 'default', 'input field with name is still submitted');

0 commit comments

Comments
 (0)