Skip to content

Commit

Permalink
Fix #68291: 404 on urls with '+'
Browse files Browse the repository at this point in the history
URI paths have to be treated according to RFC 3986 by the CLI web server, not
as application/x-www-form-urlencoded.
  • Loading branch information
cmb69 committed Sep 5, 2015
1 parent f9ece83 commit fd94c92
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */
#include "ext/standard/php_smart_str.h"
#include "ext/standard/html.h"
#include "ext/standard/url.h" /* for php_url_decode() */
#include "ext/standard/url.h" /* for php_raw_url_decode() */
#include "ext/standard/php_string.h" /* for php_dirname() */
#include "php_network.h"

Expand Down Expand Up @@ -1577,7 +1577,7 @@ static void normalize_vpath(char **retval, size_t *retval_len, const char *vpath
return;
}

decoded_vpath_end = decoded_vpath + php_url_decode(decoded_vpath, vpath_len);
decoded_vpath_end = decoded_vpath + php_raw_url_decode(decoded_vpath, vpath_len);

#ifdef PHP_WIN32
{
Expand Down
21 changes: 21 additions & 0 deletions sapi/cli/tests/bug68291.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #68291 (404 on urls with '+')
--INI--
allow_url_fopen=1
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
file_put_contents(__DIR__ . '/bug68291+test.html', 'Found');
php_cli_server_start(NULL, NULL);
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/bug68291+test.html');
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/bug68291+test.html');
?>
--EXPECT--
Found

0 comments on commit fd94c92

Please sign in to comment.