CodeIgniter Forums
Searching by tags with special characters? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Searching by tags with special characters? (/showthread.php?tid=12633)



Searching by tags with special characters? - El Forum - 10-26-2008

[eluser]gRoberts[/eluser]
hi all,

I've implemented a simple tag search for a clients site which works fine unless you type in characters like "'@# etc.

I then urlencoded the tag being used as the parameter but its still not working properly.

How do people handle tags with special characters in?

Cheers

Gavin


Searching by tags with special characters? - El Forum - 10-26-2008

[eluser]Randy Casburn[/eluser]
Have you considered using htmlentities or htmlspecialchars instead? They provide a little better treatement of those characters since they are not concerned with how the browser implements URLs.

Randy


Searching by tags with special characters? - El Forum - 10-26-2008

[eluser]gRoberts[/eluser]
Unfortunately it doesn't work Sad

Here is a test I used to try each method:

Code:
htmlspecialchars: <a href="http://test.domain.com/tags/search/A dodgy tag¬!&quot;£$%^&amp;*()_+=-&lt;&gt;?/.">A dodgy tag¬!"£$%^&*()_+=-<>?/.</a>
htmlentities: <a href="http://test.domain.com/tags/search/A dodgy tag&not;!&quot;&pound;$%^&amp;*()_+=-&lt;&gt;?/.">A dodgy tag¬!"£$%^&*()_+=-<>?/.</a>
urlencode: <a href="http://test.domain.com/tags/search/A+dodgy+tag�!">?/.">A dodgy tag¬!"£$%^&*()_+=-<>?/.</a>

Urlencode seems the best method but CI won't accept it as a parameter (error 400)

I appreciate your help!

Thanks

Edit: The forum has removed some of the urlencoded chars....


Searching by tags with special characters? - El Forum - 10-26-2008

[eluser]Randy Casburn[/eluser]
I misunderstood -- I didn't realize you were translating your tag directly into URIs. I thought you were simply encoding variables.

My bad. Another option then is base64_encode().

Randy


Searching by tags with special characters? - El Forum - 10-26-2008

[eluser]gRoberts[/eluser]
That was my last option although defeats the point. I'll see what my client says although I doubt he would settle with base64 encoding Sad

Thank you again!