When comments are posted using either of the 3 standard content types (filtered HTML, full HTML, PHP), an extra "p" element is wrapped around the comment, making it invalid HTML, as "p" elements cannot be nested.

The problem also applies to issues, just like it applies to their comments.

It does not apply to previews, for either issues or comments, only to their rendition once submitted.

It appears to be theme-independent. As of today, it is present on drupal.org itself.

It does not seem to apply to other node types, so it seems to be located somewhere within project.

Comments

dww’s picture

yup, the project module's code is full of hard-coded <p> elements. :( someone who knows more about CSS than i should probably fix all this so that the resulting output still looks reasonable once we rip all those out...

dww’s picture

Status: Active » Closed (fixed)

Not sure when this was changed, but this no longer seems to be happening. fgm, if you notice this is still a problem, please re-open. Thanks.

fgm’s picture

Project: Project » Project issue tracking
Version: x.y.z » 5.x-1.0
Status: Closed (fixed) » Active

This particular invalidity cause (nested P elements) has apparently been removed in the meantime, but another exists: taking for example this very page on d.o., for unlogged-in users, it is still invalid for two reasons:

  1. two errors appear because It contains: <div class="links">» <a href="/"><a href="/user/login?destination=project/comments/add/56944">Login</a> or <a href="/user/register?destination=project/comments/add/56944">register</a> to follow up</a></div>, which is invalid because of nested A elements in the "Follow up" link, which seems to be part of project_issue_link, although I don't see how
  2. another is duplicate XHTML IDs (one is for log in, the other for search), but these are outside project scope
hunmonk’s picture

Version: 5.x-1.0 » 4.7.x-2.x-dev
Status: Active » Patch (to be ported)

can't locate the issue you refer to. i'm guessing that it was fixed already. marking to be ported if anybody cares to fix this.

fgm’s picture

Status: Patch (to be ported) » Active

Hunmonk,

Just look at : http://validator.w3.org/check?uri=http%3A%2F%2Fdrupal.org%2Fnode%2F56944...

as of today, the invalid HTML is still being generated for the same errors with the version currently running on d.o. (although I don't know which one it is).

hunmonk’s picture

Version: 4.7.x-2.x-dev » 5.x-1.x-dev

@fgm: please feel free to submit a patch to correct this -- it's doubtful it will be addressed any time soon unless you do. :)

fgm’s picture

It's rather difficult to guess without being able to test on the site itself, but I looks rather like a case of hook_link_alter somewhere on the site adding <a href"/"> to the link in project_issue_link, which already includes a <a href="[...] returned from theme_project_issue_follow_up_forbidden.

In such a case, theme_links, as invoked from node_view, will generate the extraneous <a href="/"> causing this error.

But without access to the actual d.o. code, it's hard to tell.

dww’s picture

With very few exceptions, d.o runs the HEAD of project*. I'm pretty sure this is just a trivial, silly bug if someone looked closely at those login-or-register links and where they're coming from.

john morahan’s picture

The same thing is happening on e.g. the forum pages on d.o, with the "Login or register to post comments" link.

Is it possible that bluebeach is overriding theme_links, but not changing the <a> to <span> when $link['href'] is unset?

hunmonk’s picture

Project: Project issue tracking » Drupal.org infrastructure
Version: 5.x-1.x-dev »
Component: Comments » Bluebeach

@dww: i've looked at the project issue code for the generation of those links, and see no issues.

i've tried to reproduce this problem on a local install with the garland theme, and no luck.

since john is reporting this same problem with links generated from other modules, i'd conclude that the next most likely place to check is, in fact, bluebeach. reassigning.

fgm’s picture

Yup, I've identified the problem thanks to a fragment of bluebeach killes pasted me. the culprit appears to be function phptemplate_links($links) , which indiscriminately invokes l($link['title'], $link['href'] ... without checking whether a href attribute exists or not.

And since l() does not allow non-linking A elements, it builds a link to the home page, causing what we see.

The obvious solution is to check whether such an attribute exists and invoke l or not depending on whether the attribute is present or not.

The arguably better solution would be to allow l() to work without a href attribute, but IIRC the last time I suggested this, it was rejected on backwards compatibility grounds.

fgm’s picture

This should fix the problem. However, I don't have access to bluebeach so can't generate a patch or test.

function phptemplate_links($links) {
  $html_links = array();
  foreach ($links as $link) {
    if (isset($link['href'])) {
      $html_links[] = l($link['title'], $link['href'], $link['attributes'], $link['query'],
$link['fragment'], FALSE, $link['html']);
    }
    else {
      if (!$html) {
        $link['title'] = check_plain($link['title']);
        }
      $html_links[] = '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';    
    }
  }
  return implode(' <C2><B7> ', $html_links);
}

This test is actually lifted from API sample for D5 theme_links.

fgm’s picture

Status: Active » Needs review

Forgot to set status

john morahan’s picture

function phptemplate_links($links) {
  $html_links = array();
  foreach ($links as $link) {
    $html = isset($link['html']) && $link['html'];
    if (isset($link['href'])) {
      $html_links[] = l($link['title'], $link['href'], $link['attributes'], $link['query'],
$link['fragment'], FALSE, $html);
    }
    else {
      if (!$html) {
        $link['title'] = check_plain($link['title']);
      }
      $html_links[] = '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';   
    }
  }
  return implode(' <C2><B7> ', $html_links);
}
fgm’s picture

whoops, you're right, I missed the line building $html when pasting.

killes@www.drop.org’s picture

What to do with this? Still valid?

fgm’s picture

Issue still present, try the link on http://drupal.org/node/56944#comment-392973

Since bluebeach is not public, I can't test the patch on the current version.

drumm’s picture

Component: Bluebeach » Drupal.org theme
drumm’s picture

Status: Needs review » Fixed

This should be fixed in SVN trunk and 5.

If you want to help out with bluebeach, see http://groups.drupal.org/drupalorg-theme-developers

fgm’s picture

Status: Fixed » Needs review

If SVN trunk and 5 is what's currently on d.o., the problem is not fixed.

However, not being a member of the infra team, I don't have SVN access to test it elsewhere: these apparently don't have the same accounts as CVS.

drumm’s picture

Status: Needs review » Fixed

It was committed, but not deployed yet. It is now running live on scratch.drupal.org.

fgm’s picture

Status: Fixed » Needs work

Then it does not completely fix the issue: the same problem is present on scratch.drupal.org with still 16 errors, in comparison with 61 errors on drupal.org for the same page.

Check http://validator.w3.org/check?uri=http%3A%2F%2Fscratch.drupal.org%2Fnode...

Graeme Blackwood’s picture

Status: Needs work » Closed (cannot reproduce)

I am closing this as I'm pretty sure it is fixed. I am not getting any validation errors and we are now on a totally different theme.

Project: Drupal.org infrastructure » Bluecheese
Component: Drupal.org theme » Miscellaneous