Merge branch '2.7' into 2.8

This commit is contained in:
mark_story 2015-08-23 16:29:07 -04:00
commit 51d8f74c50
3 changed files with 33 additions and 2 deletions

View file

@ -1290,6 +1290,30 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
}
/**
* Test that a hidden field followed by a visible field
* undoes the hidden field locking.
*
* @return void
*/
public function testSecuredInputDuplicate() {
$this->Form->request['_Token'] = array('key' => 'testKey');
$this->assertEquals(array(), $this->Form->fields);
$this->Form->input('text_val', array(
'type' => 'hidden',
'value' => 'some text',
));
$expected = array('text_val' => 'some text');
$this->assertEquals($expected, $this->Form->fields);
$this->Form->input('text_val', array(
'type' => 'text',
));
$expected = array('text_val');
$this->assertEquals($expected, $this->Form->fields);
}
/**
* Test secured inputs with custom names.
*

View file

@ -661,6 +661,8 @@ class FormHelper extends AppHelper {
if (!in_array($field, $this->fields)) {
if ($value !== null) {
return $this->fields[$field] = $value;
} elseif (isset($this->fields[$field]) && $value === null) {
unset($this->fields[$field]);
}
$this->fields[] = $field;
}

View file

@ -65,7 +65,7 @@ class MediaView extends View {
* @return void
*/
public function render($view = null, $layout = null) {
$name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null;
$name = $extension = $download = $id = $modified = $path = $cache = $mimeType = $compress = null;
extract($this->viewVars, EXTR_OVERWRITE);
$path = $path . $id;
@ -86,7 +86,12 @@ class MediaView extends View {
}
if ($name !== null) {
$name .= '.' . pathinfo($id, PATHINFO_EXTENSION);
if (empty($extension)) {
$extension = pathinfo($id, PATHINFO_EXTENSION);
}
if (!empty($extension)) {
$name .= '.' . $extension;
}
}
$this->response->file($path, compact('name', 'download'));