diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php
index b01333ad8..3fdbdfc70 100644
--- a/cake/libs/view/helpers/html.php
+++ b/cake/libs/view/helpers/html.php
@@ -219,15 +219,12 @@ class HtmlHelper extends AppHelper {
} elseif (isset($attributes['type']) && isset($types[$attributes['type']])) {
$type = $types[$attributes['type']];
}
- } else {
- if ($url !== null) {
- $inline = $url;
- }
+ } elseif ($url !== null) {
+ $inline = $url;
}
-
$attributes = array_merge($type, $attributes);
-
$out = null;
+
if (isset($attributes['link'])) {
if (isset($attributes['rel']) && $attributes['rel'] === 'icon') {
$out = sprintf($this->tags['metalink'], $attributes['link'], $this->_parseAttributes($attributes, array('link')));
@@ -254,13 +251,7 @@ class HtmlHelper extends AppHelper {
* @return string A meta tag containing the specified character set.
*/
function charset($charset = null) {
- if (is_null($charset)) {
- $charset = strtolower(Configure::read('App.encoding'));
- if (!$charset) {
- $charset = 'utf-8';
- }
- }
-
+ $charset = current(array_filter(array($charset, strtolower(Configure::read('App.encoding')), 'utf-8')));
return $this->output(sprintf($this->tags['charset'], $charset));
}
/**
diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php
index 854bca6f4..43e995b6b 100644
--- a/cake/tests/cases/libs/view/helpers/html.test.php
+++ b/cake/tests/cases/libs/view/helpers/html.test.php
@@ -141,6 +141,15 @@ class HtmlHelperTest extends UnitTestCase {
Configure::write('Asset.filter.css', false);
}
+ function testCharsetTag() {
+ Configure::write('App.encoding', null);
+ $this->assertPattern('/charset=utf-8"/', $this->Html->charset());
+
+ Configure::write('App.encoding', 'ISO-8859-1');
+ $this->assertPattern('/charset=iso-8859-1"/', $this->Html->charset());
+ $this->assertPattern('/charset=UTF-7"/', $this->Html->charset('UTF-7'));
+ }
+
function testBreadcrumb() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');