Author |
|
rcr
Joined: 30 Oct 2014 Posts: 6
|
Posted: Thu 30 Oct '14 22:35 Post subject: Cyrillic characters in URL string are not visible in $_GET |
|
|
Hello, everybody!
I've migrated from Apache 2.2 to Apache 2.4 few days ago. It is installed as a service on my Windows 7 developer machine and works in bundle with PHP 5.6.2.
Today I've discovered that GET parameters with Cyrillic characters in URL string are empty.
For example URL looks like this: site.com/search.php?q=%C8%E2%E0%ED%EE%E2
URL-encoded string here is Иванов (%C8%E2%E0%ED%EE%E2)
When I try to use this GET parameter in my PHP script - the variable $_GET['q'] is empty. If I put latin characters in this parameter - $_GET['q'] is taking the corresponding value.
Doesn't look like it's a problem of PHP as I think. Otherwise at least something should stay in the variable.
And also I would like to add that this was working absolutely normal on Apache 2.2.
I will appreciate any suggestions on my issue. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 05 Nov '14 11:16 Post subject: |
|
|
Did you try a print_r($_GET) ?
Did you install any filtering like mod security? |
|
Back to top |
|
rcr
Joined: 30 Oct 2014 Posts: 6
|
Posted: Sat 08 Nov '14 18:22 Post subject: |
|
|
Hi, Mr. Blond
Thanks for the reply. Yes, I've tried to print the GET array. Latin values are present in it, Cyrillic - empty. No additional mods were installed. Checked this also in httpd.conf. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Mon 10 Nov '14 12:14 Post subject: |
|
|
Well the url encode is not correct. it should be
%D0%98%D0%B2%D0%B0%D0%BD%D0%BE%D0%B2
With that my test script runs well
Code: |
header("Content-Type: text/html; charset=utf-8");
print_r($_GET);
echo urlencode($_GET['q']);
|
|
|
Back to top |
|
rcr
Joined: 30 Oct 2014 Posts: 6
|
Posted: Tue 11 Nov '14 10:56 Post subject: |
|
|
Didn't get why it's incorrect. There are 6 letters in Иванов and in your string %D0%98%D0%B2%D0%B0%D0%BD%D0%BE%D0%B2 encoded 12 characters.
Anyway this doesn't matter. No matter how much Cyrillic characters I'll put in $_GET['q'] via URL, it will be still empty. Could this be due to CP-1251 charset I'm using? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 11 Nov '14 11:37 Post subject: |
|
|
I use ANSI or UTF-8 as charset for the document (file) so save it.
Did you change anything in apache charset or PHP charset? |
|
Back to top |
|
rcr
Joined: 30 Oct 2014 Posts: 6
|
Posted: Wed 19 Nov '14 19:38 Post subject: |
|
|
In httpd.conf there's: AddDefaultCharset UTF-8
In php.ini all the charset lines are commented. |
|
Back to top |
|
rcr
Joined: 30 Oct 2014 Posts: 6
|
Posted: Wed 19 Nov '14 19:53 Post subject: |
|
|
There's one more interesting finding: when I type Иванов directly to the browsers' address string (for example: site.com/index.php?q=Иванов) in GET variable q I get: Р�ванов
If I convert this string from CP1251 to UTF-8 it would be almost normal: ��ванов |
|
Back to top |
|
rcr
Joined: 30 Oct 2014 Posts: 6
|
Posted: Wed 19 Nov '14 20:00 Post subject: |
|
|
James Blond wrote: | I use ANSI or UTF-8 as charset for the document (file) so save it.
Did you change anything in apache charset or PHP charset? |
Oh god, I am extremely sorry for all this stuff. The problem was in my function that filters all coming data from user. I can't even imagine that it was doing this cuz' it works just fine on Debian server. But when I've commented the line calling this function here, on local machine all the Cyrillic data appeared on it's place. I apologize for this mistake and taking your time |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Thu 20 Nov '14 11:24 Post subject: |
|
|
Make sure you set the correct meta type
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
in doubt you can force it on the form tag with accept-charset |
|
Back to top |
|