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

Slash the slash #1601

Merged
merged 3 commits into from
Jul 28, 2023
Merged

Slash the slash #1601

merged 3 commits into from
Jul 28, 2023

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Jul 25, 2023

What does this implement/fix?

As a consequence of pi-hole/web#2655, redirection from the login page to any other page than the dashboard is broken.

This PR fixes this in the proper way by redirecting from URLs with trailing slashes such as /admin/queries/" to /admin/queries which is where the actual scripts are (they'd have to be in /admin/queries/index.html otherwise)


Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

… to any other page than the dashboard is broken. This PR fixes this in the proper way by redirecting from URIs such as "/admin/queries/" to "/admin/queries" which is where the actual scripts are (they'd have to be in "/admin/queries/index.html" otherwise)

Signed-off-by: DL6ER <[email protected]>
@DL6ER DL6ER requested a review from a team July 25, 2023 15:43
@PromoFaux
Copy link
Member

Testing in a container - it appears the behaviour that was fixed by pi-hole/web#2655 is back

Visiting pi.hole/admin redirects to 172.20.2/admin/

@DL6ER
Copy link
Member Author

DL6ER commented Jul 26, 2023

Thanks for testing. We accidentally undid the "trick" we applied over there. My latest commit should fix this "once and for all" by handling all cases (ending or not in a slash) properly. Please test again

@PromoFaux
Copy link
Member

Visiting pi.hole/admin redirects to 172.20.2/admin/

This is still the case for me

The other issue that I showed in the gif in mattermost earlier, however, is fixed

@DL6ER
Copy link
Member Author

DL6ER commented Jul 28, 2023

@PromoFaux I cannot reproduce this, but it might be a cache issue. Could you try again with another browser or her with the dev tools opened on the networks tab and selected to not load from cache?

@PromoFaux
Copy link
Member

Same thing in an incognito window with cache disabled

If I'm logged out, it works... at least, I get redirected to 127.0.0.1/admin/login?target=%2admin

Once I log in, it takes me to 127.0.0.1/admin/

If I then manually remove the trailing slash you see the following behaviour:

image

image

@DL6ER
Copy link
Member Author

DL6ER commented Jul 28, 2023

I'm confused now, that is only happen when you manually remove the slash or does it also happen when you do something in the way it should be done? (No doubt we should get the manual removal of the slash fixed as well)

@PromoFaux
Copy link
Member

Seemingly only when I do the manual remove of the slash. Imagine I am authenticated, and then open a new tab and type 127.0.0.1/admin - it should probably redirect

@yubiuser
Copy link
Member

I can confirm, everything works as it should when used as one should use it. However, when I'm loggend in via hostname/admin/ and remove the trailing slash I get redirected to IP/login as unauthorized.

@DL6ER
Copy link
Member Author

DL6ER commented Jul 28, 2023

It should now be fixed. This last change actually made pi-hole/web#2655 completely redundant, however, it also doesn't hurt to have it.

Copy link
Member

@PromoFaux PromoFaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with a local build that this is now working as expected, even when used as not expected.

image

@DL6ER DL6ER merged commit e085728 into development-v6 Jul 28, 2023
@DL6ER DL6ER deleted the fix/redirect_slash branch July 28, 2023 21:07
@PromoFaux PromoFaux mentioned this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants