Skip to content

Commit

Permalink
Removed unnecessary conditional branch, fixed test and comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
akiyan authored and markstory committed May 22, 2014
1 parent 67f2562 commit 781430c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
21 changes: 15 additions & 6 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -1418,25 +1418,34 @@ public function testSecuredFormUrlIgnoresHost() {
}

/**
* URL, HTML and identifier - and "URL + its hash" or "URLs + their hashes".
* Test that URL, HTML and identifer show up in their hashs.
*
* @return void
*/
public function testSecuredFormUrlHasHtmlEntityAndFragmentIdentifier() {
public function testSecuredFormUrlHasHtmlAndIdentifer() {
$this->Form->request['_Token'] = array('key' => 'testKey');

$expected = 'a0c54487c45e8eea45beb318c35fc01e6f87de29%3A';
$expected = 'ece0693fb1b19ca116133db1832ac29baaf41ce5%3A';
$this->Form->create('Address', array(
'url' => array('controller' => 'articles', 'action' => 'view', 1, '?' => array('page' => 1, 'limit' => 10), '#' => 'result')
'url' => array(
'controller' => 'articles',
'action' => 'view',
'?' => array(
'page' => 1,
'limit' => 10,
'html' => '<>"',
),
'#' => 'result',
),
));
$result = $this->Form->secure();
$this->assertContains($expected, $result);

$this->Form->create('Address', array('url' => 'http://localhost/articles/view/1?page=1&limit=10#result'));
$this->Form->create('Address', array('url' => 'http://localhost/articles/view?page=1&limit=10&html=%3C%3E%22#result'));
$result = $this->Form->secure();
$this->assertContains($expected, $result, 'Full URL should only use path and query.');

$this->Form->create('Address', array('url' => '/articles/view/1?page=1&limit=10#result'));
$this->Form->create('Address', array('url' => '/articles/view?page=1&limit=10&html=%3C%3E%22#result'));
$result = $this->Form->secure();
$this->assertContains($expected, $result, 'URL path + query should work.');
}
Expand Down
10 changes: 4 additions & 6 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -3002,18 +3002,16 @@ protected function _secureFieldName($options) {
}

/**
* Sets the last creaated form action.
* Sets the last created form action.
*
* @var mixed
* @return void
*/
protected function _lastAction($url) {
$action = Router::url($url, true);
if (strpos($action, '://')) {
$query = parse_url($action, PHP_URL_QUERY);
$query = $query ? '?' . $query : '';
$this->_lastAction = parse_url($action, PHP_URL_PATH) . $query;
}
$query = parse_url($action, PHP_URL_QUERY);
$query = $query ? '?' . $query : '';
$this->_lastAction = parse_url($action, PHP_URL_PATH) . $query;
}

/**
Expand Down

0 comments on commit 781430c

Please sign in to comment.