diff --git a/includes/common.inc b/includes/common.inc index 7d0bf85..fb1e6ec 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -126,8 +126,7 @@ function drupal_set_html_head($data = NULL) { * Retrieve output to be displayed in the head tag of the HTML page. */ function drupal_get_html_head() { - $output = "\n"; - return $output . drupal_set_html_head(); + return drupal_set_html_head(); } /** @@ -167,9 +166,21 @@ function drupal_get_headers() { * Make any final alterations to the rendered xhtml. */ function drupal_final_markup($content) { + // Check if any http-equiv="Content-Type" values have been assigned already, + // allowing for different output types (specifically non-utf-8). + $matches = array(); + preg_match('/(]*)>)/', $content, $matches); + $meta_content = 'content="text/html; charset=utf-8"'; + + // If found, remove all existing http-equiv="Content-Type" lines. + if (count($matches) == 3) { + $meta_content = trim(preg_replace('/\/$/', '', $matches[2])); + $content = preg_replace('/]*>/', '', $content); + } + // Make sure that the charset is always specified as the first element of the // head region to prevent encoding-based attacks. - return preg_replace('/]*>/i', "\$0\n", $content, 1); + return preg_replace('/]*>/i', "\$0\n", $content, 1); } /**