Skip to:
Content

bbPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2701 closed defect (bug) (duplicate)

Default "do not reply" address for emails is built incorrectly

Reported by: djpaul's profile DJPaul Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5.4
Component: General Keywords: has-patch
Cc:

Description

Discovered this on a 2.5.4 site, but am aware of the related changes in #2618, so my line numbers will refer to the trunk.

In bbp_get_do_not_reply_address, ltrim is used incorrectly to try to strip the http:// prefix off the start of get_home_url. ltrim works on a per character removal (on the left side of the input string) rather than a whole string match. Any h, t, p, s, colon, or forward slash characters appearing at the start of get_home_url will be removed, not just the protocol.

For example:

wp> ltrim( 'http://helpfulpaul.com', '^(http|https)://' )
string(14) "elpfulpaul.com"

This causes undeliverable or invalid emails in certain situations because (in my case) the "from" address was incorrect.

	function bbp_get_do_not_reply_address() {
	        $email = 'noreply@' . str_replace( 'www.', '', ltrim( get_home_url(), '^(http|https)://' ) );
	        return apply_filters( 'bbp_get_do_not_reply_address', $email );
	}

I suggest the following to fix:

$email  = 'noreply@' . preg_replace( '@^https?://(www\.)?@i', '', get_home_url() );

I'll patch it shortly.

Attachments (1)

bbpress-2701.01.patch (557 bytes) - added by DJPaul 10 years ago.

Download all attachments as: .zip

Change History (5)

#1 @DJPaul
10 years ago

  • Keywords has-patch added

Patch attached.

#2 @DJPaul
10 years ago

This issue was introduced in #2162

#3 @netweb
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks Paul, though I'm closing as duplicate of #2618, see ticket:2618#comment:10 and attached 2618.4.diff patch.

Also of note, the regex you added should not include either of the @ character matches, get_home_url() never includes the email @ symbol.

#4 @DJPaul
10 years ago

The @ characters can be used as an alternative delimiter character for PCRE regular expressions; http://php.net/manual/en/regexp.reference.delimiters.php

Forward slashes are probably the most common, but if I used them in this patch, I would have to escape the slashes in the :/ / part of the URL, and that just makes the regex longer and harder to read. Using an alternate delimiter to avoid escaping characters is a convenience.

Last edited 10 years ago by DJPaul (previous) (diff)
Note: See TracTickets for help on using tickets.