Created
January 23, 2014 13:50
-
-
Save haegrr/8578699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git main/php.h main/php.h | |
| index c2d0d93..d9be0fa 100644 | |
| --- main/php.h | |
| +++ main/php.h | |
| @@ -245,6 +245,8 @@ END_EXTERN_C() | |
| /* macros */ | |
| #define STR_PRINT(str) ((str)?(str):"") | |
| +#define _STRINGIFY(x) #x | |
| +#define STRINGIFY(x) _STRINGIFY(x) | |
| #ifndef MAXPATHLEN | |
| # ifdef PATH_MAX | |
| diff --git sapi/cli/php_cli_server.c sapi/cli/php_cli_server.c | |
| index 2c68fa1..53b4423 100644 | |
| --- sapi/cli/php_cli_server.c | |
| +++ sapi/cli/php_cli_server.c | |
| @@ -1447,7 +1447,7 @@ static void php_cli_server_request_dtor(php_cli_server_request *req) /* {{{ */ | |
| static void php_cli_server_request_translate_vpath(php_cli_server_request *request, const char *document_root, size_t document_root_len) /* {{{ */ | |
| { | |
| struct stat sb; | |
| - static const char *index_files[] = { "index.php", "index.html", NULL }; | |
| + static const char *index_files[] = { "index.php" STRINGIFY(PHP_MAJOR_VERSION), "index.php", "index.html", NULL }; | |
| char *buf = safe_pemalloc(1, request->vpath_len, 1 + document_root_len + 1 + sizeof("index.html"), 1); | |
| char *p = buf, *prev_path = NULL, *q, *vpath; | |
| size_t prev_path_len = 0; | |
| @@ -2148,8 +2148,13 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client | |
| { | |
| int is_static_file = 0; | |
| + size_t versioned_ext_len = 3 + strlen(STRINGIFY(PHP_MAJOR_VERSION)); | |
| + | |
| SG(server_context) = client; | |
| - if (client->request.ext_len != 3 || memcmp(client->request.ext, "php", 3) || !client->request.path_translated) { | |
| + if (((client->request.ext_len != 3 || memcmp(client->request.ext, "php", 3)) | |
| + && (client->request.ext_len != versioned_ext_len | |
| + || memcmp(client->request.ext, "php" STRINGIFY(PHP_MAJOR_VERSION), versioned_ext_len))) | |
| + || !client->request.path_translated) { | |
| is_static_file = 1; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment