Commit graph

1480 commits

Author SHA1 Message Date
David CARLIER
b233c55b12
ext/curl: curl_getinfo, curl_multi_get_handles and curl_multi_setopt array optimisations. (#18389)
mainly change to packed arrays.
2025-04-21 17:13:57 +01:00
Ayesh Karunaratne
7fd51535a4 ext/curl: add tests for CURLOPT_INFILESIZE(_LARGE) 2025-04-09 14:12:14 +07:00
Oskar Stark
195467f014 [ext-curl] Add \CURLOPT_INFILESIZE_LARGE
This is my first PR on this repository and is based on:
* https://github.com/symfony/symfony/pull/59654/files#r1935358570

So feel free to close it :-)
2025-04-09 14:12:14 +07:00
Niels Dossche
c10afa9643
Simplify curl gc handlers (#18227)
Since these objects are final and have no dynamic properties, we don't
have to build a property table.
2025-04-02 17:33:02 +02:00
Gina Peter Banyard
d8e7f362dd
ext/curl: Various minor clean-up refactorings (#18042) 2025-03-15 18:14:33 +00:00
Ayesh Karunaratne
cab120f521
ext/curl: update Caddyfile basicauth to basic_auth
In Caddy 2.8, `basicauth` was renamed to `basic_auth`.

This also applies `caddy fmt Caddyfile --overwrite` changes.
2025-03-05 16:30:59 +07:00
Ayesh Karunaratne
8e39e9c815
ext/curl: update sync-constants.php consts-ignore list 2025-03-04 21:21:00 +07:00
Christoph M. Becker
9998337539
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
2025-02-21 12:50:21 +01:00
Christoph M. Becker
07a3719bc7
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
2025-02-21 12:49:08 +01:00
Christoph M. Becker
29c39a3d91
Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
We must define `CURL_STATICLIB` only when building against a static
libcurl.  The detection relies on our usual naming conventions, what
should be revised in the future (possibly using pkg-config, or
switching to CMake).

Closes GH-17857.
2025-02-21 12:46:20 +01:00
Ayesh Karunaratne
6a319928c4
ext/curl: Add CURLINFO_{USED_PROXY,HTTPAUTH_USED,PROXYAUTH_USED}
Adds support for `curl_getinfo()` info keys and additional array keys:

 - [`CURLINFO_USED_PROXY`](https://curl.se/libcurl/c/CURLINFO_USED_PROXY.html) - `libcurl` >= 8.7.9 -
   Zero if no proxy was used in the previous transfer or a non-zero value if a proxy was used.
 - [`CURLINFO_HTTPAUTH_USED`](https://github.com/curl/curl/blob/curl-8_12_0/docs/libcurl/opts/CURLINFO_HTTPAUTH_USED.md) - `libcurl` >= 8.7.9 -
   Bitmask indicating the authentication method that was used in the previous HTTP request.
 - [`CURLINFO_PROXYAUTH_USED`](https://github.com/curl/curl/blob/curl-8_12_0/docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md) - `libcurl` >= 8.12.0 -
   Bitmask indicating the authentication method that was used in the previous request done over an HTTP proxy.

```php
curl_getinfo($ch);
```
```php
[
	// ...
	"used_proxy" => 0,
	"httpauth_used" => 0,
	"proxyauth_used" => 0,
]
```

This also updates the `Caddyfile` for curl tests to add a new route
that supports HTTP basic auth.
2025-02-17 17:37:27 +07:00
Ilija Tovilo
f25eb7f18d
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix curl protocols test expectation
2025-02-14 14:38:58 +01:00
Ilija Tovilo
5b87faaaa7
Fix curl protocols test expectation
Closes GH-17803
2025-02-14 14:38:34 +01:00
Christoph M. Becker
dd66bb9817
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix curl_basic_022.phpt for libcurl 8.12.0
2025-02-05 19:24:37 +01:00
Christoph M. Becker
e9d4fc184d
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix curl_basic_022.phpt for libcurl 8.12.0
2025-02-05 19:23:52 +01:00
Christoph M. Becker
47931a426e
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix curl_basic_022.phpt for libcurl 8.12.0
2025-02-05 19:22:51 +01:00
Christoph M. Becker
856866ef24
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix curl_basic_022.phpt for libcurl 8.12.0
2025-02-05 19:22:20 +01:00
Christoph M. Becker
36d46a4732
Fix curl_basic_022.phpt for libcurl 8.12.0
Due to a deliberate change in libcurl, the expiration is now capped to
at most 400 days.  We could solve this by choosing another date roughly
a year in the future, but would need to update the test next year.
This would be especially annoying for security branches.

Another option would be to actually parse the cookie list lines, but
that might not be worth the trouble.  Instead we just ignore the exact
timestamp created by libcurl.

[1] <https://github.com/curl/curl/pull/15937>

Closes GH-17709.
2025-02-05 19:20:47 +01:00
Christoph M. Becker
06c41ec6c5
Run curl_setopt_ssl.phpt on Windows, too (GH-16086)
The whole point of using `proc_open()` to execute `openssl s_client` is
that we can terminate the process when we're done.  However, when going
through the shell on Windows, we get a handle to the shell process, and
if we terminate that, the grandchild will stay open.  Since the pipes
of the grandchild will stay open, the PHP process will not terminate
either, so the test stalls.

We solve this by simply bypassing the shell.
2025-01-28 01:14:10 +01:00
Ayesh Karunaratne
88fc34aa7a
ext/curl: update CURLOPT_PREREQFUNCTION test to validate CURLE_ABORTED_BY_CALLBACK return value
Updates the `CURLOPT_PREREQFUNCTION` test to validate that
connections failed when the PREREQFUNC returns abort returns
CURLE_ABORTED_BY_CALLBACK as the error number.

Previously, it only checked against a hardcoded value. Now, it
checks against the `CURLE_ABORTED_BY_CALLBACK` constant as well.
2025-01-19 11:20:41 +07:00
Eric Norris
d20880ce3b
RFC: Add CurlSharePersistentHandle objects (#16937)
see https://wiki.php.net/rfc/curl_share_persistence_improvement
2025-01-06 21:52:00 +01:00
Christoph M. Becker
bb6dbdcf94
Fix curl_multi_exec() overflow message (GH-17078)
As is, passing `2147484` as `$timeout`, throws a `ValueError` stating
the `$timeout` needs to be between 0 and 2147484, what is a confusing.
Thus we report the proper threshold as float.

While we're at it we also drop the superfluous `(double)` cast, and
rely on C's usual arithmetic conversions.
2024-12-13 16:06:39 +01:00
Christoph M. Becker
7e1d035077
Factor out SETUP_ZLIB_LIB() (GH-16798)
Note that this function is similar to `SETUP_OPENSSL`, but since the
zlib headers are not necessarily required, we append `_LIB`.

We are also more liberal regarding zlib(_a).lib, because
extensions requiring zlib are looking only for zlib.lib if ext/zlib has
been built as shared extension.  This is overly restrictive at best,
and actually makes no sense, since (a) we're not shipping shared zlib
builds for years, and (b) users could have a zlib.lib which is a static
build (they could even just rename zlib_a.lib to zlib.lib).
2024-11-27 18:35:34 +01:00
Niels Dossche
4591f0427f
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix various memory leaks in curl mime handling
2024-11-26 20:40:16 +01:00
Niels Dossche
8206de62f7
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix various memory leaks in curl mime handling
2024-11-26 20:40:09 +01:00
Niels Dossche
89060216a3
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix various memory leaks in curl mime handling
2024-11-26 20:37:51 +01:00
Niels Dossche
a80f0b515a
Fix various memory leaks in curl mime handling
Closes GH-16745.
2024-11-26 20:37:22 +01:00
Niels Dossche
2c532cf02b
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16802: open_basedir bypass using curl extension
2024-11-15 21:17:56 +01:00
Niels Dossche
1b803bc3f5
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16802: open_basedir bypass using curl extension
2024-11-15 21:17:51 +01:00
Niels Dossche
179ca2bf2a
Fix GH-16802: open_basedir bypass using curl extension
And fix a memleak while here.

Closes GH-16804.
2024-11-15 21:17:36 +01:00
Christoph M. Becker
85e23dbbb2
Update FreeBSD CI
FreeBSD 13.2 is no longer supported[1], and apparently the respective
Cirrus CI image has been removed.  We update to FreeBSD 13.3.

This also requires to disable some compiler warnings now, and adapt a
test case.

[1] <https://www.freebsd.org/security/#sup>
[2] <3304488820>

Co-authored-by: David Carlier <devnexen@gmail.com>

Closes GH-16817.
2024-11-15 18:20:48 +01:00
Christoph M. Becker
d4103b3570
Remove superfluous determination of cURL version (GH-16787)
This was originally meant to distinguish between libcurl 7.59.0 and
earlier; only the latter would need to be linked against normalize.lib,
libssh2.lib and nghttp2.lib[1].  That would only have catered to our
builds, and might not have been correct anyway.  However, the version
check was wrong (paren error), and has been removed in the meantime[2].

Given that cURL 7.59.0 is rather old, we do not reinstate the version
check, but rather drop the now superfluous (and improper) determination
of the cURL version.  A nice bonus is that we get rid of some global
variables.

[1] <a1ba3007a4>
[2] <94a12d5b31>
2024-11-14 12:25:08 +01:00
Gina Peter Banyard
53df3ae1e5
ext/curl: Use Z_ARRVAL_P instead of HASH_OF
We already check in advance that it is an array
2024-11-10 21:45:24 +00:00
Christoph M. Becker
9ebbe1e3f3
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16723: CURLMOPT_PUSHFUNCTION issues
2024-11-09 12:44:16 +01:00
Christoph M. Becker
3a1a205f2a
Fix GH-16723: CURLMOPT_PUSHFUNCTION issues
We copy the source handler's FCCs to those of the destination.

We also fix the erroneous test assumption that the trampoline wouldn't
be called.

Closes GH-16732.
2024-11-09 12:43:29 +01:00
Christoph M. Becker
e5654b75ac
Merge branch 'PHP-8.4'
* PHP-8.4:
  [skip ci] Fix typo in test name
2024-11-08 20:10:31 +01:00
Christoph M. Becker
6e6373ab89
[skip ci] Fix typo in test name 2024-11-08 20:10:14 +01:00
Ilija Tovilo
fb257ee83c
Upgrade master to Ubuntu 24.04 (GH-16704) 2024-11-07 16:32:45 +01:00
Ilija Tovilo
25c0993902
Backport CI fixes to security branches
Closes GH-16469

Working towards GH-16286

commit e0db221143b808d97bc3a44e9f0968c6308794b4
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Fri Oct 25 22:48:20 2024 +0200

    Move CFLAGS into ./configure command for consistency

commit 8ad67768250d181cd7fef30e0c866625bbd8ac94
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Fri Oct 25 22:47:03 2024 +0200

    Also upgrade nightly to macOS 13

commit 58a88ccb9f
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Wed Oct 23 19:07:59 2024 +0200

    Fix call to dc[n]gettext in tests with 0 $category

    This causes a segfault on PHP-8.1

commit 611af05c50
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Fri Dec 8 13:36:52 2023 +0100

    [skip ci] Skip intermittently failing curl test on macOS

    The test fails with "CURL ERROR: 56". I will create an issue for it shortly.

commit ec745178bb
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Wed Oct 23 19:05:32 2024 +0200

    Backport parts of 9999a0c for gettext

    See 9999a0cb75

commit 5ce703496f
Author: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date:   Sun Jul 28 14:34:26 2024 +0200

    Fix CI failure on macOS after Curl update

commit 714a3e7071
Author: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date:   Sat Jul 27 16:09:50 2024 +0200

    Fix CI failure after Curl update (#15124)

commit 4f2eb921b9
Author: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date:   Thu May 23 22:20:37 2024 +0200

    Fix GH-14307: Test curl_basic_024 fails with curl 8.8.0

    Curl changed the behaviour, from the changelog:
      - lib: make protocol handlers store scheme name lowercase curl/curl@c294f9c

    From the docs: "The returned scheme might be upper or lowercase. Do
    comparisons case insensitively."

    Closes GH-14312.

commit 251195b41b
Author: Ayesh Karunaratne <ayesh@aye.sh>
Date:   Thu Feb 1 02:03:55 2024 +0700

    ext/curl: Fix failing tests due to string changes in libcurl 8.6.0

    Upstream libcurl 8.6.0 contains a change[^1] that caused a test failure.
    This fixes it by updating the test's `EXPECTF` to use a regex to account for both string patterns.

    [^1]: 45cf4755e7 (diff-a8a54563608f8155973318f4ddb61d7328dab512b8ff2b5cc48cc76979d4204cL1683)

    Closes GH-13293.

commit fc5d83f2b1
Author: Christoph M. Becker <cmbecker69@gmx.de>
Date:   Wed Oct 16 22:46:20 2024 +0200

    Prepare for necessary move to macOS 13

    GH will remove macOS 12 runner images as of December 3rd, so we prepare
    for that.

    Besides the obvious need to change the runner, we also suppress a
    couple of warnings, because otherwise the build would fail due to
    `-Werror`.
2024-10-28 15:57:16 +01:00
Bob Weinand
1e08c15512 Merge branch 'PHP-8.4' 2024-10-25 01:31:15 +02:00
Bob Weinand
824c81602b Fix test without extra curl features
The empty line would otherwise be required in the test and make it fail.
2024-10-25 01:30:21 +02:00
Tim Düsterhus
cb6025cdac
curl: Add curl_multi_get_handles() (#16363)
see https://curl.se/libcurl/c/curl_multi_get_handles.html
2024-10-16 16:24:04 +02:00
David Carlier
2e263d26a2
Merge branch 'PHP-8.4' 2024-10-12 14:54:02 +01:00
David Carlier
42f877659d
Fix GH-16359 curl write callback crash on FCC usage w/o user function.
close GH-16362
2024-10-12 14:53:22 +01:00
DanielEScherzer
41996e8d4f
ext/[cd]*: fix a bunch of typos (#16298)
Only functional change is the renaming of the functions
`dom_document_substitue_entities_(read|write)` to replace `substitue` with
`substitute`.
2024-10-09 17:40:42 +02:00
Tim Düsterhus
b675db4c56
Merge branch 'PHP-8.4'
* PHP-8.4:
  curl: Prevent a CurlMultiHandle from holding onto a CurlHandle if `add_handle` fails (#16302)
2024-10-09 09:38:25 +02:00
Tim Düsterhus
f2fbb75f30
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  curl: Prevent a CurlMultiHandle from holding onto a CurlHandle if `add_handle` fails (#16302)
2024-10-09 09:38:16 +02:00
Tim Düsterhus
a1e96620f2
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  curl: Prevent a CurlMultiHandle from holding onto a CurlHandle if `add_handle` fails (#16302)
2024-10-09 09:37:50 +02:00
Tim Düsterhus
e49d732a83
curl: Prevent a CurlMultiHandle from holding onto a CurlHandle if add_handle fails (#16302)
* curl: Prevent a CurlMultiHandle from holding onto a CurlHandle if `add_handle` fails

As a user I expect `curl_multi_add_handle` to not have any effect if it returns
an error and I specifically do not expect that it would be necessary to call
`curl_multi_remove_handle`.

* NEWS
2024-10-09 09:37:13 +02:00
Tim Düsterhus
35a681d717
curl: Remove unnecessary dynamic allocation for HashTable in _php_curl_free (#16297)
Given that the lifecycle of the `slist` HashTable exactly matches the lifecycle
of the `_php_curl_free` struct, we might as well embed the HashTable directly
and avoid a pointer indirection.
2024-10-08 15:07:32 +02:00