comment.module sets $form['#attributes']['destination'] = $_REQUEST['destination']. This results in a 'destination' attribute in the HTML form tag (theme_form puts it there). The attribute is not defined for the form tag and therefore results non-compliant XHTML.

Also, AFAIK, the attribute has no effect. Removing it does not prevent the destination query parameter from working, e.g., from admin/content/comment's edit links.

Patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Status: Needs review » Needs work

Good catch... but $_REQUEST['destination'] indicates to where the form should redirect once it's submitted. Therefore, I think this should change to $form['#redirect'] = $_REQUEST['destination']..,.

bjaspan’s picture

Version: x.y.z » 6.x-dev
Status: Needs work » Needs review

The offending line was added in comment.module:1.379 (http://cvs.drupal.org/viewcvs/drupal/drupal/modules/comment/comment.modu...). It seems to have been part of one of the initial Forms API patches: http://drupal.org/node/29465.

The old code

$destination = $_REQUEST['destination'] ? 'destination='. $_REQUEST['destination'] : '';
return theme('box', $title, form($form, 'post', url('comment/reply/'. $edit['nid'], $destination)));

was replaced with

if ($_REQUEST['destination']) {
  $form[attributes]['destination'] = $_REQUEST['destination'];
}

I never worked with 4.6 but I looked into form.inc from that era. The 4th arg was $attributes and got inserted into the <form> tag. So, the old code generated <form ... destination=some/path> which, it turns out, is exactly what we are getting now: invalid XHTML that has no effect. So the patch accurated preserved the bug. :-)

So, $_REQUEST['destination'] has not had any effect on this form since before 4.6. Putting it in $form['#redirect'] now would be change of semantics. Furthermore, why should this one form set #redirect = $destination? If that is correct behavior, the FAPI should do it, no?

Conclusion: I still think the code should be removed for 6.x-dev, 5.0, and 4.7.

catch’s picture

Title: comment.module produces invalid form » remove raw $_REQUEST from comment.module
FileSize
705 bytes

re-roll.

bjaspan’s picture

Patch re-rolled.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

indeed, this is cruft.

Gábor Hojtsy’s picture

Version: 6.x-dev » 5.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

This looks quite bad, indeed. Committed to 6.x.

bjaspan’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
FileSize
757 bytes

My original patch for 5.x from 11/7/06 still applies but is not from the Drupal root directory. Here's a re-rolled patch for 5.x.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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