logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Cyrillic characters in URL string are not visible in $_GET
Author
rcr



Joined: 30 Oct 2014
Posts: 6

PostPosted: Thu 30 Oct '14 22:35    Post subject: Cyrillic characters in URL string are not visible in $_GET Reply with quote

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

PostPosted: Wed 05 Nov '14 11:16    Post subject: Reply with quote

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

PostPosted: Sat 08 Nov '14 18:22    Post subject: Reply with quote

Hi, Mr. Blond Wink

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

PostPosted: Mon 10 Nov '14 12:14    Post subject: Reply with quote

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

PostPosted: Tue 11 Nov '14 10:56    Post subject: Reply with quote

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

PostPosted: Tue 11 Nov '14 11:37    Post subject: Reply with quote

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

PostPosted: Wed 19 Nov '14 19:38    Post subject: Reply with quote

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

PostPosted: Wed 19 Nov '14 19:53    Post subject: Reply with quote

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

PostPosted: Wed 19 Nov '14 20:00    Post subject: Reply with quote

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 Sad Neutral
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 20 Nov '14 11:24    Post subject: Reply with quote

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


Reply to topic   Topic: Cyrillic characters in URL string are not visible in $_GET View previous topic :: View next topic
Post new topic   Forum Index -> Apache