Hi guys

Since I installed nodewords, I noticed that the html meta tag which contains the charset appears twice in the html code. It is normally written by the theme layer, but nodewords seems to inject it another time. Since it injects exactly the same content than the original, no bug happens, but it's still a bug. Here is what I see in the html code :

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>[my page title]</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
...

Comments

hanoii’s picture

Project: Meta tags Node Type » Nodewords: D6 Meta Tags
Version: 6.x-1.7 » 6.x-1.11

Are you using this module or only nodewords? This is nodewords_nodetye (Nodewords Meta Tags). From your description you only mention nodewords, so I am moving the issue to that module, if you do use this module as well. Please disable and try this issue out. If you still experience the problem, then it's nodewords, if you don't then it may be this module and I can took a look at it.

Also if it's nodewords, inform your version number, I am changing it to the latest.

Anonymous’s picture

Status: Active » Closed (duplicate)

It's done by Drupal core code; check the source on any pages on Drupal.org, and you will notice the same meta tag is printed twice (Drupal.org does not use Nodewords).

gjansen’s picture

I'm having the same problem.
I do use the nodewords module.
Any suggestions how I can prevent this duplicate META-Tag?

Anonymous’s picture

See the previous comment; you cannot fix it because it is done by Drupal core code.

brunodbo’s picture

Status: Closed (duplicate) » Needs review

Confirming that this meta tag appears twice when using nodewords. This happens in nodewords.module, on line 542.

Attached patch removes the charset meta tag added by nodewords (since it's already added by Drupal core).

brunodbo’s picture

StatusFileSize
new495 bytes

And here's the patch ..

avpaderno’s picture

Status: Needs review » Closed (duplicate)

The code in Nodewords has been already changed.

Confirming that this meta tag appears twice when using nodewords.

That is not correct; the content type meta tags appears twice because it is added from Drupal.
See the source of this page, and you will see it twice, even though Drupal.org doesn't use Nodewords.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <!-- Note: does not validate. We would like it to, but that would mean reduced user experience for the majority of our visitors. -->
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
  <title>The meta http-equiv=&quot;Content-type&quot; appears twice | drupal.org</title>
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/codefilter/codefilter.css?p" />
<link type="text/css" rel="stylesheet" media="all" href="/files/css/css_7c24766e3b00d28b208e32e26fd06b02.css" />
<link type="text/css" rel="stylesheet" media="print" href="/files/css/css_ce84c4a203f9581727de3c8acecbdd4f.css" />
  <script type="text/javascript" src="/files/js/js_f0599e07b12578dc6cc738f69f60aa77.js"></script>
<script type="text/javascript">
brunodbo’s picture

That is not correct; the content type meta tags appears twice because it is added from Drupal.
See the source of this page, and you will see it twice, even though Drupal.org doesn't use Nodewords.

I'm not sure if I understand: are you saying Drupal core adds the Content-Type meta tag twice? When I remove that code from nodewords.module (v6.x-1.11, the current stable release), the Content-Type meta tag appears only once in my source.

Anonymous’s picture

I'm not sure if I understand: are you saying Drupal core adds the Content-Type meta tag twice?

Yes, it does. There is also a report in the Drupal project queue (#451304: Drupal outputs two meta content-type tags). Then, it's evident the meta tag content-type is added from Drupal from the following code:

<?php
function drupal_final_markup($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('/<head[^>]*>/i', "\$0\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />", $content, 1);
}
?>

I think that seeing the content type meta tag twice in a site that doesn't use Nodewords is a clear demonstration that is not an issue related with Nodewords.

jfine’s picture

Status: Closed (duplicate) » Needs review

I just noticed this issue. This is not a duplicate of #451304.

Line 542-544 in nodewords.module duplicates the content type.

  $variables['head'] = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" .
    $output . "\n" .
    drupal_set_html_head();

When I remove the content-type section of this string the duplicate goes away. Additionally when I disable the nodewords module the duplicate goes away. What was the purpose behind nodewords adding a content-type?

Additionally, it doesn't look like drupal_set_html_head() is being used properly by nodewords. Other modules trying to hook into head via the API effectively drupal_set_html_head() and drupal_get_html_head() will effectively remove the tags added by nodewords.

damienmckenna’s picture

Issue tags: +v6.x-1.12 blocker
dave reid’s picture

Status: Needs review » Fixed

The current code is no longer in 6.x-1.x and looks fixed to me. I can't reproduce the duplicate Content-Type tag with the latest code.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

chaloalvarezj’s picture

Version: 6.x-1.11 » 6.x-1.x-dev
Status: Closed (fixed) » Active

I had this bug on the 6.x-1.11 version, and the patch in #6 Posted by brunodbo solved it. However, after updating to the latest 6.x-1.x-dev version of December 2, 2010, the bug persist! and the patch does not apply anymore.

Edit: Just uninstalled nodewords altogether... and the double meta: http-equiv="Content-Type" is still there. So it appears to be Drupal bug after all.

dave reid’s picture

Status: Active » Closed (duplicate)

It is not a nodewords issue. It does not add any content-type meta tags itself. What is really responsible is this Drupal core issue: #451304: Drupal outputs two meta content-type tags.

damienmckenna’s picture

Status: Closed (duplicate) » Needs work

Needs to be re-rolled against the latest 6.x-1.x codebase.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1.05 KB

Patch attached.

dave reid’s picture

Status: Needs review » Fixed

This has been re-applied.

Status: Fixed » Closed (fixed)
Issue tags: -meta, -charset, -v6.x-1.12 blocker

Automatically closed -- issue fixed for 2 weeks with no activity.