Opened 13 years ago
Closed 13 years ago
#3280 closed defect (bug) (fixed)
Invalid URLs are incorrectly handled
Reported by: | DJPaul | Owned by: | |
---|---|---|---|
Milestone: | 1.5 | Priority: | blocker |
Severity: | Version: | ||
Component: | Core | Keywords: | |
Cc: |
Description
Alot of BuddyPress URLs are not handling invalid URLs correctly. Make sure you have wp_debug set.
These must 404, not redirect back to the home page or a component's root page:
1) http://example.com/groups/INVALID/ (and all subdirs, i.e. /forum/, /members/, and so on).
2) http://example.com/groups/valid/INVALID/
3) http://example.com/groups/valid/forum/INVALID
4) http://example.com/members/INVALID/
5) http://example.com/members/valid/INVALID/
If a valid component is on the URL, I think that component should be responsible for handling 404s within that component, rather than letting it fall back to BP_Core, e.g.
$wp_query->set_404(); status_header( 404 ); nocache_headers();
Attachments (6)
Change History (21)
#2
@
13 years ago
I agree that this should be fixed, but is it really a blocker? It's not a regression; BP already works like this (for better or for worse).
In any case, it should mean just changing a few 'return false' calls to the status_header(404); sequence, right?
#3
@
13 years ago
Fairly rough first patch attached. There may be some more situations in the messages component to 404 for, but I was unsure.
Had to hack up bp_core_catch_no_access(). As a result, the "If the displayed user was marked as a spammer and the logged-in user is not a super admin" thing doesn't work.
For the email notifications, I suggest we go through and edit all of those to point to wp-login.php with a redirect_to argument.
#4
@
13 years ago
Patch applied over at testbp.org. Still doesn't seem to fix the http://testbp.org/members/sdafsadfsdf/profile issue though.
#6
@
13 years ago
Thanks for starting this, DJPaul. 3280-2.patch is an expanded version with a few enhancements:
- Distinguish between groups that don't exist and groups that one does not have access to. If you attempt to visit a non-existent group, or any subpage of a non-existent group, you get a 404. If you attempt to visit the inner page of a group to which you do not have access, you get bp_core_no_access(), ie a redirect to the login page with a redirect_to param. This will take care of the email notification issue without resorting to putting the hideous wp-login.php url in emails :)
- http://example.com/members/INVALID/profile now 404s. I did this by putting a check directly into bp_core_set_uri_globals(), where BP attempts to find a displayed_user. This was tricky for components that also have root component pages, like http://example.com/members/INVALID/groups, because WP's canonical URL functions tried to "help" our 404 situation by redirecting back to the similarly-named WP page with the name 'Groups'. That's why you'll see
remove_action( 'template_redirect', 'redirect_canonical' );
in a few places.
#7
@
13 years ago
I was thinking about this, and I think it might be nice to make a wrapper function bp_handle_404() or something like that, since unsetting the current_component and unhooking 'redirect_canonical' will generally be necessary in the case of BP 404s. This'll also make it easier for plugin authors to do proper 404ing.
#8
@
13 years ago
Patch updated to remove unused global per IRC. /groups/valid/forum/INVALID/ is still incorrectly handled.
#10
@
13 years ago
As much as I really, really hate it, unless we want to whitelist URLs for everything, I think we're going to have to put up with URLs like /groups/valid/send-invites/ANYTHING/GOES/HERE/.
#11
@
13 years ago
As much as I really, really hate it, unless we want to whitelist URLs for everything, I think we're going to have to put up with URLs like /groups/valid/send-invites/ANYTHING/GOES/HERE/.
I don't think that's true. We can just change the logic in groups_screen_group_invite() a bit. Working on a patch.
It's true that this is a huge PITA to fix, but it's good to do now, so we can set some best practices for future dev.
#13
@
13 years ago
Nice one; 3280-5.patch attached with convenience function to set the 404. Also includes a bunch of whitespace cleanup.
Related: #3211