-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: Ignore non-HTML responses in storePreviousURL #6012
fix: Ignore non-HTML responses in storePreviousURL #6012
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was worried this would be too restrictive because there might be some served content of a variant type. A little research suggests that the content type should actually be this restrictive:
text/html
: All HTML content should be served with this type.
I would like to see a tests added to confirm & exempt this - it should be fairly easy, copying what we already have.
This fix seems to be reasonable. The image URL is not a page.
But this changes the behavior of |
@tearoom6 We expect all contributions to conform to our style guide, be commented (inside the PHP source files), be documented (in the user guide), and unit tested (in the test folder). The user guide and unit testing are missing. |
74a11bc
to
2fe0228
Compare
@@ -33,6 +33,7 @@ Breaking Changes | |||
**************** | |||
|
|||
- The ``system/bootstrap.php`` file no longer returns a ``CodeIgniter`` instance, and does not load the ``.env`` file (now handled in ``index.php`` and ``spark``). If you have code that expects these behaviors it will no longer work and must be modified. This has been changed to make `Preloading <https://www.php.net/manual/en/opcache.preloading.php>`_ easier to implement. | |||
- ``previous_url()`` has been changed to return only the URLs whose Content-Type was ``text/html``. Accordingly, the behavior of ``redirect()->back()`` has been changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the upgrade note, we write what to do when upgrading.
Since it seems unlikely that any developers were using non-HTML URLs, is there no need to list it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I understood. I have removed it from the upgrade note 👍
3925228
to
a1e0804
Compare
@tearoom6 Thank you for updating. The PHPStan errors are not related to this PR. But these errors was fixed in the latest There is no conflict, so we can merge this PR if you don't rebase. |
Co-authored-by: kenjis <kenji.uui@gmail.com>
a1e0804
to
a86e392
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you for reviewing and the advices! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work! Thank you for your contribution.
Description
In this PR, I added an exclusion condition for
storePreviousURL
: "Response Content-Type is not text/html".Background
In our application, some images are composited in the CodeIgnitor controller and returned.
The request URL for such case is saved as
_ci_previous_url
because it does not meet any of the exclusion conditions of the existingstorePreviousURL
implementation, and when redirecting back, etc., there is a case where the request is redirected to the URL of the image.The URL to store as
previous_url
is usually considered to be an HTML (text/html
) case, so I have added that as a condition.Checklist: