Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Donor search results URLs #1175

Closed
1 task
kevinwhoffman opened this issue Oct 29, 2016 · 1 comment
Closed
1 task

Clean up Donor search results URLs #1175

kevinwhoffman opened this issue Oct 29, 2016 · 1 comment
Assignees
Milestone

Comments

@kevinwhoffman
Copy link
Contributor

Issue Overview

When searching for Donors, the search results URLs contain _wpnonce and _wp_http_referer query args. These args should be removed prior to redirection.

Example URL for Search Results from Donor Reports Tab

http://give.dev/wp-admin/edit.php?_wpnonce=577d19d542&_wp_http_referer=%2Fwp-admin%2Fedit.php%3Fpost_type%3Dgive_forms%26page%3Dgive-reports%26tab%3Ddonors&s=test&paged=1&post_type=give_forms&page=give-reports&tab=donors

Expected Behavior

The search results URL should not contain _wpnonce and _wp_http_referer query args.

Current Behavior

_wpnonce and _wp_http_referer query args are present in search results URLs. The _wp_http_referer query arg compounds in length with each successive search.

Possible Solution

I looked into how WP core handles nonce fields during a search query, and I found that those arguments are removed in edit.php prior to redirecting to search results. Here are the relevant lines: https://github.com/WordPress/WordPress/blob/master/wp-admin/edit.php#L175-L178

I tried placing that same code at the top of reports.php:

if ( ! empty($_REQUEST['_wp_http_referer']) ) {
     wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) );
     exit;
}

However, that code results in Fatal error: Uncaught Error: Call to undefined function wp_redirect().

We should determine if the nonce field is even serving a purpose here, or alternatively find a way to remove the query args from the URL.

Steps to Reproduce (for bugs)

  1. Visit Reports > Donors tab in Give 1.8.0.
  2. Submit a search query in the top-right corner.
  3. Note the query _wpnonce and _wp_http_referer query args in the URL.
  4. Submit another search query an notice the _wp_http_referer compounds in length.

Todos

  • Determine if the nonce field serves a purpose in this context. @DevinWalker
@DevinWalker DevinWalker added this to the 1.9 milestone Oct 31, 2016
@DevinWalker DevinWalker modified the milestones: 1.8, 1.9 Oct 31, 2016
ravinderk added a commit to ravinderk/Give that referenced this issue Nov 24, 2016
@ravinderk ravinderk mentioned this issue Nov 24, 2016
3 tasks
@ravinderk
Copy link
Collaborator

@DevinWalker I found that we have the same issue on donor page and donor tab under report page.

@ravinderk ravinderk reopened this Jan 17, 2017
ravinderk added a commit to ravinderk/Give that referenced this issue Jan 17, 2017
@ravinderk ravinderk mentioned this issue Jan 17, 2017
3 tasks
DevinWalker pushed a commit that referenced this issue Jan 17, 2017
DevinWalker pushed a commit that referenced this issue Jan 17, 2017
…o release/1.8

* 'release/1.8' of https://github.com/WordImpress/Give:
  Remove unused code from forms_dropdown fx
  Show untitled form name under form list on domation edit page
  Fix wrong View API Log url
  Fix ajax user seach results list not showing bug
  Fix #1175
  Show unname donation form title in widget under form listing
  Save default currency position on fresh install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants