• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with urldecode(), maybe encoding problem

#1
[eluser]vadimyer[/eluser]
Hi there.

First, I have enabled query strings and a search function. Search string passes to the "searchterm" variable and when I pass it through the form, it works fine and looks like:

http://local/home/search/?searchterm=testtesttest

Okay, now when I input some cyrillic string in a search form, it works fine as well, the URI would be for example:

http://local/home/search/?searchterm=привет (in chrome) or
http://local/home/search/?searchterm=������ (in IE, Opera etc.)

Two above cases work fine, BUT WHEN I enter the CYRILLIC search string directly from the address bar (for example, in Opera or IE) it doesn't wanna search anything. $_GET['searchterm'] is empty, and as for QUERY_STRING, it is something like searchterm=������ (all data from profiler).

I urldecode my string from the controller, but it somehow doesn't work. I also tried some iconv() cases, from what I've googled, but they also didn't work.

So the question is why all other browsers except chrome doesn't retrieve CYRILLIC $_GET variable from the address bar if it was entered from there? Passing through the form everything works fine.

Thanks in advance, guys. Hope for you help.

#2
[eluser]vadimyer[/eluser]
UPD.

wow, I see that string "% ED % E7 % F0 ..." (without spaces) here was somehow replaced by rombs with question mark.

#3
[eluser]adityamenon[/eluser]
::unhelpful reply alert::

I think it's because the browsers have some inbuilt mechanism to deal with uncommon GET variables, when left to themselves. But when entering from the address bar, the browser is not having a chance to pre-process the stuff... maybe it's stopping the special characters for security. If you find out a way out of this, please post it here. I was going to post an answer saying "use htmlentities, then send the var via GET, then use html_entity_decode to get your value" - but after I really read your question, I understood that you're talking about the address bar...

#4
[eluser]vadimyer[/eluser]
[quote author="adityamenon" date="1310254570"]::unhelpful reply alert::

I think it's because the browsers have some inbuilt mechanism to deal with uncommon GET variables, when left to themselves. But when entering from the address bar, the browser is not having a chance to pre-process the stuff... maybe it's stopping the special characters for security. If you find out a way out of this, please post it here. I was going to post an answer saying "use htmlentities, then send the var via GET, then use html_entity_decode to get your value" - but after I really read your question, I understood that you're talking about the address bar...[/quote]

Hey. The problem was not solved yet, but I finally found out that the address bar from IE, Opera, FF decodes cyrillic symbols in CP1251 (windows-1251) encoding, while Chrome's address bar works in UTF-8. So, for example, when in UTF-8 the decoded string would be:

#5
[eluser]adityamenon[/eluser]
Ah... so my hunch was right. I really don't see a way around this. Just force every visitor coming to that particular page to download Chrome. Warn them that the website will not function as expected in any other browser. This is an unhappy solution.

#6
[eluser]vadimyer[/eluser]
Haha, no that's not really necessary Smile I think that 1 user of 100 or even 1000 would try to enter the search string right from the address bar. The problem is very small in fact, my search engine would just find nothing if some clever user will try to change search string from IE's or Opera's address bar Smile

#7
[eluser]vadimyer[/eluser]
Those browsers finally don't support "bar-search" like Chrome, so for users who use them, it wouldn't be necessary. They will just use front-end or some plugins that would be created for different browsers.

#8
[eluser]adityamenon[/eluser]
Quote:Haha, no that’s not really necessary
Indeed. It would be worthy to mention the issue in your "No results found" page, however. Especially, to those clever users that you can detect/suspect have arrived directly instead of via the search form... (javascript or session variable)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.