Commit Graph

3070 Commits

Author SHA1 Message Date
Daniel Stenberg
c12a1fdd0e
tests: remove trailing spaces in server responses
Allows us to drop lots of %spc% from test cases making them easier on
the eye.

Closes #19374
2025-11-05 15:17:29 +01:00
Daniel Stenberg
0783ef2348
tests: remove most user-agent filters
Use the %VERSION instead. The user-agent stripping was introduced at the
time before we had %VERSION (introduced in e6b21d4). The tests would
then remove the user-agent header to make them possible to be compared
in a version independent way.

Fixes #19355
Reported-by: Stefan Eissing
Closes #19356
2025-11-04 13:05:11 +01:00
Viktor Szakats
63e9721b63
tests: avoid hard-coded CRLFs in more sections
- `reply/data*`, `verify/stdout`, `verify/stderr`, `verify/file*`,
  `verify/proxy`:
  - make `crlf="yes"` force CRLF to all lines, instead of just applying
    to HTTP protocol headers.
  - add support for `crlf="headers"` that only converts HTTP protocol
    header lines to CRLF. (previously done via `crlf="yes"`.)
  - use `crlf="headers"` where possible.

- `reply/connect*`:
  - add support for `crlf="yes"` and `crlf="headers"`.
  - use them where possible.

- `client/file*`, `client/stdin`:
  - add support for `crlf="yes"`.
  - use it where possible.

- `reply/data*`, `verify/protocol`:
  - replace existing uses of `crlf="yes"` with `crlf="headers`" where it
    does not change the result.

Reducing the number of `tests/data/test*`:
- CRLF newlines from 10295 to 1985. (119985 lines total)
- files with mixed newlines from 656 to 113. (1890 files total)

After this patch there remain 141 sections with mixed newlines, where
the mixing is not split between headers/non-headers. There is no obvious
pattern here. Some of the CRLF uses might be accidental, or
non-significant. They will be tackled in a future patch.

Follow-up to 6cf3d7b1b1 #19318
Follow-up to 4d2a05d3fe #19284

Closes #19313
2025-11-03 21:15:12 +01:00
Viktor Szakats
254e04b702
ftpserver.pl: fix newlines in 227/229 replies, adjust tests
The test FTP server returned LF newlines for 227/229 replies, instead of
the CRLF used for the rest.

Test data added later were explicitly made to expect an LF in these
response lines.

After this patch the FTP server returns CRLF newlines, allowing
to delete this special case in test data.

Follow-up to 3bfff57e1f
Follow-up to a7937ed49c

Closes #19330
2025-11-03 12:19:03 +01:00
Viktor Szakats
aaf9522a2c
test696: decouple from test556 data
Test 696 and 556 share the same libtest code. Make sure to issue
the `GET` request to the correct runtime test number instead of using
the hard-wired "556".

It makes the `sws` test server read the response string from `test696`
`<data>` section, instead of reading it from `test556`. To avoid this
hidden interaction between test data.

AFAICS there is no other similar hard-coded string in reused libtests.

Ref: https://github.com/curl/curl/pull/19313#issuecomment-3477448933
Follow-up to be82a3605a #16003
Closes #19329
2025-11-03 12:19:03 +01:00
Viktor Szakats
6cf3d7b1b1
tests: avoid more hard-coded CRLFs in protocol sections
- fix regex to not catch CR (from CRLF), in `PORT`, `EPRT`
  commands, allowing to use `crlf="yes"` more.
- add `crlf="headers"` mode for `protocol` sections.
  To call `subnewlines()` without its force option.
  This is the mode used in `data` sections when `crlf="yes"`.
  (This confusion may be subject to a future commit.)
- subnewlines: apply CRLF to `HEAD` and `CONNECT` HTTP requests.
- subnewlines: apply CRLF to RTSP requests.
- delete remaining empty `protocol` sections.

Reducing the number of `tests/data/test*`:
- CRLF newlines from 11325 to 10295. (119984 lines total)
- files with mixed newlines from 707 to 656. (1890 files total)

Follow-up to 4d2a05d3fe #19284

Closes #19318
2025-11-01 23:52:55 +01:00
Daniel Stenberg
8d0bfe74fb
httpsrr: send HTTPS query to the right target
When the target host is on a different port than 443, the name
"_[port]._https.[name]" shall be used.

Fixes #19301
Reported-by: Gunni on github
Closes #19324
2025-11-01 23:13:30 +01:00
Viktor Szakats
6a97bc2c97
tests/data: delete stray CRLFs in markup lines
Closes #19317
2025-11-01 04:36:09 +01:00
Viktor Szakats
2e408aa5cc
tests: replace standalone significant tabs with macro
Follow-up to d29f14b9cf #19300

Closes #19315
2025-10-31 23:44:21 +01:00
Viktor Szakats
d29f14b9cf
tests: replace significant invisible spaces with macros
To make them explicit, visible, avoid being accidentally trimmed.
Also prevents Git warnings, e.g. on `git am`.

Also:
- runtests: add support for `%spc%` and `%tab%` macros.
- test59: delete non-significant line-ending space.
- spacecheck.pl: drop line-ending whitespace exception for tests.

Closes #19300
2025-10-31 17:15:33 +01:00
Viktor Szakats
26e3f00469
test446, 1034, 1160: set US-ASCII encoding in XML header
To match the ASCII-7 requirement for curl test data files.

Follow-up to 9243ed59b3 #17329
Follow-up to 87ba80a6df

Closes #19297
2025-10-31 15:01:08 +01:00
Viktor Szakats
2147de554d
test429: use %repeat[]%
Follow-up to eb22e37060 #19281
Follow-up to 55d4767876 #19279

Closes #19296
2025-10-31 15:01:08 +01:00
Viktor Szakats
4d2a05d3fe
tests: use crlf=yes attribute more
To make special newlines more explicit and visible.
Mostly in `<protocol>` sections, some in `<data*>` and `<upload>`.

Reducing the number of `tests/data/test*`:
- CRLF newlines from 21535 to 11337.
- files with mixed newlines from 1335 to 707.

Also delete empty `<protocol>` sections.

Closes #19284
2025-10-31 15:01:08 +01:00
Viktor Szakats
d2e8acfaa6
test1100: fix missing <protocol> section
To make it actually run. Also fix the NTLM expected result, also syncing
it with other tests.

Follow-up to e6b21d422e #6037

Closes #19288
2025-10-31 13:14:06 +01:00
Viktor Szakats
eb22e37060
tests: use %repeat[] to make tests smaller (cont.)
tests: 46, 265, 304, 316, 397, 443, 551, 552, 559, 651, 742, 775, 1003,
1005, 1006, 1008, 1062, 1070, 1086, 1112, 1151, 1160, 1178, 1192, 1193,
1205, 1237, 3207.

Total `test*` size reduction: 2,395,537 -> 2,165,631 bytes.

Follow-up to 55d4767876 #19279

Closes #19281
2025-10-30 16:52:26 +01:00
Daniel Stenberg
55d4767876
tests: use %repeat[] to make tests smaller
Avoid putting huge chunks of repeated texts in test cases.

test3206, test1060, test1061 and test22

Closes #19279
2025-10-30 09:48:41 +01:00
TheBitBrine
e64c28e243
imap: fix custom FETCH commands to handle literal responses
Custom IMAP commands using -X (e.g. 'FETCH 123 BODY[1]') were only
returning the first line of responses containing literals, instead of
the full multi-line body data.

The issue was that custom commands route through imap_perform_list()
and imap_state_listsearch_resp(), which didn't detect or handle IMAP
literal syntax {size}.

This commit adds literal detection to imap_state_listsearch_resp():
- Detects literal syntax {size} in untagged responses
- Writes the response header line containing the literal marker
- Handles any literal body data already in the pingpong buffer
- Sets up transfer layer to read remaining literal data from socket
- Configures maxdownload and transfer size to include header + body
- Initializes pp->overflow to 0 when no buffered data present
- Modifies imap_done() to transition to FETCH_FINAL for custom
  commands that set up downloads

Test 841 and 3206 verify.

Fixes #18847
Reported-by: BohwaZ
Bug: https://github.com/curl/curl/issues/18847
Closes #19246
2025-10-30 08:48:28 +01:00
Daniel Stenberg
fe9e0115b1
tests: reduce max allowed allocations for four tests
and completely remove the check for one

Closes #19260
2025-10-28 23:28:50 +01:00
Daniel Stenberg
f9dfabb42a
test1802: test --proxy-headers and --headers setting user-agent 2025-10-27 09:52:05 +01:00
Daniel Stenberg
b602de775e
test776: set as 'flaky'
I have not figured out why, but having this test failing in CI every so often
is disturbing.

Reported-by: Viktor Szakatas
Fixes #19235
Closes #19243
2025-10-26 10:47:40 +01:00
Stefan Eissing
a330117bb0
smtp: fix EOB handling
SMTP automatically appends a \n.\n to an upload if there is not already
one at the end of the input. The implementation had a bug where this did
not happen, depending on read size and buffering.

Change test 900 to reproduce the failure. The bug only happened for mail
body input of known length, where EOS was known on the last chunk read.
Change test 900 to use an input file and make it large enough.

Fixes #18798
Closes #19193
Reported-by: madoe on github
2025-10-23 13:03:10 +02:00
Stefan Eissing
0a79a599a9
transfer: fix retry for empty downloads on reuse
When a reused connection did transfer 0 bytes, it assumed the transfer
had failed and needed a retry. Add a check for data->red.done, so we can
successfully accept the transfer of a 0-length file via SFTP.

Add test case 1583 to verfiy.

Fix SFTP disconnect debug trace when there was nothing to
disconnect (like when reusing a connection).

Fixes #19165
Reported-by: Alexander Blach
Closes #19189
2025-10-23 13:01:35 +02:00
Daniel Stenberg
a7ece53e96
test776: NTLM with too long NTMLv2 ntresplen 2025-10-23 10:20:16 +02:00
Daniel Stenberg
41e6b45edd
test775: verify NTLM with too long user name set 2025-10-23 10:20:16 +02:00
Daniel Stenberg
9e198618de
tool_parsecfg: detect and error on recursive --config use
The config file parser now has a maximum level of inclusions allowed (5)
to detect and prevent recursive inclusions of itself leading to badness.

Bonus: clean up return code handling from the config parser.

Test 774 verifies
Closes #19168
2025-10-21 10:11:43 +02:00
Daniel Stenberg
9596c4a258
http: return error for a second Location: header
Unless it is identical to the previous one.

Follow-up to dbcaa00657

Adjusted test 580, added test 772 and 773

Fixes #19130
Reported-by: Jakub Stasiak
Closes #19134
2025-10-20 09:35:23 +02:00
Daniel Stenberg
f847d2ed02
tool_formparse: rewrite the headers file parser
The -F option allows users to provide a file with a set of headers for a
specific formpost section. This code used old handcrafted parsing logic
that potentially could do wrong.

Rewrite to use my_get_line() and dynbuf. Supports longer lines and
should be more solid parsing code.

Gets somewhat complicated by the (unwise) feature that allows "folding"
of header lines in the file: if a line starts with a space it should be
appended to the previous.

The previous code trimmed spurious CR characters wherever they would
occur in a line but this version does not. It does not seem like
something we want or that users would expect.

Test 646 uses this feature.
Closes #19113
2025-10-18 12:49:53 +02:00
Daniel Stenberg
be852e39b2
tftp: check for trailing ";mode=" in URL without strstr
RFC 3617 defines two specific modes, "netascii" and "octet". This code
now checks only for those trailing ones - and not in the hostname since
they can't be there anymore.

Assisted-by: Jay Satiro
Closes #19070
2025-10-15 09:59:57 +02:00
Daniel Stenberg
27375ca364
tool_getparam: make --fail and --fail-with-body override each other
This allows users to put one of them in their .curlrc and still easily
use the other one at will in command lines.

The --no-* versions disable both of them.

Reported-by: Mitchell Blank Jr
Fixes #19029
Closes #19034
2025-10-13 10:38:10 +02:00
Jay Satiro
e7247d8697 tool_operate: keep failed partial download for retry auto-resume
- Keep data from a failed download instead of discarding it on retry in
  some limited cases when we know it's ok (currently only HTTP 200/206).

Prior to this change on failed transfer the tool truncated any outfile
data written before retrying the transfer. This change adds an exception
for HTTP downloads when the user requested auto-resume, because in that
case we can keep the outfile data and resume from the new position.

Reported-by: tkzv@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/18035
Closes https://github.com/curl/curl/pull/18665
2025-10-09 14:39:27 -04:00
Daniel Stenberg
5d32c4fc7b
test1582: verify the TLS channel binding cert memory leak fix 2025-10-09 09:10:56 +02:00
Daniel Stenberg
008078fc38
http: make Content-Length parser more WHATWG
Return error if there is something after the number other than
whitespace and newline.

Allow comma separated numbers and repeated headers as long as the new value is
the same as was set before.

Add test 767 to 771 to verify.

Reported-by: Ignat Loskutov
Fixes #18921
Closes #18925
2025-10-08 23:18:38 +02:00
Stefan Eissing
357808f4ad
multi: add notifications API
Add infrastructure to colled and dispatch notifications for transfers
and the multi handle in general. Applications can register a callback
and en-/disable notification type the are interested in.

Without a callback installed, notifications are not collected. Same when
a notification type has not been enabled.

Memory allocation failures on adding notifications lead to a general
multi failure state and result in CURLM_OUT_OF_MEMORY returned from
curl_multi_perform() and curl_multi_socket*() invocations.

Closes #18432
2025-10-07 10:55:31 +02:00
Daniel Stenberg
3b18aeb8bd
managen: verify the options used in example lines
Also fix the --knownhosts typo

Follow-up to aae18c4bdc

Reported-by: Daniel Terhorst-North
URL: https://mas.to/@tastapod/115327102344617386
Closes #18884
2025-10-06 23:17:33 +02:00
Daniel Stenberg
66f4c5699e
test766: verify CURLOPT_SOCKOPTFUNCTION error on accept
This test does active FTP with a socketopt callback that returns error
for the CURLSOCKTYPE_ACCEPT "purpose" to make sure we test and exercise
this error path - without leaks.

Closes #18879
2025-10-06 23:16:04 +02:00
Daniel Stenberg
a80dcb04e3
test1711: send a >64K mail with SMTP
A failed attempt to reproduce #18798

Closes #18861
2025-10-06 13:42:30 +02:00
Daniel Stenberg
aae18c4bdc
tool_getparam: add --knownhosts
To allow users to specify a known hosts file that is not the default
one: ~/.ssh/known_hosts

URL: https://github.com/curl/curl/discussions/18784
Closes #18859
2025-10-06 13:41:22 +02:00
Viktor Szakats
fff36a360e
checksrc: fix to handle ) predecing a banned function
Fixing:
```
Unmatched ) in regex; marked by <-- HERE in m/  \*buffer_len = \(ssize_t) <-- HERE
  strtol\(/ at /home/runner/work/curl/curl/scripts/checksrc.pl line 916, <$R> line 380.
```
Ref: https://github.com/curl/curl/actions/runs/18209824275/job/51848079550#step:3:5

Also add a test case.

Follow-up to 684f4cdd3e #18779
Cherry-picked from #18823
Closes #18836
2025-10-03 22:45:13 +02:00
Stefan Eissing
eefd03c572
ssl: support Apple SecTrust configurations
- configure/cmake support for enabling the option
- supported in OpenSSL and GnuTLS backends
- when configured, Apple SecTrust is the default trust store
  for peer verification. When one of the CURLOPT_* for adding
  certificates is used, that default does not apply.
- add documentation of build options and SSL use

Closes #18703
2025-10-03 12:02:23 +02:00
Viktor Szakats
632c5ee897
runtests: tag tests that require curl verbose strings
To skip them when curl has verbose strings disabled, instead of failing.

Cherry-picked from #18797
Closes #18800
2025-10-02 10:41:46 +02:00
Viktor Szakats
684f4cdd3e
checksrc: catch banned functions when preceded by (
Also add a test case.

Closes #18779
2025-09-30 13:16:47 +02:00
Viktor Szakats
20142f5d06
build: avoid overriding system symbols for fopen functions
By introducing wrappers for them in the curlx namespace:
`curlx_fopen()`, `curlx_fdopen()`, `curlx_fclose()`.

The undefine/redefine/`(function)()` methods broke on systems
implementing these functions as macros. E.g. AIX 32-bit's `fopen()`.

Also:
- rename `lib/fopen.*` to `lib/curl_fopen.*` (for `Curl_fopen()`)
  to make room for the newly added `curlx/fopen.h`.
- curlx: move file-related functions from `multibyte.c` to `fopen.c`.
- tests/server: stop using the curl-specific `fopen()` implementation
  on Windows. Unicode isn't used by runtests, and it isn't critical to
  run tests on longs path. It can be re-enabled if this becomes
  necessary, or if the wrapper receives a feature that's critical for
  test servers.

Reported-by: Andrew Kirillov
Bug: https://github.com/curl/curl/issues/18510#issuecomment-3274393640

Follow-up to bf7375ecc5 #18503
Follow-up to 9863599d69 #18502
Follow-up to 3bb5e58c10 #17827

Closes #18634
2025-09-30 01:10:36 +02:00
Stefan Eissing
061e265502
http: handle user-defined connection headers
When there is more than one user-supplied 'Connection: ' header, add
values that curl needs internally to the first one and emit all
subsequent ones thereafter.

Fixes #18662
Reported-by: Evgeny Grin (Karlson2k)
Closes #18686
2025-09-26 09:27:50 +02:00
Daniel Stenberg
3dad0cfd77
write-out: make %header{} able to output *all* occurances of a header
By appending `:all:[separator]` to the header name. The `[separator]` string
is output between each header value if there are more than one to output.

Test 764 and 765 verify

Idea-by: kapsiR on github
Ref: #18449
Closes #18491
2025-09-21 00:00:29 +02:00
Daniel Stenberg
5ab120bc4e
krb5: drop support for Kerberos FTP
It was accidentally broken in commit 0f4c439fc7, shipped since
8.8.0 (May 2024) and yet not a single person has noticed or reported,
indicating that we might as well drop support for FTP Kerberos.

Krb5 support was added in 54967d2a3a (July 2007), and we have
been carrying the extra license information around since then for this
code. This commit removes the last traces of that code and thus we can
remove the extra copyright notices along with it.

Reported-by: Joshua Rogers
Closes #18577
2025-09-20 23:58:28 +02:00
Daniel Stenberg
fd6eb8d6e7
cookie: avoid saving a cookie file if no transfer was done
Because parts of the cookie loading happens on transfer start the
in-memory cookie jar risks being incomplete and then a save might
wrongly truncate the target file.

Added test 1902 to verify.

Reported-by: divinity76 on github
Fixes #18621
Closes #18622
2025-09-19 16:40:20 +02:00
Daniel Stenberg
a827e4294c
smtp: check EHLO responses case insensitively
Adjust test 980 to announce starttls in lowercase.

Fixes #18588
Reported-by: Joshua Rogers
Closes #18589
2025-09-18 08:02:12 +02:00
Daniel Stenberg
dbe4e28d57
managen: render better manpage references/links
- When an option name is used in text, this script no longer outputs the
  short plus long version in the manpage output. It makes the text much
  more readable.

  This always showing both verions was previously done primarily to make
  sure roffit would linkify it correctly, but since roffit 0.17 it
  should link both long or short names correctly.

- When managen outputs generic text about options at the end of the
  description it now highlights them properly so that they too get
  linkified correctly in the HTML version. For consistency.

Closes #18580
2025-09-17 15:49:15 +02:00
Viktor Szakats
a4196e2249
tidy-up: whitespace
Closes #18553
2025-09-15 15:00:11 +02:00
Stefan Eissing
de3fc1d7ad
asyn-thrdd: drop pthread_cancel
Remove use of pthread_cancel in asnyc threaded resolving. While there
are system where this works, others might leak to resource leakage
(memory, files, etc.). The popular nsswitch is one example where resolve
code can be dragged in that is not prepared.

The overall promise and mechanism of pthread_cancel() is just too
brittle and the historcal design of getaddrinfo() continues to haunt us.

Fixes #18532
Reported-by: Javier Blazquez
Closes #18540
2025-09-15 09:25:43 +02:00