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
This commit is contained in:
Daniel Stenberg 2025-10-18 11:58:36 +02:00
parent f32451c12b
commit f847d2ed02
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 53 additions and 54 deletions

View file

@ -42,7 +42,7 @@ It may contain any type of data.
X-fileheader1: This is a header from a file
# This line is another comment. It precedes a folded header.
X-fileheader2: This is #a
X-fileheader2: This is #a
folded header
</file2>
</client>