Using an updated version of the code from issue 27633, I added referrer information to the contact form, but it doesn't work right.

The hidden field is correct on the page, but when I submit, the email says it was referred from '/contact', so I think the problem is with the form processing or validation. How do I fix this?

Details: Using Drupal 6 beta 1, Linux Server

Comments

bradlis7’s picture

Status: Active » Needs work

Not sure if this is a better status to have or not...

bradlis7’s picture

Version: 6.x-dev » 7.x-dev

I'll put it down for 7, because I don't think 6 is open for this feature.

BioALIEN’s picture

I would personally tag this for D6. What you're patching here looks security related as most contact forms return a referrer for an endless list of reasons.

It's a welcome enhancement to the contact.module and it gets my +1.

bradlis7’s picture

Version: 7.x-dev » 6.x-dev

If you think so, I'll tag it so until someone says otherwise. Should this be bug report?

bradlis7’s picture

Status: Needs work » Needs review
StatusFileSize
new4.45 KB

Well, I've made a working patch, but I don't like the way I had to do it. It feels like too much of a hack, using session variables and such. If there's a form API guru out there, I could use your wisdom on this...

dries’s picture

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

Coding style needs work. Should also be postponed to Drupal 7 as Drupal 6 is feature frozen.

bradlis7’s picture

StatusFileSize
new4.47 KB

Try this. If any more code cleanup is necessary, let me know.

robin monks’s picture

Please make sure some sort of check_plain is run on the referrer, we don't want to pass uncleaned input.

Robin

dave reid’s picture

Version: 7.x-dev » 8.x-dev

Instead of writing the referrer to the session, it should be added as a FAPI element:

$form['referrer'] = array(
  '#type' => 'value',
  '#value' => $_SERVER['HTTP_REFERER'],
);

I think this also needs more discussion and since it's a feature request, it's not likely to be accepted for D7. Bumping to D8.

deekayen’s picture

Status: Needs work » Closed (won't fix)

In the many years since this issue was created, the mail_alter hook was introduced. I can picture altering various things through a contrib module to add a form value containing the referrer and then altering that into the mail, either as a body concatenation or a new X- header.