Commit graph

1244 commits

Author SHA1 Message Date
Pierrick Charron
d84b972658
Fixed CURLOPT_TLSAUTH_TYPE is not treated as a string option. 2022-06-17 19:51:58 -04:00
Christoph M. Becker
722e9b9fa5
Fix test for curl 7.83.0
libcurl 7.83.0 removed some trailing exclamation marks from error
messages[1]; we have to cater to that.

[1] <6968fb9d54>

(cherry picked from commit a4179e4c92)
2022-05-03 15:07:50 +02:00
Christoph M. Becker
5005445994
Mark curl tests using http2.golang.org as XFAIL
http2.golang.org/serverpush has been retired[1], so we need to come up
with an alternative.  Until then, we mark the relevant tests as XFAIL
(although bug77535.phpt passes, what might be an indication that the
test needs further revision).  To avoid waiting for the timeout, we
also unconditionally skip these tests for now.

[1] <https://github.com/golang/go/issues/49301>

Closes GH-7829.
2021-12-26 22:27:15 +01:00
Christophe Coevoet
096a01c905
[ci skip] Update the min curl version in the sync-constants.php script
PHP 8.0 bumped the min curl version to 7.29.0

Closes GH-7805.
2021-12-23 13:43:32 +01:00
Nikita Popov
db055fdb89 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid dangling pointer in curl header.str
2021-08-31 17:24:30 +02:00
Alexey Zamorov
8c292a2f9d Avoid dangling pointer in curl header.str
If buf_len is zero, this would leave behind a dangling pointer
to an already released header.str. Make sure this can't happen
by always overwriting the pointer.

Closes GH-7376.
2021-08-31 17:23:58 +02:00
Nikita Popov
416dd524f9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix curl_copy_handle() with CURLINFO_HEADER_OUT
2021-08-31 17:09:07 +02:00
Nikita Popov
30e791ed56 Fix curl_copy_handle() with CURLINFO_HEADER_OUT
The CURLOPT_DEBUGDATA will point to the old curl handle after
copying. Update it to point to the new handle.

We don't separately store whether CURLINFO_HEADER_OUT is enabled,
so I'm doing this unconditionally. It should be harmless if
CURLOPT_DEBUGFUNCTION is not used.
2021-08-31 17:06:41 +02:00
Nikita Popov
b63ea1047a Mark resource-like objects as non-comparable
As these hold on to some internal resource, there can't be two
"equal" objects with different identity. Make sure the lack of
public properties doesn't result in these being treated as always
equal.
2021-02-16 14:20:45 +01:00
Christoph M. Becker
afe17cc1b6 Adapt test case for libcurl 7.75.0+
libcurl 7.75.0 finally adds support for `gophers://`, i.e. gopher over
TLS.  The protocol is neither standardized, nor is the protocol
registered with IANA, but well, it is there and the test case should
cater to that.
2021-02-16 00:28:34 +01:00
Nikita Popov
0ec7bfaa43 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing derefs in CurlFile
2021-02-02 10:32:11 +01:00
Nikita Popov
54fa0a69f8 Add missing derefs in CurlFile
As pointed out on GH-6456.
2021-02-02 10:31:16 +01:00
Christoph M. Becker
c321896a37 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80595: Resetting POSTFIELDS to empty array breaks request
2021-01-18 11:01:01 +01:00
Christoph M. Becker
38ad37ad43 Fix #80595: Resetting POSTFIELDS to empty array breaks request
This is mainly to work around https://github.com/curl/curl/issues/6455,
but not building the mime structure for empty hashtables is a general
performance optimization, so we do not restrict it to affected cURL
versions (7.56.0 to 7.75.0).

The minor change to bug79033.phpt is unexpected, but should not matter
in practice.

Closes GH-6606.
2021-01-18 10:57:56 +01:00
Christoph M. Becker
bf244757ee Allow PHP_CURL_APIs to be imported by DLLs
Closes GH-6438.
2020-11-24 14:12:39 +01:00
Nikita Popov
06c4a501fd Fix curl_multi_getcontent() parameter name
While the function name starts with curl_multi_*, the function
actually accepts a CurlHandle. As such, it should also use just
$handle as the parameter name.

Closes GH-6435.
2020-11-19 10:17:17 +01:00
Nikita Popov
b4a2a9662b Retain reference to share handle from curl handle
Not keeping a reference will not result in use after free, because
curl protects against it, but it will result in a memory leak,
because curl_share_cleanup() will fail. We should make sure that
the share handle object stays alive as long as the curl handles
use it.
2020-11-11 11:56:03 +01:00
Christoph M. Becker
e076455026 Adapt test expectation to cURL 7.73.0
cURL 7.73.0 introduced support for the MQTT protocol, so we have to
adapt our expectations regarding the supported protocols.
2020-10-14 19:11:58 +02:00
Nikita Popov
d96219c185 Fixed bug #80121
The issue affected both CurlHandle and CurlMultiHandle. I'll have
to double check this for other resource->object conversions as well.
2020-10-01 17:05:23 +02:00
Máté Kocsis
f6024a9054
Improve parameter names in ext/curl
Closes GH-6155
2020-09-25 11:17:06 +02:00
Christoph M. Becker
d21137368f Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #77493: curl_basic_009 fails with newer curl versions
2020-09-23 10:48:35 +02:00
Christoph M. Becker
d30ec2cd85 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77493: curl_basic_009 fails with newer curl versions
2020-09-23 10:44:06 +02:00
Christoph M. Becker
9439d65f0d Fix #77493: curl_basic_009 fails with newer curl versions
libcurl 7.62.0 introduced a maximum protocol length of 8, so this test
case failed with `CURLE_URL_MALFORMAT`.  While this is lifted to 40 as
of libcurl 7.65.0, and this test case has already been fixed with
commit e27301c[1], we restore the original intention to check for a
`CURLE_UNSUPPORTED_PROTOCOL ` error.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=e27301c7b37f6a1643a0dc1966919bd62a32bc74>
2020-09-23 10:42:48 +02:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Sara Golemon
bfa8e42a55
Use ephemeral ports during curl tests with dev server 2020-09-17 14:44:12 +00:00
Nikita Popov
7e339a335e Make null byte error a ValueError
Currently we treat paths with null bytes as a TypeError, which is
incorrect, and rather inconsistent, as we treat empty paths as
ValueError. We do this because the error is generated by zpp and
it's easier to always throw TypeError there.

This changes the zpp implementation to throw a TypeError only if
the type is actually wrong and throw ValueError for null bytes.
The error message is also split accordingly, to be more precise.

Closes GH-6094.
2020-09-08 15:23:23 +02:00
Nikita Popov
85b5dc4711 Private/public split curl header
To allow exporting the php_curl.h header containing curl class
entries, split off a separate curl_private.h header with all the
implementation details.

We may move or expose additional APIs in php_curl.h on an as-needed
basis.
2020-09-07 11:12:41 +02:00
Nikita Popov
d1ac7e3ab1 Remove some unnecessary HAVE_EXTNAME guards
A recurring pattern in old extension: Putting the whole source
code behind HAVE_EXTNAME. This is pointless, as the code is only
compiled if the extension is enabled.

This removes a couple of them, but not all.
2020-09-07 11:05:07 +02:00
Máté Kocsis
517c9938af
Promote warnings to exceptions in ext/curl
Closes GH-5963
2020-08-14 17:40:35 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Nikita Popov
632766a561 Disallow separation in a number of callbacks
All of these clearly do not need separation support.
2020-07-07 09:02:24 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Fabien Villepinte
0c6d06ecfa Replace EXPECTF when possible
Closes GH-5779
2020-06-29 21:31:44 +02:00
Nikita Popov
6e1990dea6 Don't accept objects instead of arrays in curl
This properly addresses the issue from bug #79741. Silently
interpreting objects as mangled property tables is almost
always a bad idea.

Closes GH-5773.
2020-06-29 15:56:22 +02:00
Nikita Popov
75a04eac97 Make exit() unwind properly
exit() is now internally implemented by throwing an exception,
performing a normal stack unwind and a clean shutdown. This ensures
that no persistent resource leaks occur.

The exception is internal, cannot be caught and does not result in
the execution of finally blocks. This may be relaxed in the future.

Closes GH-5768.
2020-06-29 15:50:12 +02:00
Nikita Popov
f930978b70 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79741
2020-06-26 12:29:43 +02:00
Nikita Popov
978cdb736a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79741
2020-06-26 12:29:23 +02:00
Nikita Popov
43cd3f6814 Fixed bug #79741 2020-06-26 12:28:39 +02:00
Máté Kocsis
b5c7a83dca
Remove unnecessary PHPDoc-alike blocks from tests
Closes GH-5759
2020-06-24 13:13:44 +02:00
Nikita Popov
653e4ea1c5 Add flag to forbid dynamic property creation on internal classes
While performing resource -> object migrations, we're adding
defensive classes that are final, non-serializable and non-clonable
(unless they are, of course). This path adds a ZEND_ACC_NO_DYNAMIC_PROPERTIES
flag, that also forbids the creation of dynamic properties on these objects.
This is a subset of #3931 and targeted at internal usage only
(though may be extended to userland at some point in the future).

It's already possible to achieve this (what the removed
WeakRef/WeakMap code does), but there's some caveats: First, this
simple approach is only possible if the class has no declared
properties, otherwise it's necessary to special-case those
properties. Second, it's easy to make it overly strict, e.g. by
forbidding isset($obj->prop) as well. And finally, it requires a
lot of boilerplate code for each class.

Closes GH-5572.
2020-06-24 11:52:36 +02:00
Nikita Popov
c008fde961 Skip two curl tests under asan
These tests leak with the curl version on ubuntu 20.04. This should
be fixed when we switch exit to use an exception.
2020-06-24 10:13:25 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Nikita Popov
26171c3690 Also allow casting CurlMultiHandles 2020-06-22 15:09:22 +02:00
Nikita Popov
1c4463c77a Allow casting CurlHandle to int
(int) $curlHandle will return spl_object_id($curlHandle). This
makes curl handle objects backwards compatible with code using
(int) $curlHandle to obtain a resource ID.

Closes GH-5743.
2020-06-19 23:05:47 +02:00
Máté Kocsis
ed6fbf9174
Fix UNKNOWN default values in ext/curl
Closes GH-5734
2020-06-18 13:26:32 +02:00
Máté Kocsis
a43fd3bbef
Remove the deprecated parameter of curl_version() 2020-06-18 13:26:32 +02:00