Commit Graph

2818 Commits

Author SHA1 Message Date
Daniel Stenberg
fe9f68fa61
cmdline-opts: shorter help texts
In an effort to increase the readability of the "--help all" output on
narrow (80 column) terminals.

Co-authored-by: Jay Satiro

Closes #13169
2024-03-25 13:05:24 +01:00
Daniel Stenberg
6bd4ca0ef6
tool_getparam: accept a blank -w ""
Added test 468 to verify.

Regression from 07bcae89d5 (shipped in 8.6.0)
Reported-by: Thomas Pyle
Fixes #13144
Closes #13145
2024-03-19 07:45:05 +01:00
Daniel Stenberg
40948189ff
curl: make --libcurl output better CURLOPT_*SSLVERSION
The option is really two enums ORed together, so it needs special
attention to make the code output nice.

Added test 1481 to verify. Both the server and the proxy versions.

Reported-by: Boris Verkhovskiy
Fixes #13127
Closes #13129
2024-03-14 17:59:22 +01:00
Daniel Stenberg
3ccce37790
tool_getparam: handle non-existing (out of range) short-options
... correctly, even when they follow an existing one without a space in
between.

Verify with test 467

Follow-up to 07dd60c05b
Reported-by: Geeknik Labs
Fixes #13101
Closes #13102
2024-03-12 07:58:42 +01:00
Daniel Stenberg
1ccf1cd993
scripts/managen: the new name and home for the manpage generator
It was previously docs/cmdline-opts/gen.pl

Closes #13089
2024-03-08 17:05:08 +01:00
Viktor Szakats
e55db0c8c7
mkhelp: rename variable to fix compiler warnings
```
src\tool_operate.c(541,33): warning C4459: declaration of 'm' hides global declaration [_bld\src\curl.vcxproj]
  _bld\src\tool_hugehelp.c(8,27):
  see declaration of 'm'
src\tool_paramhlp.c(307,14): warning C4459: declaration of 'm' hides global declaration [_bld\src\curl.vcxproj]
src\tool_progress.c(118,16): warning C4459: declaration of 'm' hides global declaration [_bld\src\curl.vcxproj]
src\tool_writeout.c(288,31): warning C4459: declaration of 'm' hides global declaration [_bld\src\curl.vcxproj]
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/49348159/job/51ee75cd2n0wj6lc#L614

Reviewed-by: Daniel Stenberg
Closes #13077
2024-03-07 19:03:30 +00:00
Daniel Stenberg
923f7f8ce5
paramhlp: fix CRLF-stripping files with "-d @file"
All CR and LF bytes should be stripped, as documented, and all other
bytes are inluded in the data. Starting now, it also excludes null bytes
as they would otherwise also cut the data short.

Reported-by: Simon K
Fixes #13063
Closes #13064
2024-03-07 08:14:45 +01:00
Daniel Stenberg
62c08d5d4a
mkhelp: simplify the generated hugehelp program
Use a plain array and puts() every line, also allows us to provide the
strings without ending newlines.

- merge blank lines into the next one as a prefixed newline.
- turn eight consecutive spaces into a tab (since they can only be on the
  left side of text)
- the newly generated tool_hugehelp is 3K lines shorter and 50K smaller
- modifies the top logo layout a little by reducing the indent

Closes #13047
2024-03-06 15:56:00 +01:00
Daniel Stenberg
f03c85635f
docs: ascii version of manpage without nroff
Create ASCII version of manpage without nroff

 - build src/tool_hugegelp.c from the ascii manpage
 - move the the manpage and the ascii version build to docs/cmdline-opts
 - remove all use of nroff from the build process
 - should make the build entirely reproducible (by avoiding nroff)

 - partly reverts 2620aa9 to build libcurl option man pages one by one
   in cmake because the appveyor builds got all crazy until I did

The ASCII version of the manpage

 - is built with gen.pl, just like the manpage is
 - has a right-justified column making the appearance similar to the previous
   version
 - uses a 4-space indent per level (instead of the old version's 7)
 - does not do hyphenation of words (which nroff does)

History

  We first made the curl build use nroff for building the hugehelp file in
  December 1998, for curl 5.2.

Closes #13047
2024-03-06 15:55:59 +01:00
Daniel Stenberg
65405459d5
getparam: make --ftp-ssl work again
Follow-up to 9e4e527 which accidentally broke it

Reported-by: Jordan Brown
Fixes #13006
Closes #13007
2024-02-28 11:20:22 +01:00
Daniel Stenberg
6e494a2390
docs: more language cleanups
- present tense
- avoid bad words

Closes #13003
2024-02-27 16:19:43 +01:00
Daniel Stenberg
ac208ccf6f
write-out: add '%{proxy_used}'
Returns 1 if the previous transfer used a proxy, otherwise 0. Useful to
for example determine if a `NOPROXY` pattern matched the hostname or
not.

Extended test 970 and 972
2024-02-22 08:38:53 +01:00
Daniel Stenberg
ef4bd8d6c0
curl: when allocating variables, add the name into the struct
This saves the name from being an extra separate allocation.

Closes #12891
2024-02-07 23:11:40 +01:00
Daniel Stenberg
0f0edc283c
curl: exit on config file parser errors
Like when trying to import an environment variable that does not exist.

Also fix a bug for reading env variables when there is a default value
set.

Bug: https://curl.se/mail/archive-2024-02/0008.html
Reported-by: Brett Buddin

Add test 462 to verify.

Closes #12862
2024-02-07 13:45:28 +01:00
Daniel Stenberg
924e264bde tool_operate: change precedence of server Retry-After time
- When calculating the retry time, no longer allow a server's requested
  Retry-After time to take precedence over a longer retry time (either
  default algorithmic or user-specified).

Prior to this change the server's Retry-After time took precedence over
curl's retry time in all cases, but that's not always practical for
short Retry-After times depending on how busy the server is.

Bug: https://curl.se/mail/archive-2024-01/0022.html
Reported-by: Dirk Hünniger

Closes https://github.com/curl/curl/pull/12871
2024-02-07 02:49:28 -05:00
Daniel Stenberg
911fc964a1
cmdline-docs: quote and angle bracket cleanup
- make sure angle brackets are escaped
- remove a lot of superfluous double quotes
- replace several double quotes with backticks

To make nicer-looking markdown.

Closes #12884
2024-02-07 08:35:28 +01:00
Daniel Stenberg
75d79a4486
tool_cb_hdr: only parse etag + content-disposition for 2xx
... and ignore them for other response codes.

Reported-by: Harry Sintonen
Closes #12866
2024-02-05 23:40:33 +01:00
Chris Webb
541321507e
configure: add --disable-docs flag
Building man pages from curldown sources now requires perl. Add a
--disable-docs flag to configure to enable building and installing
without documentation where perl is not available or man pages are not
required. This is selected automatically (with a warning) when perl is
not found by configure.

Fixes #12832
Closes #12857
2024-02-05 19:39:52 +01:00
Daniel Stenberg
2f3e7a26bc
tool_operate: do not set CURLOPT_QUICK_EXIT in debug builds
Since it allows (small) memory leaks that interfere with torture tests
and regular memory-leak checks.

Reported-by: Dan Fandrich
Fixes #12834
Closes #12835
2024-02-01 11:43:47 +01:00
Viktor Szakats
cb343182b7
build: delete/replace 3 more clang warning pragmas
- tool_msgs: delete redundant `-Wformat-nonliteral` suppression pragma.

- whitespace formatting in `mprintf.h`, lib518, lib537.

- lib518: fix wrong variable in `sizeof()`.

- lib518: bump variables to `rlim_t`.
  Follow-up to e2b394106d #1469

- lib518: sync error message with lib537
  Follow-up to 365322b8bc

- lib518, lib537: replace `-Wformat-nonliteral` suppression pragmas
  by reworking test code.

Follow-up to 5b286c2508 #12812
Follow-up to aee4ebe591 #12803
Follow-up to 0923012758 #12540
Follow-up to 3829759bd0 #12489

Reviewed-by: Daniel Stenberg
Closes #12814
2024-01-28 23:54:32 +00:00
Viktor Szakats
5b286c2508
build: delete/replace clang warning pragmas
- delete redundant warning suppressions for `-Wformat-nonliteral`.
  This now relies on `CURL_PRINTF()` and it's theoratically possible
  that this macro isn't active but the warning is. We're ignoring this
  as a corner-case here.

- replace two pragmas with code changes to avoid the warnings.

Follow-up to aee4ebe591 #12803
Follow-up to 0923012758 #12540
Follow-up to 3829759bd0 #12489

Reviewed-by: Daniel Stenberg
Closes #12812
2024-01-27 21:19:41 +00:00
Daniel Stenberg
52c4d8d3f4
tool: fix the listhelp generation command
The previous command line to generate the tool_listhelp.c source file
broke with 2494b8dd51.

Make 'make listhelp' invoked in src/ generate it. Also update the
comment in the file to mention the right procedure.

Closes #12786
2024-01-25 13:54:26 +01:00
Viktor Szakats
a808aab068
cmake: rework options to enable curl and libcurl docs
Rework CMake options for building/using curl tool and libcurl manuals.

- rename `ENABLE_MANUAL` to `ENABLE_CURL_MANUAL`, meaning:
  to build man page and built-in manual for curl tool.

- rename `BUILD_DOCS` to `BUILD_LIBCURL_DOCS`, meaning:
  to build man pages for libcurl.

- `BUILD_LIBCURL_DOCS` now works without having to enable
  `ENABLE_CURL_MANUAL` too.

- drop support for existing CMake-level `USE_MANUAL` option to avoid
  confusion. (It used to work with the effect of current
  `ENABLE_CURL_MANUAL`, but only by accident.)

Assisted-by: Richard Levitte
Ref: #12771
Closes #12773
2024-01-24 23:22:27 +00:00
Jay Satiro
f4606a796e tool_getparam: stop supporting @filename style for --cookie
The `@filename` style was never documented for --cookie <data|filename>
but prior to this change curl would accept it anyway and always treat a
@ prefixed string as a filename.

That's a problem if the string also contains a = sign because then it is
documented to be interpreted as a cookie string and not a filename.

Example:

`--cookie @foo=bar`

Before: Interpreted as load cookies from filename foo=bar.

After: Interpreted as cookie `@foo=bar` (name `@foo` and value `bar`).

Other curl options with a data/filename option-value use the `@filename`
to distinguish filenames which is probably how this happened. The
--cookie option has never been documented that way.

Ref: https://curl.se/docs/manpage.html#-b

Closes https://github.com/curl/curl/pull/12645
2024-01-17 00:32:28 -05:00
Daniel Stenberg
ae9f01f336
tool_operate: make --remove-on-error only remove "real" files
Reported-by: Harry Sintonen
Assisted-by: Dan Fandrich

Closes #12710
2024-01-16 10:57:12 +01:00
Daniel Stenberg
ba01cac39b
tool_operate: stop setting the file comment on Amiga
- the URL is capped at 80 cols, which ruins it if longer
- it does not strip off URL credentials
- it is done unconditonally, not on --xattr
- we don't have Amiga in the CI which makes fixing it blindly fragile

Someone who builds and tests on Amiga can add it back correctly in a
future if there is a desire.

Reported-by: Harry Sintonen
Closes #12709
2024-01-15 18:21:16 +01:00
Daniel Stenberg
fb414370ac
tool_getparam: move the --rate logic into set_rate() 2024-01-08 22:39:18 +01:00
Daniel Stenberg
9e4e527735
tool_getparam: switch to an enum for every option
To make the big switch much easier to read/understand and to make it
easier to add new options.
2024-01-08 22:39:11 +01:00
Daniel Stenberg
1f4433dad4
tool_getparam: build post data using dynbuf (more) 2024-01-08 22:38:22 +01:00
Daniel Stenberg
1dba44b2f1
tool_getparam: replace malloc + copy by dynbuf for --data 2024-01-08 22:38:22 +01:00
Daniel Stenberg
f37840a46e
tool_getparam: make data_urlencode avoid direct malloc
use aprintf() instead
2024-01-08 22:38:22 +01:00
Daniel Stenberg
3870d03b5d
tool_getparam: move the --url-query logic into url_query()
This function is not doing post at all so it was always weirdly placed.
2024-01-08 22:38:22 +01:00
Daniel Stenberg
8aecfad9e6
tool_getparam: move the --data logic into set_data() 2024-01-08 22:38:22 +01:00
Daniel Stenberg
f6e97effb6
tool_getparam: unify the cmdline switch() into a single one
- easier to follow, easier to modify, easier to extend, possibly slightly
  faster

- each case now has the long option as a comment
2024-01-08 22:38:22 +01:00
Daniel Stenberg
07dd60c05b
tool_getparam: bsearch cmdline options
- the option names are now alpha sorted and lookup is a lot faster

- use case sensitive matching. It was previously case insensitive, but that
  was not documented nor tested.

- remove "partial match" feature. It was not documented, not tested and
  was always fragile as existing use could break when we add a new
  option

- lookup short options via a table

Closes #12631
2024-01-08 22:38:22 +01:00
Daniel Stenberg
07bcae89d5
tool: make parser reject blank arguments if not supported
Already in the getstr() function that clones the input argument.

Closes #12620
2024-01-03 23:21:29 +01:00
Daniel Stenberg
941b56d790
tool: prepend output_dir in header callback
When Content-Disposition parsing is used and an output dir is prepended,
make sure to store that new file name correctly so that it can be used
for setting the file timestamp when --remote-time is used.

Extended test 3012 to verify.

Co-Authored-by: Jay Satiro
Reported-by: hgdagon on github
Fixes #12614
Closes #12617
2024-01-02 23:26:56 +01:00
Daniel Stenberg
b23255af99
tool_listhelp: regenerate after recent .d updates
Makes it survive test 1478

Closes #12612
2024-01-02 08:44:12 +01:00
Daniel Stenberg
d187f51948
tool_getparam: do not try to expand without an argument
This would lead to a segfault.

Fixes #12565
Reported-by: Geeknik Labs
Closes #12575
2023-12-21 15:27:05 +01:00
Viktor Szakats
0923012758
build: more -Wformat fixes
- memdebug: update to not trigger `-Wformat-nonliteral` warnings.
- imap: mark `imap_sendf()` with  `CURL_PRINTF()`.
- tool_msgs: mark static function with `CURL_PRINTF()`.

Follow-up to 3829759bd0 #12489

Closes #12540
2023-12-18 14:56:57 +00:00
Viktor Szakats
3829759bd0
build: enable missing OpenSSF-recommended warnings, with fixes
https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
as of 2023-11-29 [1].

Enable new recommended warnings (except `-Wsign-conversion`):

- enable `-Wformat=2` for clang (in both cmake and autotools).
- add `CURL_PRINTF()` internal attribute and mark functions accepting
  printf arguments with it. This is a copy of existing
  `CURL_TEMP_PRINTF()` but using `__printf__` to make it compatible
  with redefinting the `printf` symbol:
  https://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_5.html#SEC94
- fix `CURL_PRINTF()` and existing `CURL_TEMP_PRINTF()` for
  mingw-w64 and enable it on this platform.
- enable `-Wimplicit-fallthrough`.
- enable `-Wtrampolines`.
- add `-Wsign-conversion` commented with a FIXME.
- cmake: enable `-pedantic-errors` the way we do it with autotools.
  Follow-up to d5c0351055 #2747
- lib/curl_trc.h: use `CURL_FORMAT()`, this also fixes it to enable format
  checks. Previously it was always disabled due to the internal `printf`
  macro.

Fix them:

- fix bug where an `set_ipv6_v6only()` call was missed in builds with
  `--disable-verbose` / `CURL_DISABLE_VERBOSE_STRINGS=ON`.
- add internal `FALLTHROUGH()` macro.
- replace obsolete fall-through comments with `FALLTHROUGH()`.
- fix fallthrough markups: Delete redundant ones (showing up as
  warnings in most cases). Add missing ones. Fix indentation.
- silence `-Wformat-nonliteral` warnings with llvm/clang.
- fix one `-Wformat-nonliteral` warning.
- fix new `-Wformat` and `-Wformat-security` warnings.
- fix `CURL_FORMAT_SOCKET_T` value for mingw-w64. Also move its
  definition to `lib/curl_setup.h` allowing use in `tests/server`.
- lib: fix two wrongly passed string arguments in log outputs.
  Co-authored-by: Jay Satiro
- fix new `-Wformat` warnings on mingw-w64.

[1] 56c0fde389/docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C%2B%2B.md

Closes #12489
2023-12-16 13:12:37 +00:00
Viktor Szakats
ba8752e556
Makefile.mk: drop Windows support
And DLL-support with it. This leaves `Makefile.mk` for MS-DOS and Amiga.

We recommend CMake instead. With unity mode it's much faster, and about
the same without.

Ref: https://github.com/curl/curl/pull/12221#issuecomment-1783761806
Reviewed-by: Daniel Stenberg
Closes #12224
2023-12-16 13:12:22 +00:00
Daniel Stenberg
102de7aa8d
curl: show ipfs and ipns as supported "protocols"
They are accepted schemes in URLs passed to curl (the tool, not the
library).

Also makes curl-config show the same list.

Co-Authored-by: Jay Satiro
Reported-by: Chara White
Bug: https://curl.se/mail/archive-2023-12/0026.html
Closes #12508
2023-12-15 14:03:44 +01:00
Emanuele Torre
6c7da81561
tool_writeout_json: fix JSON encoding of non-ascii bytes
char variables if unspecified can be either signed or unsigned depending
on the platform according to the C standard; in most platforms, they are
signed.

This meant that the  *i<32  waas always true for bytes with the top bit
set. So they were always getting encoded as \uXXXX, and then since they
were also signed negative, they were getting extended with 1s causing
'\xe2' to be expanded to \uffffffe2, for example:

  $ curl --variable 'v=“' --expand-write-out '{{v:json}}\n' file:///dev/null
  \uffffffe2\uffffff80\uffffff9c

I fixed this bug by making the code use explicitly unsigned char*
variables instead of char* variables.

Test 268 verifies

Reported-by: iconoclasthero
Closes #12434
2023-12-01 10:39:13 +01:00
Stefan Eissing
39778f95fd
test459: fix for parallel runs
- change warniing message to work better with varying filename
  length.
- adapt test output check to new formatting

Follow-up to 97ccc4479f
Closes #12423
2023-11-28 14:23:06 +01:00
Daniel Stenberg
e6bf2001c7
tool_cb_prg: make the carriage return fit for wide progress bars
When the progress bar was made max width (256 columns), the fly()
function attempted to generate its output buffer too long so that the
trailing carriage return would not fit and then the output would show
wrongly. The fly function is called when the expected total transfer is
unknown, which could be one or more progress calls before the actual
progress meter get shown when the expected transfer size is provided.

This new take also replaces the msnprintf() call with a much simpler
memset() for speed.

Reported-by: Tim Hill
Fixes #12407
Closes #12415
2023-11-27 19:16:05 +01:00
Daniel Stenberg
97ccc4479f
tool_parsecfg: make warning output propose double-quoting
When the config file parser detects a word that *probably* should be
quoted, mention double-quotes as a possible remedy.

Test 459 verifies.

Proposed-by: Jiehong on github
Fixes #12409
Closes #12412
2023-11-27 14:02:50 +01:00
Jay Satiro
1b04dfa371 curl.rc: switch out the copyright symbol for plain ASCII
.. like we already do for libcurl.rc.

libcurl.rc copyright symbol used to cause a "non-ascii 8-bit codepoint"
warning so it was switched to ascii.

Ref: https://github.com/curl/curl/commit/1ca62bb5#commitcomment-133474972

Suggested-by: Robert Southee

Closes https://github.com/curl/curl/pull/12403
2023-11-26 18:42:02 -05:00
Daniel Stenberg
0510e8b58c
lib: fix comment typos
Five separate ones, found by codespell

Closes #12390
2023-11-23 12:35:59 +01:00
Viktor Szakats
e9a7d4a1c8
windows: use built-in _WIN32 macro to detect Windows
Windows compilers define `_WIN32` automatically. Windows SDK headers
or build env defines `WIN32`, or we have to take care of it. The
agreement seems to be that `_WIN32` is the preferred practice here.
Make the source code rely on that to detect we're building for Windows.

Public `curl.h` was using `WIN32`, `__WIN32__` and `CURL_WIN32` for
Windows detection, next to the official `_WIN32`. After this patch it
only uses `_WIN32` for this. Also, make it stop defining `CURL_WIN32`.

There is a slight chance these break compatibility with Windows
compilers that fail to define `_WIN32`. I'm not aware of any obsolete
or modern compiler affected, but in case there is one, one possible
solution is to define this macro manually.

grepping for `WIN32` remains useful to discover Windows-specific code.

Also:

- extend `checksrc` to ensure we're not using `WIN32` anymore.

- apply minor formatting here and there.

- delete unnecessary checks for `!MSDOS` when `_WIN32` is present.

Co-authored-by: Jay Satiro
Reviewed-by: Daniel Stenberg

Closes #12376
2023-11-22 15:42:25 +00:00