@@ -1103,15 +1103,6 @@ static void init_request_info(void)
11031103 script_path_translated = __unixify (script_path_translated , 0 , NULL , 1 , 0 );
11041104#endif
11051105
1106- // If DocumentRoot contains cyrillic characters and PHP is invoked with SetHandler (not applicable to ProxyPassMatch),
1107- // then the cyrillic characters are urlencoded by apache, and we need to decode them, for example with
1108- // DocumentRoot /home/hans/web/cyrillicрф.ratma.net/public_html
1109- // env_script_filename contains /home/hans/web/cyrillic%D1%80%D1%84.ratma.net/public_html/index.php.
1110- // and we must decode it to /home/hans/web/cyrillicрф.ratma.net/public_html/index.php.
1111- if (apache_was_here && strchr (script_path_translated , '%' ))
1112- {
1113- php_raw_url_decode (script_path_translated , strlen (script_path_translated ));
1114- }
11151106
11161107 /*
11171108 * if the file doesn't exist, try to extract PATH_INFO out
@@ -1128,8 +1119,21 @@ static void init_request_info(void)
11281119 char * ptr ;
11291120
11301121 if (pt ) {
1122+ // If DocumentRoot contains cyrillic characters and PHP is invoked with SetHandler (not applicable to ProxyPassMatch),
1123+ // then the cyrillic characters are urlencoded by apache, and we need to decode them, for example with
1124+ // DocumentRoot /home/hans/web/cyrillicрф.ratma.net/public_html
1125+ // env_script_filename contains /home/hans/web/cyrillic%D1%80%D1%84.ratma.net/public_html/index.php.
1126+ // and we must decode it to /home/hans/web/cyrillicрф.ratma.net/public_html/index.php.
1127+ bool firstrun_apache_cyrillic_encoding = apache_was_here && memchr (pt , '%' , len );
1128+ if (firstrun_apache_cyrillic_encoding ) {
1129+ len = php_raw_url_decode (pt , len );
1130+ }
11311131 while ((ptr = strrchr (pt , '/' )) || (ptr = strrchr (pt , '\\' ))) {
1132- * ptr = 0 ;
1132+ if (firstrun_apache_cyrillic_encoding ) {
1133+ firstrun_apache_cyrillic_encoding = false;
1134+ } else {
1135+ * ptr = 0 ;
1136+ }
11331137 if (stat (pt , & st ) == 0 && S_ISREG (st .st_mode )) {
11341138 /*
11351139 * okay, we found the base script!
0 commit comments