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

Fixes #21 Exclude admin_url() from being rewritten #22

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

engahmeds3ed
Copy link
Contributor

@engahmeds3ed engahmeds3ed commented Jul 20, 2022

Here we need to exclude admin_url in srcset from being rewritten by the CDN url not to cause the logout problem.

The problem

When Jetpack plugin is installed, it adds an image for stats in the adminbar in front pages which has the following HTML

<img src="https://www.xxx.com/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale" srcset="https://www.xxx.com/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale 1x, https://www.xxx.com/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale-2x 2x" width="112" height="24" alt="Stats" title="Views over 48 hours. Click for more Site Stats.">

and when we change the srcset for this image, it's converted to this one

<img src="https://www.xxx.com/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale" srcset="https://xxx.rocketcdn.me/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale 1x, https://xxx.rocketcdn.me/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale-2x 2x" width="112" height="24" alt="Stats" title="Views over 48 hours. Click for more Site Stats.">

and I believe this will force logout when the pages tries to load this img

https://xxx.rocketcdn.me/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale

because it will redirect you to the

https://www.xxx.com/wp-admin/admin.php?page=stats&amp;noheader&amp;proxy&amp;chart=admin-bar-hours-scale

but the referrer will be from the CDN url so it forces logout.

The Solution

Would be to exclude the urls that have wp-admin OR admin_url on it.

@engahmeds3ed engahmeds3ed self-assigned this Jul 20, 2022
@engahmeds3ed engahmeds3ed marked this pull request as ready for review July 22, 2022 11:14
@engahmeds3ed engahmeds3ed requested a review from a team July 22, 2022 11:14
@Tabrisrp
Copy link
Contributor

Can you explain what was happening and the choice for the fix?

@engahmeds3ed engahmeds3ed linked an issue Jul 22, 2022 that may be closed by this pull request
@engahmeds3ed
Copy link
Contributor Author

Can you explain what was happening and the choice for the fix?

I updated the PR's description with more details and connected it to the issue.

@Tabrisrp
Copy link
Contributor

What do you think of moving this check to the rewrite_url() method instead, so that we make sure we never change the URL of anything that is from the admin? This will still cover the srcset case, but also other potential future cases.

@Tabrisrp Tabrisrp added the bug Something isn't working label Jul 22, 2022
@engahmeds3ed
Copy link
Contributor Author

What do you think of moving this check to the rewrite_url() method instead, so that we make sure we never change the URL of anything that is from the admin? This will still cover the srcset case, but also other potential future cases.

Good idea, fixed.

@Tabrisrp Tabrisrp changed the title Exclude admin_url in srcset from being rewritten Fixes #21 Exclude admin_url in srcset from being rewritten Aug 1, 2022
@Tabrisrp Tabrisrp changed the title Fixes #21 Exclude admin_url in srcset from being rewritten Fixes #21 Exclude admin_url() from being rewritten Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclude URLs that have wp-admin OR admin_url in it
2 participants