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

Regex redirects without leading / are buggy #269

Closed
1 task done
peterwilsoncc opened this issue May 11, 2022 · 2 comments · Fixed by #279 or #395
Closed
1 task done

Regex redirects without leading / are buggy #269

peterwilsoncc opened this issue May 11, 2022 · 2 comments · Fixed by #279 or #395
Assignees
Labels
type:bug Something isn’t working.
Milestone

Comments

@peterwilsoncc
Copy link
Contributor

peterwilsoncc commented May 11, 2022

Describe the bug

Enabling a regular expression without a leading / can be quite buggy.

  • in most cases I am getting redirected to the wp-admin
  • if a full URL is added added as the destination, it will include the domain twice.

Steps to Reproduce

Scenario One

  1. Create a regular expression redirect
    • Redirect from: (go|be)\/h{0,}$
    • Redirect to: /404-regex
  2. In the CLI run curl -I http://xu-osp-plugins.local/be/hhhh
  3. Observe the location header is http://xu-osp-plugins.local/wp-admin/

Scenario Two

  1. Create a regular expression redirect
    • Redirect from: (go|be)\/h{0,}$
    • Redirect to: http://xu-osp-plugins.local/404-regex
  2. In the CLI run curl -I http://xu-osp-plugins.local/be/hhhh
  3. Observe the location header is /http://xu-osp-plugins.local/wp-admin/ (note leading slash)

Screenshots, screen recording, code snippet

No response

Environment information

  • Device MacBook Pro
  • OS: MacOs 11.6.5
  • Browser: curl 7.64.1

WordPress information

WordPress 6.0
WordPress 5.9
WordPress 5.8

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jeffpaul
Copy link
Member

@peterwilsoncc do you think it's noting the WP site URL ahead of the input field including a trailing / and then strip any leading / in the input field?

@jeffpaul jeffpaul added this to the 2.0.0 milestone Jun 28, 2022
@peterwilsoncc
Copy link
Contributor Author

@jeffpaul Let me consider it for a bit.

I'll do some further tests with the code @iamdharmesh left commented out in 4c04218 and see if there are further edge cases for regexes starting with ^ or ^/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment