Skip to content

Commit a7bbc68

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: updated NEWS Fixed #69655: php -S changes MKCALENDAR request method to MKCOL
2 parents 1ec6ff0 + 7e97faa commit a7bbc68

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

sapi/cli/php_http_parser.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,20 @@ size_t php_http_parser_execute (php_http_parser *parser,
604604
goto error;
605605

606606
matcher = method_strings[parser->method];
607-
if (ch == ' ' && (matcher[index] == '\0' || parser->method == PHP_HTTP_NOT_IMPLEMENTED)) {
607+
if (ch == ' ') {
608+
if (parser->method != PHP_HTTP_NOT_IMPLEMENTED && matcher[index] != '\0') {
609+
parser->method = PHP_HTTP_NOT_IMPLEMENTED;
610+
}
608611
state = s_req_spaces_before_url;
609-
} else if (ch == matcher[index]) {
612+
} else if (parser->method == PHP_HTTP_NOT_IMPLEMENTED || ch == matcher[index]) {
610613
; /* nada */
611614
} else if (parser->method == PHP_HTTP_CONNECT) {
612615
if (index == 1 && ch == 'H') {
613616
parser->method = PHP_HTTP_CHECKOUT;
614617
} else if (index == 2 && ch == 'P') {
615618
parser->method = PHP_HTTP_COPY;
619+
} else {
620+
parser->method = PHP_HTTP_NOT_IMPLEMENTED;
616621
}
617622
} else if (parser->method == PHP_HTTP_MKCOL) {
618623
if (index == 1 && ch == 'O') {
@@ -623,6 +628,8 @@ size_t php_http_parser_execute (php_http_parser *parser,
623628
parser->method = PHP_HTTP_MSEARCH;
624629
} else if (index == 2 && ch == 'A') {
625630
parser->method = PHP_HTTP_MKACTIVITY;
631+
} else {
632+
parser->method = PHP_HTTP_NOT_IMPLEMENTED;
626633
}
627634
} else if (index == 1 && parser->method == PHP_HTTP_POST && ch == 'R') {
628635
parser->method = PHP_HTTP_PROPFIND; /* or HTTP_PROPPATCH */

sapi/cli/tests/bug69655.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #69655 (php -S changes MKCALENDAR request method to MKCOL)
3+
--INI--
4+
allow_url_fopen=1
5+
--SKIPIF--
6+
<?php
7+
include "skipif.inc";
8+
?>
9+
--FILE--
10+
<?php
11+
include "php_cli_server.inc";
12+
php_cli_server_start();
13+
foreach (['MKCALENDAR', 'MKCO', 'MKCOLL', 'M'] as $method) {
14+
$context = stream_context_create(['http' => ['method' => $method]]);
15+
// the following is supposed to emit a warning for unsupported methods
16+
file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context);
17+
}
18+
?>
19+
--EXPECTF--
20+
Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
21+
in %s on line %d
22+
23+
Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
24+
in %s on line %d
25+
26+
Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
27+
in %s on line %d
28+
29+
Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
30+
in %s on line %d

0 commit comments

Comments
 (0)