Skip to content

Commit e48ceb0

Browse files
committed
Fix GH-17643: FPM with httpd ProxyPass encoded PATH_INFO env
Closes GH-17644
1 parent fd5d6ad commit e48ceb0

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fixed bug GH-17718 (Calling static methods on an interface that has
1515
`__callStatic` is allowed). (timwolla)
1616

17+
- FPM:
18+
. Fixed bug GH-17643 (FPM with httpd ProxyPass encoded PATH_INFO env).
19+
(Jakub Zelenka)
20+
1721
- LDAP:
1822
. Fixed bug GH-17704 (ldap_search fails when $attributes contains a
1923
non-packed array with numerical keys). (nielsdos, 7u83)

sapi/fpm/fpm/fpm_main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,7 @@ static void init_request_info(void)
11531153
}
11541154

11551155
if (tflag) {
1156+
char *decoded_path_info = NULL;
11561157
if (orig_path_info) {
11571158
char old;
11581159

@@ -1174,7 +1175,6 @@ static void init_request_info(void)
11741175
* As we can extract PATH_INFO from PATH_TRANSLATED
11751176
* it is probably also in SCRIPT_NAME and need to be removed
11761177
*/
1177-
char *decoded_path_info = NULL;
11781178
size_t decoded_path_info_len = 0;
11791179
if (strchr(path_info, '%')) {
11801180
decoded_path_info = estrdup(path_info);
@@ -1197,11 +1197,13 @@ static void init_request_info(void)
11971197
env_script_name[env_script_file_info_start] = 0;
11981198
SG(request_info).request_uri = FCGI_PUTENV(request, "SCRIPT_NAME", env_script_name);
11991199
}
1200-
if (decoded_path_info) {
1201-
efree(decoded_path_info);
1202-
}
12031200
}
1204-
env_path_info = FCGI_PUTENV(request, "PATH_INFO", path_info);
1201+
if (decoded_path_info) {
1202+
env_path_info = FCGI_PUTENV(request, "PATH_INFO", decoded_path_info);
1203+
efree(decoded_path_info);
1204+
} else {
1205+
env_path_info = FCGI_PUTENV(request, "PATH_INFO", path_info);
1206+
}
12051207
}
12061208
if (!orig_script_filename ||
12071209
strcmp(orig_script_filename, pt) != 0) {

sapi/fpm/tests/fcgi-env-pif-apache-pp-sn-strip-encoded-plus.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $tester
3939
scriptFilename: "proxy:fcgi://" . $tester->getAddr() . $sourceFilePath . '/1%20+2',
4040
scriptName: $scriptName . '/1 +2'
4141
)
42-
->expectBody([$scriptName, $scriptName . '/1 +2', $sourceFilePath, '/1%20+2', $scriptName . '/1%20+2']);
42+
->expectBody([$scriptName, $scriptName . '/1 +2', $sourceFilePath, '/1 +2', $scriptName . '/1 +2']);
4343
$tester->terminate();
4444
$tester->close();
4545

sapi/fpm/tests/fcgi-env-pif-apache-pp-sn-strip-encoded.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $tester
3939
scriptFilename: "proxy:fcgi://" . $tester->getAddr() . $sourceFilePath . '/1%202',
4040
scriptName: $scriptName . '/1 2'
4141
)
42-
->expectBody([$scriptName, $scriptName . '/1 2', $sourceFilePath, '/1%202', $scriptName . '/1%202']);
42+
->expectBody([$scriptName, $scriptName . '/1 2', $sourceFilePath, '/1 2', $scriptName . '/1 2']);
4343
$tester->terminate();
4444
$tester->close();
4545

0 commit comments

Comments
 (0)