litzinger / URL-Helper

Apache License 2.0
17 stars 10 forks source link

Case Sensitivity in URI segements #12

Open reevesc opened 7 years ago

reevesc commented 7 years ago

Looks like there's a small bug in the query logic of the set_category_segments() method. I actually encountered the issue on an older version of the extension (1.0.5) but tested on the lastest version and it's still there.

Details:

On line 209 (version 1.12.0) the where_in() method is called and the $segs array is passed in, but the query that's generated is not case sensitive. So, if there is a category with a cat_url_title of 'hello' and one of the URI segments is 'HELLO' - the query returns a matching result. By itself, that's not really an issue, but when the $ids array is flipped (line 216) PHP throws an undefined index warning because it's trying to get the value of $ids['hello'] which doesn't exist (it should be looking for $ids['HELLO']) on lines 221-226.

I was able to patch the issue by changing line 209 from:

->where_in('cat_url_title, $segs)`

To:

->where_in('CAST(cat_url_title as BINARY)', $segs)

Looks like there are several ways to address it, the one above seems to be working quite well. That said, the site does not have Publisher installed so I'm not able to test against that module (I didn't dive too deep into the logic so it may not even be relevant).

Let me know if you need more info or would like me to send up a pull request.

C.

litzinger commented 7 years ago

Just now getting around to this. Yeah that change makes sense. I'll merge the PR if you submit one.

reevesc commented 7 years ago

Will do.