rocklobster-in / contact-form-7

Contact Form 7 - Just another contact form plugin for WordPress.
Other
290 stars 144 forks source link

Get url from post if no referrer is present #1491

Closed michaelw85 closed 1 month ago

michaelw85 commented 1 month ago

When you run your website on a server with a referrer policy set to no-referrer special mail tag _url will return the ajax url, which I believe will never be useful for an admin. I've added a fallback for this scenario to use the post url instead.

Issue mentioned by other users: https://wordpress.org/support/topic/special-mail-tag-_url-returns-wrong-url/

takayukister commented 1 month ago

$_POST['postId'] is not defined and even if defined it's not fallback for [_url].

michaelw85 commented 1 month ago

Sorry, I just noticed the post ID is coming from custom code in my WP setup. I assumed it was there by default. 🤦 I should use a clean WP setup for this kind of work.

Do you agree that the code needs to be refactored to not rely on $_SERVER['HTTP_REFERER']? It is not something we should rely on but would rather be something for a fallback in my opinion.

takayukister commented 1 month ago

I know HTTP_REFERER is not reliable and look for alternatives.