summaryrefslogtreecommitdiff
path: root/lib/formdata.c
Commit message (Collapse)AuthorAgeFilesLines
* copyright: update all copyright lines and remove year rangesDaniel Stenberg2023-01-031-1/+1
| | | | | | | | | | | | - they are mostly pointless in all major jurisdictions - many big corporations and projects already don't use them - saves us from pointless churn - git keeps history for us - the year range is kept in COPYING checksrc is updated to allow non-year using copyright statements Closes #10205
* mime: relax easy/mime structures bindingPatrick Monnerat2022-11-281-2/+2
| | | | | | | | | | | | | | | | | | | Deprecation and removal of codeset conversion support from the library have released the strict need for an early binding of mime structures to an easy handle (https://github.com/curl/curl/commit/2610142). This constraint currently forces to create the handle before the mime structure and the latter cannot be attached to another handle once created (see https://curl.se/mail/lib-2022-08/0027.html). This commit removes the handle pointers from the mime structures allowing more flexibility on their use. When an easy handle is duplicated, bound mime structures must however still be duplicated too as their components hold send-time dynamic information. Closes #9927
* lib: fix some type mismatches and remove unneeded typecastsRose2022-11-081-8/+6
| | | | | | | | | Many of these castings are unneeded if we change the variables to work better with each other. Ref: https://github.com/curl/curl/pull/9823 Closes https://github.com/curl/curl/pull/9835
* misc: typo and grammar fixesAyesh Karunaratne2022-10-271-2/+2
| | | | | | | | | | - Replace `Github` with `GitHub`. - Replace `windows` with `Windows` - Replace `advice` with `advise` where a verb is used. - A few fixes on removing repeated words. - Replace `a HTTP` with `an HTTP` Closes #9802
* formdata: typecast the va_arg return valueDaniel Stenberg2022-09-131-1/+1
| | | | | | | | To avoid "enumerated type mixed with another type" warnings Follow-up from 0f52dd5fd5aa3592691a Closes #9499
* formdata: fix warning: 'CURLformoption' is promoted to 'int'zhanghu2022-09-131-2/+4
| | | | | | | | | | | curl/lib/formdata.c: In function 'FormAdd': curl/lib/formdata.c:249:31: warning: 'CURLformoption' is promoted to 'int' when passed through '...' 249 | option = va_arg(params, CURLformoption); | ^ curl/lib/formdata.c:249:31: note: (so you should pass 'int' not 'CURLformoption' to 'va_arg') curl/lib/formdata.c:249:31: note: if this code is reached, the program will abort Closes #9484
* copyright: make repository REUSE compliantmax.mehl2022-06-131-0/+2
| | | | | | | | | | | Add licensing and copyright information for all files in this repository. This either happens in the file itself as a comment header or in the file `.reuse/dep5`. This commit also adds a Github workflow to check pull requests and adapts copyright.pl to the changes. Closes #8869
* lib: remove support for CURL_DOES_CONVERSIONSDaniel Stenberg2022-02-041-13/+1
| | | | | | TPF was the only user and support for that was dropped. Closes #8378
* formdata: avoid size_t => long typecast overflowsDaniel Stenberg2022-01-131-2/+7
| | | | | | | | Typically a problem for platforms with 32 bit long and 64 bit size_t Reported-by: Fabian Yamaguchi Bug: https://hackerone.com/reports/1444539 Closes #8272
* formdata: avoid "Argument cannot be negative" warningDaniel Stenberg2021-07-011-4/+10
| | | | | | | | | | ... when converting a curl_off_t to size_t, by using CURL_ZERO_TERMINATED before passing the argument to the function. Detected by Coverity CID 1486590. Closes #7328 Assisted-by: Daniel Gustafsson
* formdata: correct typecast in curl_mime_data callDaniel Stenberg2021-06-301-2/+2
| | | | | | Coverity pointed out it the mismatch. CID 1486590 Closes #7327
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* terminology: call them null-terminated stringsDaniel Stenberg2020-06-281-2/+2
| | | | | | | | | | | Updated terminology in docs, comments and phrases to refer to C strings as "null-terminated". Done to unify with how most other C oriented docs refer of them and what users in general seem to prefer (based on a single highly unscientific poll on twitter). Reported-by: coinhubs on github Fixes #5598 Closes #5608
* source cleanup: remove all custom typedef structsDaniel Stenberg2020-05-151-8/+8
| | | | | | | | | | | - Stick to a single unified way to use structs - Make checksrc complain on 'typedef struct {' - Allow them in tests, public headers and examples - Let MD4_CTX, MD5_CTX, and SHA256_CTX typedefs remain as they actually typedef different types/structs depending on build conditions. Closes #5338
* mime: latch last read callback status.Patrick Monnerat2020-03-071-8/+4
| | | | | | | | | | | | | In case a read callback returns a status (pause, abort, eof, error) instead of a byte count, drain the bytes read so far but remember this status for further processing. Takes care of not losing data when pausing, and properly resume a paused mime structure when requested. New tests 670-673 check unpausing cases, with easy or multi interface and mime or form api. Fixes #4813 Reported-by: MrdUkk on github
* formdata/mime: copyright year range updateDaniel Stenberg2020-03-021-1/+1
| | | | Due to the merge/revert cycle
* Revert "mime: latch last read callback status."Daniel Stenberg2020-03-021-9/+5
| | | | | | | | This reverts commit 87869e38d7afdec3ef1bb4965711458b088e254f. Fixes #5014 Closes #5015 Reopens #4833
* mime: latch last read callback status.Patrick Monnerat2020-03-021-5/+9
| | | | | | | | | | | | | | In case a read callback returns a status (pause, abort, eof, error) instead of a byte count, drain the bytes read so far but remember this status for further processing. Takes care of not losing data when pausing, and properly resume a paused mime structure when requested. New tests 670-673 check unpausing cases, with easy or multi interface and mime or form api. Fixes #4813 Reported-by: MrdUkk on github Closes #4833
* mime: acknowledge CURL_DISABLE_MIMEDaniel Stenberg2019-05-131-6/+6
|
* build: fix "clarify calculation precedence" warningsMarcel Raad2019-05-121-1/+1
| | | | | | | Codacy/CppCheck warns about this. Consistently use parentheses as we already do in some places to silence the warning. Closes https://github.com/curl/curl/pull/3866
* curl-compilers: enable -Wimplicit-fallthrough=4 for GCCMarcel Raad2018-08-211-1/+2
| | | | | | | | This enables level 4 instead of the default level 3, which of the currently used comments only allows /* FALLTHROUGH */ to silence the warning. Closes https://github.com/curl/curl/pull/2747
* Silence GCC 8 cast-function-type warningsMarcel Raad2018-08-111-1/+3
| | | | | | | | | | On Windows, casting between unrelated function types is fine and sometimes even necessary, so just use an intermediate cast to (void (*) (void)) to silence the warning as described in [0]. [0] https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Warning-Options.html Closes https://github.com/curl/curl/pull/2860
* formdata: Remove unused macro HTTPPOST_CONTENTTYPE_DEFAULTRikard Falkeborn2018-08-091-4/+0
| | | | | | | Its usage was removed in 84ad1fd3047815f9c6e78728bb351b828eac10b1. Closes #2852
* cppcheck: fix warningsMarian Klymov2018-06-111-2/+1
| | | | | | | | | | | | | - Get rid of variable that was generating false positive warning (unitialized) - Fix issues in tests - Reduce scope of several variables all over etc Closes #2631
* checksrc: make sure sizeof() is used *with* parenthesesDaniel Stenberg2018-05-211-1/+1
| | | | | | ... and unify the source code to adhere. Closes #2563
* formdata: use the mime-content type functionDaniel Stenberg2018-02-051-56/+8
| | | | | | | | | | Reduce code duplication by making Curl_mime_contenttype available and used by the formdata function. This also makes the formdata function recognize a set of more file extensions by default. PR #2280 brought this to my attention. Closes #2282
* mime: keep "text/plain" content type if user-specified.Patrick Monnerat2017-10-121-1/+1
| | | | | | Include test cases in 554, 587, 650. Fixes https://github.com/curl/curl/issues/1986
* form/mime: field names are not allowed to contain zero-valued bytes.Patrick Monnerat2017-09-221-5/+32
| | | | | Also suppress length argument of curl_mime_name() (names are always zero-terminated).
* code style: use spaces around plusesDaniel Stenberg2017-09-111-2/+2
|
* code style: use spaces around equals signsDaniel Stenberg2017-09-111-3/+3
|
* mime: drop internal FILE * support.Patrick Monnerat2017-09-061-2/+10
| | | | | | | | - The part kind MIMEKIND_FILE and associated code are suppressed. - Seek data origin offset not used anymore: suppressed. - MIMEKIND_NAMEDFILE renamed MIMEKIND_FILE; associated fields/functions renamed accordingly. - Curl_getformdata() processes stdin via a callback.
* mime: unified to use the typedef'd mime structs everywhereDaniel Stenberg2017-09-051-5/+5
| | | | ... and slightly edited to follow our code style better.
* mime: remove support "-" stdin pseudo-file name in curl_mime_filedata().Patrick Monnerat2017-09-031-1/+4
| | | | | | | | | | | | | | | This feature is badly supported in Windows: as a replacement, a caller has to use curl_mime_data_cb() with fread, fseek and possibly fclose callbacks to process opened files. The cli tool and documentation are updated accordingly. The feature is however kept internally for form API compatibility, with the known caveats it always had. As a side effect, stdin size is not determined by the cli tool even if possible and this results in a chunked transfer encoding. Test 173 is updated accordingly.
* mime: new MIME API.Patrick Monnerat2017-09-021-739/+106
| | | | | | | Available in HTTP, SMTP and IMAP. Deprecates the FORM API. See CURLOPT_MIMEPOST. Lib code and associated documentation.
* formdata: fix -Wcomma warningMarcel Raad2017-05-111-1/+1
| | | | | | | clang 5.0 complains: possible misuse of comma operator here [-Wcomma] Change the comma to a semicolon to fix that.
* formboundary: convert assert into run-time checkDaniel Stenberg2017-05-091-1/+2
| | | | | | | | | ... to really make sure the boundary fits in the target buffer. Fixes unused parameter 'buflen' warning. Reported-by: Michael Kaufmann Bug: https://github.com/curl/curl/pull/1468#issuecomment-300078754
* rand: treat fake entropy the same regardless of endiannessJay Satiro2017-05-081-24/+15
| | | | | | | | | | | | | | | | | When the random seed is purposely made predictable for testing purposes by using the CURL_ENTROPY environment variable, process that data in an endian agnostic way so the the initial random seed is the same regardless of endianness. - Change Curl_rand to write to a char array instead of int array. - Add Curl_rand_hex to write random hex characters to a buffer. Fixes #1315 Closes #1468 Co-authored-by: Daniel Stenberg Reported-by: Michael Kaufmann
* lib: remove unused codeMarcel Raad2017-04-261-3/+0
| | | | | | | | This fixes the following clang warnings: macro is not used [-Wunused-macros] will never be executed [-Wunreachable-code] Closes https://github.com/curl/curl/pull/1448
* Improve code readbilitySylvestre Ledru2017-03-131-58/+55
| | | | | | ... by removing the else branch after a return, break or continue. Closes #1310
* build: fix gcc7 implicit fallthrough warningsAlexis La Goutte2017-03-031-0/+1
| | | | | | | Mark intended fallthroughs with /* FALLTHROUGH */ so that gcc will know it's expected and won't warn on [-Wimplicit-fallthrough=]. Closes https://github.com/curl/curl/pull/1297
* formdata: check for EOF when reading from stdinDaniel Stenberg2017-02-231-2/+2
| | | | | | Reported-by: shachaf@users.noreply.github.com Fixes #1281
* formdata: use NULL, not 0, when returning pointersDaniel Stenberg2016-12-251-1/+1
|
* checksrc: warn for assignments within if() expressionsDaniel Stenberg2016-12-141-6/+6
| | | | | ... they're already frowned upon in our source code style guide, this now enforces the rule harder.
* checksrc: stricter no-space-before-paren enforcementDaniel Stenberg2016-12-131-2/+2
| | | | In order to make the code style more uniform everywhere
* checksrc: move open braces to comply with function declaration styleDaniel Stenberg2016-11-241-1/+2
|
* checksrc: code style: use 'char *name' styleDaniel Stenberg2016-11-241-9/+9
|
* Curl_rand: fixed and moved to rand.cDaniel Stenberg2016-11-141-2/+7
| | | | | | | | | | | | | Now Curl_rand() is made to fail if it cannot get the necessary random level. Changed the proto of Curl_rand() slightly to provide a number of ints at once. Moved out from vtls, since it isn't a TLS function and vtls provides Curl_ssl_random() for this to use. Discussion: https://curl.haxx.se/mail/lib-2016-11/0119.html
* strcasecompare: is the new name for strequal()Daniel Stenberg2016-10-311-6/+6
| | | | | | | ... to make it less likely that we forget that the function actually does case insentive compares. Also replaced several invokes of the function with a plain strcmp when case sensitivity is not an issue (like comparing with "-").
* formpost: avoid silent snprintf() truncationDaniel Stenberg2016-10-081-10/+25
| | | | | | | | | | The previous use of snprintf() could make libcurl silently truncate some input data and not report that back on overly large input, which could make data get sent over the network in a bad format. Example: $ curl --form 'a=b' -H "Content-Type: $(perl -e 'print "A"x4100')"
* formpost: trying to attach a directory no longer crashesDaniel Stenberg2016-10-041-7/+8
| | | | | | | | The error path would previously add a freed entry to the linked list. Reported-by: Toby Peterson Fixes #1053