summaryrefslogtreecommitdiff
path: root/lib/mime.c
Commit message (Collapse)AuthorAgeFilesLines
* checksrc: find bad indentation in conditions without open braceDaniel Stenberg2023-04-281-2/+2
| | | | | | | | | | | If the previous line starts with if/while/for AND ends with a closed parenthesis and there's an equal number of open and closed parentheses on that line, verify that this line is indented $indent more steps, if not a cpp line. Also adjust the fall-out from this fix. Closes #11054
* mime: skip NULL assigns after Curl_safefree()Daniel Stenberg2023-04-131-4/+0
| | | | | | | Pointed out by PVS. Ref: #10929 Closes #10947
* 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-18/+14
| | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | 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
* lib: sanitize conditional exclusion around MIMEPatrick Monnerat2022-09-291-4/+5
| | | | | | | | | | | | | | | The introduction of CURL_DISABLE_MIME came with some additional bugs: - Disabled MIME is compiled-in anyway if SMTP and/or IMAP is enabled. - CURLOPT_MIMEPOST, CURLOPT_MIME_OPTIONS and CURLOPT_HTTPHEADER are conditioned on HTTP, although also needed for SMTP and IMAP MIME mail uploads. In addition, the CURLOPT_HTTPHEADER and --header documentation does not mention their use for MIME mail. This commit fixes the problems above. Closes #9610
* 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 exclamation marksDaniel Stenberg2022-04-161-1/+1
| | | | | | ... from infof() and failf() calls. Make them less attention seeking. Closes #8713
* mime: use a define instead of the magic number 24Daniel Stenberg2022-02-131-2/+3
| | | | | | | MIME_BOUNDARY_DASHES is now the number of leading dashes in the generated boundary string. Closes #8441
* mime: some more strlen() call removals.Patrick Monnerat2022-02-131-26/+29
| | | | Closes #8423
* lib: remove support for CURL_DOES_CONVERSIONSDaniel Stenberg2022-02-041-62/+1
| | | | | | TPF was the only user and support for that was dropped. Closes #8378
* mime: use percent-escaping for multipart form field and file namesPatrick Monnerat2021-11-151-20/+44
| | | | | | | | | | | | | | | | | | Until now, form field and file names where escaped using the backslash-escaping algorithm defined for multipart mails. This commit replaces this with the percent-escaping method for URLs. As this may introduce incompatibilities with server-side applications, a new libcurl option CURLOPT_MIME_OPTIONS with bitmask CURLMIMEOPT_FORMESCAPE is introduced to revert to legacy use of backslash-escaping. This is controlled by new cli tool option --form-escape. New tests and documentation are provided for this feature. Reported by: Ryan Sleevi Fixes #7789 Closes #7805
* mime: mention CURL_DISABLE_MIME in commentErik Stenlund2021-10-201-1/+2
| | | | | | | CURL_DISABLE_MIME is not mentioned in the comment describing the if else preprocessor directive. Closes #7882
* lib: avoid fallthrough cases in switch statementsDaniel Gustafsson2021-09-291-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit b5a434f7f0ee4d64857f8592eced5b9007d83620 inhibits the warning on implicit fallthrough cases, since the current coding of indicating fallthrough with comments is falling out of fashion with new compilers. This attempts to make the issue smaller by rewriting fallthroughs to no longer fallthrough, via either breaking the cases or turning switch statements into if statements. lib/content_encoding.c: the fallthrough codepath is simply copied into the case as it's a single line. lib/http_ntlm.c: the fallthrough case skips a state in the state- machine and fast-forwards to NTLMSTATE_LAST. Do this before the switch statement instead to set up the states that we actually want. lib/http_proxy.c: the fallthrough is just falling into exiting the switch statement which can be done easily enough in the case. lib/mime.c: switch statement rewritten as if statement. lib/pop3.c: the fallthrough case skips to the next state in the statemachine, do this explicitly instead. lib/urlapi.c: switch statement rewritten as if statement. lib/vssh/wolfssh.c: the fallthrough cases fast-forwards the state machine, do this by running another iteration of the switch statement instead. lib/vtls/gtls.c: switch statement rewritten as if statement. lib/vtls/nss.c: the fallthrough codepath is simply copied into the case as it's a single line. Also twiddle a comment to not be inside a non-brace if statement. Closes: #7322 See-also: #7295 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
* tidy-up: make conditional checks more consistentDaniel Stenberg2021-04-221-2/+2
| | | | | | ... remove '== NULL' and '!= 0' Closes #6912
* mime: make sure setting MIMEPOST to NULL resets properlyDaniel Stenberg2021-01-151-1/+2
| | | | | | | | | | | | ... so that a function can first use MIMEPOST and then set it to NULL to reset it back to a blank POST. Added test 584 to verify the fix. Reported-by: Christoph M. Becker Fixes #6455 Closes #6456
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* terminology: call them null-terminated stringsDaniel Stenberg2020-06-281-1/+1
| | | | | | | | | | | 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
* socks: remove unreachable breaks in socks.c and mime.cxquery2020-06-081-1/+0
| | | | Closes #5537
* source cleanup: remove all custom typedef structsDaniel Stenberg2020-05-151-12/+13
| | | | | | | | | | | - 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
* checksrc: enhance the ASTERISKSPACE and update code accordinglyDaniel Stenberg2020-05-141-1/+1
| | | | | | | | Fine: "struct hello *world" Not fine: "struct hello* world" (and variations) Closes #5386
* mime: properly check Content-Type even if it has parametersPatrick Monnerat2020-04-191-2/+19
| | | | | | | | New test 669 checks this fix is effective. Fixes #5256 Closes #5258 Reported-by: thanhchungbtc on github
* mime: fix the binary encoder to handle large data properlyPatrick Monnerat2020-03-071-1/+1
| | | | | | | | | | New test 666 checks this is effective. As upload buffer size is significant in this kind of tests, shorten it in similar test 652. Fixes #4860 Closes #4833 Reported-by: RuurdBeerstra on github
* mime: do not perform more than one read in a rowPatrick Monnerat2020-03-071-49/+147
| | | | | | | | | | | | | | | | | | | | | Input buffer filling may delay the data sending if data reads are slow. To overcome this problem, file and callback data reads do not accumulate in buffer anymore. All other data (memory data and mime framing) are considered as fast and still concatenated in buffer. As this may highly impact performance in terms of data overhead, an early end of part data check is added to spare a read call. When encoding a part's data, an encoder may require more bytes than made available by a single read. In this case, the above rule does not apply and reads are performed until the encoder is able to deliver some data. Tests 643, 644, 645, 650 and 654 have been adapted to the output data changes, with test data size reduced to avoid the boredom of long lists of 1-byte chunks in verification data. New test 667 checks mimepost using single-byte read callback with encoder. New test 668 checks the end of part data early detection. Fixes #4826 Reported-by: MrdUkk on github
* mime: latch last read callback status.Patrick Monnerat2020-03-071-3/+36
| | | | | | | | | | | | | 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-37/+4
| | | | | | | | This reverts commit 87869e38d7afdec3ef1bb4965711458b088e254f. Fixes #5014 Closes #5015 Reopens #4833
* Revert "mime: do not perform more than one read in a row"Daniel Stenberg2020-03-021-147/+49
| | | | This reverts commit ed0f357f7d25566110d4302f33759f4ffb5a6f83.
* Revert "mime: fix the binary encoder to handle large data properly"Daniel Stenberg2020-03-021-1/+1
| | | | This reverts commit b2caaa0681f329eed317ffb6ae6927f4a539f0c1.
* mime: fix the binary encoder to handle large data properlyPatrick Monnerat2020-03-021-1/+1
| | | | | | | | | New test 666 checks this is effective. As upload buffer size is significant in this kind of tests, shorten it in similar test 652. Fixes #4860 Reported-by: RuurdBeerstra on github
* mime: do not perform more than one read in a rowPatrick Monnerat2020-03-021-49/+147
| | | | | | | | | | | | | | | | | | | | | Input buffer filling may delay the data sending if data reads are slow. To overcome this problem, file and callback data reads do not accumulate in buffer anymore. All other data (memory data and mime framing) are considered as fast and still concatenated in buffer. As this may highly impact performance in terms of data overhead, an early end of part data check is added to spare a read call. When encoding a part's data, an encoder may require more bytes than made available by a single read. In this case, the above rule does not apply and reads are performed until the encoder is able to deliver some data. Tests 643, 644, 645, 650 and 654 have been adapted to the output data changes, with test data size reduced to avoid the boredom of long lists of 1-byte chunks in verification data. New test 664 checks mimepost using single-byte read callback with encoder. New test 665 checks the end of part data early detection. Fixes #4826 Reported-by: MrdUkk on github
* mime: latch last read callback status.Patrick Monnerat2020-03-021-4/+37
| | | | | | | | | | | | | | 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: make Curl_mime_duppart() assert if called without valid dstDaniel Stenberg2019-09-201-6/+6
| | | | | Fixes warning detected by PVS-Studio Fixes #4374
* mime: when disabled, avoid C99 macroDaniel Stenberg2019-09-181-0/+7
| | | | Closes #4368
* mime: acknowledge CURL_DISABLE_MIMEDaniel Stenberg2019-05-131-71/+3
|
* build: fix "clarify calculation precedence" warningsMarcel Raad2019-05-121-2/+4
| | | | | | | 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
* mime: put the boundary buffer into the curl_mime structDaniel Stenberg2019-02-121-12/+2
| | | | | | | ... instead of allocating it separately and point to it. It is fixed-size and always used for each part. Closes #3561
* mime: check Curl_rand_hex's return codeDaniel Stenberg2018-07-281-2/+7
| | | | | | Bug: https://curl.haxx.se/mail/archive-2018-07/0015.html Reported-by: Jeffrey Walton Closes #2795
* cppcheck: fix warningsMarian Klymov2018-06-111-21/+11
| | | | | | | | | | | | | - 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-6/+6
| | | | | | ... and unify the source code to adhere. Closes #2563
* mime: avoid NULL pointer dereference riskDaniel Stenberg2018-04-241-1/+1
| | | | | | Coverity detected, CID 1435120 Closes #2527
* build: add picky compiler warning flags for gcc 6 and 7Eric Gallager2018-04-071-1/+4
|
* cleanup: misc typos in strings and commentsluz.paz2018-03-161-1/+1
| | | | | | Found via `codespell` Closes #2389
* formdata: use the mime-content type functionDaniel Stenberg2018-02-051-9/+4
| | | | | | | | | | 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: clone mime tree upon easy handle duplication.Patrick Monnerat2018-01-141-1/+80
| | | | | | | | | | | | | | | | | | | | | A mime tree attached to an easy handle using CURLOPT_MIMEPOST is strongly bound to the handle: there is a pointer to the easy handle in each item of the mime tree and following the parent pointer list of mime items ends in a dummy part stored within the handle. Because of this binding, a mime tree cannot be shared between different easy handles, thus it needs to be cloned upon easy handle duplication. There is no way for the caller to get the duplicated mime tree handle: it is then set to be automatically destroyed upon freeing the new easy handle. New test 654 checks proper mime structure duplication/release. Add a warning note in curl_mime_data_cb() documentation about sharing user data between duplicated handles. Closes #2235
* mime: fix "Value stored to 'sz' is never read" scan-build errorDaniel Stenberg2017-11-211-2/+0
|
* mime: do not reuse previously computed multipart sizePatrick Monnerat2017-10-201-1/+1
| | | | | | | The contents might have changed: size must be recomputed. Reported-by: moteus on github Fixes #1999
* mime: limit bas64-encoded lines length to 76 charactersPatrick Monnerat2017-10-191-2/+2
|
* mime: do not call failf() if easy handle is NULL.Patrick Monnerat2017-10-131-1/+2
|
* mime: fix the content reader to handle >16K data properlyDaniel Stenberg2017-10-131-2/+1
| | | | | Reported-by: Jeroen Ooms Closes #1988