Commit Graph

47 Commits

Author SHA1 Message Date
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:31:31 +02:00
Peter Kokot
17ccbeec32 Trim trailing whitespace in *.phpt 2018-10-14 19:44:14 +02:00
Stanislav Malyshev
ab9f9b5d3b Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:26:55 -08:00
Stanislav Malyshev
a6f7760d57 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:26:50 -08:00
Stanislav Malyshev
dde7a05978 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fix bug #75981: prevent reading beyond buffer start
2018-02-26 22:26:26 -08:00
Stanislav Malyshev
523f230c83 Fix bug #75981: prevent reading beyond buffer start 2018-02-26 22:25:51 -08:00
Nikita Popov
31d9287d2b Merge branch 'PHP-7.1' into PHP-7.2 2017-11-17 23:22:07 +01:00
Nikita Popov
092d0922ea Merge branch 'PHP-7.0' into PHP-7.1 2017-11-17 23:21:48 +01:00
Nikita Popov
0e097f2c96 Fixed bug #75535
The sizeof()s for Content-Length and Transfer-Encoding were missing
the trailing ":". Apart from being generally wrong, this no longer
verified that the header actually contains a colon, leading to the
null http_header_value being used.

Additionally, in the interest of being defensive, also make sure
that http_header_value is non-null by setting it to the end of
the header line (effectively an empty string) if there is no colon.
If the following conditions are correct, this value is not going
to be used though.
2017-11-17 23:18:05 +01:00
Nikita Popov
5eeb414770 Write $http_response_header to local var at end
Rather than trying to modify it mid-request. The protection against
tampering that was used (addref) violates COW because an rc>1 array
is being modified.

Test bug69337.phpt changed because it was testing tampering with
$http_response_header while the HTTP request is being executed.
This simply no longer matters, so behavior is the same as if no
tampering occurred.
2017-01-13 23:27:07 +01:00
Nikita Popov
49c48e3f3a Merge branch 'PHP-7.1' 2017-01-07 23:56:00 +01:00
Nikita Popov
d48ff0f3f5 Merge branch 'PHP-7.0' into PHP-7.1 2017-01-07 23:55:48 +01:00
Rowan Collins
5146d9f8ac http_fopen_wrapper.c - Handle HTTP headers with varying white space
The stream handler assumed all HTTP headers contained exactly one space,
but the standard says there may be zero or more. Should fix Bug #47021,
and any other edge cases caused by a web server sending unusual spacing,
e.g. the MIME type discovered from Content-Type: can no longer contain
leading whitespace.

We strip trailing whitespace from the headers added into
$http_response_header as well.
2017-01-07 23:54:57 +01:00
Pedro Magalhães
9c5af4e4cb Remove the b prefix from literals on unrelated tests 2016-11-20 21:11:53 +01:00
Rowan Collins
66ac73bee8 Simplify ext/standard/tests/http/bug73297.phpt 2016-11-17 11:51:53 +01:00
Rowan Collins
4683377dfa Add failing test for bug#73297 2016-11-17 11:51:53 +01:00
Rowan Collins
773bc082ca Simplify ext/standard/tests/http/bug73297.phpt 2016-11-17 11:51:29 +01:00
Rowan Collins
12c4ff9b87 Add failing test for bug#73297 2016-11-17 11:51:29 +01:00
Rowan Collins
8b54b3654d Simplify ext/standard/tests/http/bug73297.phpt 2016-11-17 11:50:36 +01:00
Rowan Collins
5a882990a6 Add failing test for bug#73297 2016-11-17 11:50:36 +01:00
Rowan Collins
eba5e276c7 Simplify ext/standard/tests/http/bug73297.phpt 2016-11-17 11:04:57 +01:00
Rowan Collins
6122526cea Add failing test for bug#73297 2016-11-17 11:04:56 +01:00
Nikita Popov
8ba694ebbd Add $http_response_header tests
Looks like we didn't have a single test for this functionality :/
2016-05-06 12:37:21 +02:00
Bob Weinand
3d05785054 Merge remote-tracking branch 'origin/PHP-5.6' 2015-09-04 16:35:15 +02:00
Niklas Keller
4b1dff6f43 Fix #70361: HTTP stream wrapper doesn't close keep-alive connections 2015-09-04 16:29:35 +02:00
Stanislav Malyshev
b3709bfc52 Merge branch 'PHP-5.6'
* PHP-5.6: (27 commits)
  fix non-standard C
  update NEWS
  5.4.41 next
  fix CVE num
  update NEWS
  Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode)
  fix test
  fix type in fix for #69085
  fix memory leak & add test
  Fix tests
  fix CVE num
  Fix bug #69337 (php_stream_url_wrap_http_ex() type-confusion vulnerability)
  Fix test
  Additional fix for bug #69324
  More fixes for bug #69152
  Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
  Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar)
  Fixed bug #69316 (Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER)
  Fix bug #68486 and bug #69218 (segfault in apache2handler with apache 2.4)
  Fix bug #68819 (Fileinfo on specific file causes spurious OOM and/or segfault)
  ...

Conflicts:
	Zend/zend_exceptions.c
	ext/curl/interface.c
	ext/dom/document.c
	ext/fileinfo/libmagic/softmagic.c
	ext/gd/gd.c
	ext/hash/hash.c
	ext/pgsql/pgsql.c
	ext/phar/phar.c
	ext/phar/phar_internal.h
	ext/standard/http_fopen_wrapper.c
	ext/standard/link.c
	ext/standard/streamsfuncs.c
	ext/xmlwriter/php_xmlwriter.c
	ext/zlib/zlib.c
2015-04-14 01:28:06 -07:00
Stanislav Malyshev
5776fceb16 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: (27 commits)
  fix non-standard C
  update NEWS
  5.4.41 next
  fix CVE num
  update NEWS
  Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode)
  fix test
  fix type in fix for #69085
  fix memory leak & add test
  Fix tests
  fix CVE num
  Fix bug #69337 (php_stream_url_wrap_http_ex() type-confusion vulnerability)
  Fix test
  Additional fix for bug #69324
  More fixes for bug #69152
  Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
  Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar)
  Fixed bug #69316 (Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER)
  Fix bug #68486 and bug #69218 (segfault in apache2handler with apache 2.4)
  Fix bug #68819 (Fileinfo on specific file causes spurious OOM and/or segfault)
  ...

Conflicts:
	ext/standard/http_fopen_wrapper.c
2015-04-14 01:05:01 -07:00
Stanislav Malyshev
45facd15fb fix memory leak & add test 2015-04-12 22:38:34 -07:00
Dmitry Stogov
d37820ff5b Introduced get_resources() function.
It may be used for debugging and testing to identify resource leaks.
Changed ext/standard/tests/http/bug60570.phpt to use this function instead of unsafe attempt to catch resource leaks using get_memory_usage()
2014-08-20 18:29:44 +04:00
Adam Harvey
84f339546a Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Follow 308 Permanent Redirect responses.
2014-06-12 18:17:18 -07:00
Adam Harvey
b51f82f260 Follow 308 Permanent Redirect responses.
Fixes bug #67430 (http:// wrapper doesn't follow 308 redirects).
2014-06-12 18:12:53 -07:00
Michael Wallner
d29a01de3f Merge branch 'PHP-5.5'
* PHP-5.5:
  Fixed bug #61548

Conflicts:
	ext/standard/http_fopen_wrapper.c
2013-10-01 11:11:48 +02:00
Michael Wallner
18b04b480e Fixed bug #61548 2013-10-01 11:07:55 +02:00
Adam Harvey
8983a38d51 Request non-keep-alive connections by default in HTTP 1.1 requests.
As noted in FR #65634, at present we don't send a Connection request header
when the protocol version is set to 1.1, which means that RFC-compliant Web
servers should respond with keep-alive connections. Since there's no way of
reusing the HTTP connection at present, this simply means that PHP will appear
to hang until the remote server hits its connection timeout, which may be quite
some time.

This commit sends a "Connection: close" header by default when HTTP 1.1 (or
later) is requested by the user via the context options. It can be overridden
by specifying a Connection header in the context options. It isn't possible to
disable sending of the Connection header, but given "Connection: keep-alive" is
the same as the default HTTP 1.1 behaviour, I don't see this as a significant
issue — users who want to opt in for that still can.

As a note, although I've removed an efree(protocol_version), this doesn't
result in a memory leak: protocol_version is freed in the out: block at the end
of the function anyway, and there are no returns between the removed efree()
and the later call. Yes, I ran the tests with valgrind to check that. ☺

Implements FR #65634 (HTTP wrapper is very slow with protocol_version 1.1).
2013-09-11 14:11:29 -07:00
Gustavo André dos Santos Lopes
d1be77edfb - Fixed bug #60570 (http wrapper leaks context resource if request fails/is
redirected).
2011-12-21 15:44:58 +00:00
Gustavo André dos Santos Lopes
f24f2b4df6 - Fixed bug #60570 (http wrapper leaks context resource if request fails/is
redirected).
2011-12-21 15:44:58 +00:00
Gustavo André dos Santos Lopes
a56c0bd0d8 - Fixed tests in ext/standard/tests/http by adding the INI setting value
allow_url_fopen=1
- Converted test file from dos line endings to unix line endings.
2011-11-14 01:12:23 +00:00
Gustavo André dos Santos Lopes
8b5045fdcd - Fixed tests in ext/standard/tests/http by adding the INI setting value
allow_url_fopen=1
- Converted test file from dos line endings to unix line endings.
2011-11-14 01:12:23 +00:00
Gustavo André dos Santos Lopes
5c09767d4b - Fixed bug #53198 (changing INI setting "from" with ini_set did not have any
effect)
#Made "from" a proper INI setting and bound it to a global variable.
#Previously, it was simply read from the hash table with the parsed ini file
#by using cfg_get_string (I wonder why this mechanism still exists...)
2010-10-29 15:29:15 +00:00
Antony Dovgal
bb8d9fa656 cosmetic fix 2009-08-04 09:27:15 +00:00
Jani Taskinen
a845f681bb - Fix title 2009-08-04 02:55:24 +00:00
Felipe Pena
8ad9bd1930 - Fixed tests 2009-08-01 15:46:50 +00:00
Jani Taskinen
be6338014a - Fixed bug #43510 (stream_get_meta_data() does not return same mode as used in fopen) 2009-08-01 03:17:31 +00:00
Jani Taskinen
c0aab038ba Fixed bug #48929 (Double \r\n after HTTP headers when "header" context option is an array) 2009-07-20 10:54:37 +00:00
Arnaud Le Blanc
23a25db653 MFH: New test 2009-05-28 13:22:28 +00:00
Arnaud Le Blanc
8a8e036175 MFH: Test for #38802 2009-05-16 20:45:28 +00:00
Arnaud Le Blanc
ac57b7078b MFH: Minimal HTTP server to test HTTP stream wrapper 2009-05-16 20:44:05 +00:00