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

Pagination / pager->links() double encodes links #1680

Closed
niteraven7 opened this issue Jan 21, 2019 · 13 comments
Closed

Pagination / pager->links() double encodes links #1680

niteraven7 opened this issue Jan 21, 2019 · 13 comments

Comments

@niteraven7
Copy link

My app is showing some results/reviews on a page and I also have the ability to filter these results using various criteria. My filter parameters passed as an array and are form submitted with get that has a URL like:

/reviews?filter%5Bkeyword%5D=test&filter%5Bsubmit%5D=1

The pager->links() currently and incorrectly double encodes the [] and then appends page=1, 2, 3 etc. to the end:

/reviews?filter%255Bkeyword%255D=claim&filter%255Bsubmit%255D=1&page=2

Note the 255B and 255D are double encoded [ and ] and it's breaking the URL.

version: alpha4

Thanks!

-Kyle

@InsiteFX
Copy link
Contributor

@niteraven7
Copy link
Author

@InsiteFX Thanks for the response. I did do some research before posting and did come across that article and others similar to it. I feel like I have ran into this issue before years ago with a CI2 app... I've been doing web development for a long time.

The issue I'm having now is I'm running this app in the Google Cloud App Engine Standard PHP72. I'm not sure what web server Google is serving from- I'm thinking NGINX... but they don't offer htaccess files and the such.

Is there any way to decode the URL first using CI4 before appending the page parameter?

I'm not sure if this is a CI4 bug but perhaps logic can be put in place in the code to prevent this from happening?

@InsiteFX
Copy link
Contributor

If your form is using a GET try using a POST method from what I read it does not have that problem using a post only a get has the double encoding.

@niteraven7
Copy link
Author

@InsiteFX OK- but the whole point of pager->links() is to carry on the query parameters. That way the user can paginate through pages of results (filtered or not).

@niteraven7
Copy link
Author

I'm thinking of creating a CI4 Controller Filter to modify/clean-up the URI before it's passed on to controller. Maybe I can grab the get variables and loop through/decode/clean-up stuff and then it'll work. I'm just having trouble figuring out how to do that now :-/

@lonnieezell
Copy link
Member

@niteraven7 Is your code up to date? I feel like we've ran into this in the past and fixed it.

@niteraven7
Copy link
Author

@lonnieezell Yes, I'm using alpha4.

@niteraven7
Copy link
Author

@lonnieezell I was hoping you'd chime in. I can see this as somewhat of a grey area where it could be considered a web server issue or framework issue.

I'm using the pager exactly as described in the documentation. I'm not doing anything funny.

@niteraven7
Copy link
Author

I think this is what you might be thinking of:

#950

@niteraven7
Copy link
Author

It looks like you've decoded the values but not the parameters/keys...

@niteraven7
Copy link
Author

// URL Decode the value to protect // from double-encoding a URL. // Especially useful with the Pager. $parts[$key] = $this->decode($value);

@niteraven7
Copy link
Author

It looks like this works:

$parts[$this->decode($key)] = $this->decode($value);

@lonnieezell
Copy link
Member

@niteraven7 I believe you are correct. Just pushed that change. Hopefully this will work for you.

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