summaryrefslogtreecommitdiffstats
path: root/attach.c
AgeCommit message (Collapse)Author
2021-05-01Add sanitize call in print mailcap function.Kevin McCarthy
The mutt_rfc1524_expand_filename() function calls mutt_adv_mktemp(), which also calls the sanitizer. However, if the recv-mode suggested filename has a slash, it's better to sanitize before calling expand_filename() too, to preserve the entire filename (albeit with the slashes sanitized out). For example (ignoring name templates) if the file were called "either/or.pdf", pre-sanitizing would generate "either_or.pdf", while not doing so would generate "or.pdf".
2021-05-01Add allow_8bit flag to sanitize_filename functions.Kevin McCarthy
This will allow "view" mailcap invocations and autoview invocations to display something reasonable for international file names. Also add the flag to mutt_adv_mktemp(), which the mailcap viewer calls. Convert the 'slash parameter' to an ALLOW_SLASH flag. This makes the flags consistent (both "allow" something not permitted by default), and invocations more readable.
2020-11-22Add <view-pager> function to attachment menu.Kevin McCarthy
This uses a copiousoutput mailcap entry, or falls back to raw text. The existing functions do not provide a way to use copiousoutput mailcap entries exclusively. The default <view-attach> will use one for internally supported types if auto_view is configured, but there is no way to do so for other mime types (such as application/pdf).
2020-07-10Fix mutt_print_attachment_list() to unstuff format=flowed.Kevin McCarthy
Several of the cases are covered by the pipe fixes in the last commit. The last case is similar to the mutt_view_attachment case. Since the send-mode file might be modified, change it to always save to a tempfile and then unstuff the tempfile.
2020-07-10Fix mutt_pipe_attachment_list() to unstuff format=flowed.Kevin McCarthy
The pipe routines are not used in other places (except printing attachments - to be handled next), so just directly modify them. Take care to space-stuff the filter output, since it replaces the space-stuffed compose part.
2020-07-10Fix mutt_view_attachment() to unstuff format=flowed.Kevin McCarthy
This is used in receive mode for <view-text> and <view-mailcap>. I don't think those are accessible from the compose menu, but the code allows it. So fix up the send-case too. Since we may need to unstuff the send-mode file, make a copy instead of symlinking. Also clean up the code to just sanitize the filename regardless.
2019-10-23Add typelen parameter to rfc1524_mailcap_lookup().Kevin McCarthy
Because of mime_lookup commands, the call to mutt_check_lookup_list() inside the function can modify the passed in type. Add an explicit length parameter to the function, rather than assume the parameter size. This also makes it more evident the type parameter can be modified to callers. Change the len parameter to mutt_check_lookup_list() to type size_t, just to be correct about it.
2019-09-13Convert query_pipe_attachment to use buffer pool.Kevin McCarthy
2019-06-22Add NULL checks to rfc1524_free_entry().Kevin McCarthy
The existing code was fine, but make it robust like other free functions in mutt, so the behavior isn't surprising.
2019-06-22Clean up mutt_print_attachment() cleanup.Kevin McCarthy
Check if mutt_save_attachment() fails and abort the print in that case.
2019-06-22Remove mutt_rfc1524_expand_filename() return value and checks.Kevin McCarthy
The return value was of dubious value. It returned 0 only for the case that a nametemplate was specified and it already matched the supplied oldfile. However, just because the nametemplate matched does not mean attachment handling in send-mode should skip the mutt_adv_mktemp() conversion, which includes a call to mutt_sanitize_filename(). We didn't do so if *no* nametemplate was supplied. Remove the return value from the function, and remove the checks and "special handing" in attach.c calls.
2019-06-22Remove unnecessary strcmp for mutt_view_attachment().Kevin McCarthy
mutt_rfc1524_expand_filename() runs the result through mutt_adv_mktemp(), which will sanitize and relocate the filename under $tmpdir. The strcmp() is unneeded and distracting to the program logic; none of the other routines perform or need this check.
2019-06-22Fix compose and edit attachment symlink failure code.Kevin McCarthy
In the case where safe_symlink() fail, mutt prompts to continue, but did not properly reset the filename to be operated on. Fix up mutt_view_attachment() to use the same flow as the others, to allow for easier comparison.
2019-06-22Fix send-mode printing when expand_filename() returns 1.Kevin McCarthy
It will return this when a nametemplate entry already matched the passed in filename. So this bug required both a print entry and an already matching nametemplate entry to trigger.
2019-04-14Rename mutt_buffer_rfc1524_expand_command()Kevin McCarthy
Remove buffer prefix now that all callers are converted.
2019-04-14Rename mutt_buffer_adv_mktemp().Kevin McCarthy
Remove buffer prefix since all callers now use this version.
2019-04-10Rename to mutt_rfc1524_expand_filename().Kevin McCarthy
Now that all callers pass a BUFFER, the buffer prefix is not needed to distinguish the parameter.
2019-01-05Fix a few indenting issues.Kevin McCarthy
These are mostly the result of making the formatting changes commit after the indent changes commit.
2019-01-04Clean up formatting.Kevin McCarthy
Add spaces after if, else, while, for, switch. Unify the brace placement style. The vast majority of the code uses Allman style so convert the relatively few K&R braces over.
2019-01-04Clean up code indentation.Kevin McCarthy
These are mostly automated changes corresponding to the emacs settings: (c-set-style "linux") (setq c-basic-offset 2) (c-set-offset 'case-label '+) Most of the code follows the convention: (add-to-list 'c-cleanup-list 'space-before-funcall) but this is not enforced by this indentation cleanup. Also, I personally dislike tabs, so I have: (setq-default indent-tabs-mode nil) in my own configuration. However I have no desire to change every line just for that effect. So this cleanup does nothing about the mix issue. Some of the secondary files (e.g. regex.c) have been skipped. I've also skipped crypt-gpgme.c, because I need to think about that file. Werner Koch and the GnuPG team contributed most it, and it follows the Gnu indentation settings. It should probably be made uniform with Mutt, but I don't want to discourage future GnuPG contribution to the file. I manually reverted a few unsightly cleanups, and added a few tweeks when I saw things that could be improved.
2018-12-31Remove trailing whitespace.Kevin McCarthy
The result of find . -name "*.[ch]" -exec emacs -batch {} \ --eval="(progn (delete-trailing-whitespace) (and (buffer-modified-p) (save-buffer)))" \;
2018-10-16Minor syntactic cleanup in mutt_print_attachment().Kevin McCarthy
Converting a return to a rc assignment accidentally left an extra parenthesis.
2018-10-15Convert mutt_print_attachment to use BUFFER.Kevin McCarthy
2018-10-15Convert mutt_view_attachment to use BUFFER.Kevin McCarthy
2018-10-15Convert mutt_edit_attachment to use BUFFER.Kevin McCarthy
2018-10-15Convert mutt_compose_attachment to use BUFFER.Kevin McCarthy
2018-10-15Convert mutt_get_tmp_attachment to use BUFFER.Kevin McCarthy
2018-09-17Send imap keepalives for interactive filters.Kevin McCarthy
When viewing attachments externally with a (non-copiousoutput) mailcap entry missing %s, the command is invoked as a filter, with the attachment piped into stdin. However, unlike a filter, the user interacts with the command, instead of just displaying the output in the pager. Just as with the mutt_system() command, Mutt needs to send imap keepalives to keep those connections from closing during the potentially extended invocation. Thanks to John Hawkinson for the bug report, and his suggested patch, which this commit is based upon.
2017-08-10Add virtual index to actx. (see #3728)Kevin McCarthy
The virtual index is modeled after the CONTEXT. Add a CURATTACH helper to reduce code verbosity. Store the actx as menu->data. Simplify and consolidate the recvattach and compose menu update code inside a function. Because compose and recvattach share so much code, change compose to use the virtual index even though it has no collapse/expand functionality.
2017-08-10Change recvattach to allow nested encryption. (see #3728)Kevin McCarthy
* Add a FP and BODY array to the actx. These are used to allow proper cleanup. * Add HEADER and root_fp entries, to allow for index regeneration. * Separate out the compose and recvattach index generation functions. * Change the recvattach index generator to decrypt as encrypted parts are found.
2017-08-10Add helpers to add and remove actx entries. (see #3728)Kevin McCarthy
Use the helper in compose update_idx(), to consolidate the resize logic and simplify the code. Separate out the actx "free" routine from a routine to empty out the idx. The index regeneration routines should flush and rebuild the index without having to renerate the actx structure.
2017-08-10Change helpers functions to pass actx. (see #3728)Kevin McCarthy
Change the pager, compose, recvattach and recvcmd to pass the actx instead of the individual idx and idxlen parameters. Separate out the compose menu exit logic to first free the BODY data and then call the shared actx free function at the bottom.
2017-08-10Create ATTACH_CONTEXT to hold attachment index. (see #3728)Kevin McCarthy
Move the idx and idxlen into ATTACH_CONTEXT. In subsequence patches, this structure will hold more useful items, such as the virtual index. The swap out is straightforward, except for: * update_idx() in compose.c, which post-increments the idxlen in the call and again in the function. * mutt_gen_attach_list() which doesn't need to returns the new values.
2016-10-23Perform charset conversion on text attachments when piping. (closes #3773) ↵Kevin McCarthy
(see #3886) When piping a text attachment, there is no reliable way to know the charset used. Vincent Lefèvre says: It was decided in the past that when there is no information on the charset in a transmission to an external command (e.g. as for mail composing), texts are expected to be transmitted in the local charset. Add a MUTT_CHARSET flag to enable charset conversion on text attachments for both when $attach_split is set and unset.
2016-06-18pass context in mx_close_messageDamien Riegel
The mx_close_message is one of the few mx_* functions that don't have a context as parameter. To make them more consistent, pass the context.
2016-05-09Change M_* symbols to MUTT_*Derek Martin
Changeset 23334e967dd7 created a workaround for a namespace conflict with Solaris and derivatives. After some discussion, the team decided it would be best to move away from using the "M_" prefix for macros. This patch was automatically generated by running: perl -wpi -e 's/\bM_(\w+)\b/MUTT_$1/g' `find . -name '*.[ch]' -print` with the exception that sys_socket.h was exempted. (That file will be backed out subsequent to this commit.) Thanks to Andras Salamon for supplying the perl script used to make this change.
2016-01-01Update copyright notices.Kevin McCarthy
This patch only updates existing copyright notices in the source files, using commit dates since the last copyright update in commits e3af935cdb1a and f8fd60d8d3f2. Add a notice to the COPYRIGHT file to refer to our mercurial repository for the full commit history. Add myself to the COPYRIGHT file and smime_keys.pl file.
2013-10-05Fix segfault when viewing text attachments in compose menu. (closes #3644)Kevin McCarthy
The segfault was introduced in changeset b9f9e3147eb4. Since decoding and charset conversion aren't needed for attachments when composing a message, this patch reverts to just using mutt_save_attachment() to view "raw data" for text attachments in the compose/send case. This patch is based on Michael Elkins' patch at http://dev.mutt.org/trac/attachment/ticket/3644/view_attach_compose_segfault with just a missing return value check added.
2013-01-17backout [392e945dfba7]Michael Elkins
closes #3293 see #3234
2013-01-17when falling back to viewing an attachment as text in the internal pager, ↵Michael Elkins
perform charset conversion this change is meant to replace [392e945dfba7] see #3234 see #3293
2013-01-17change semantics of mutt_is_autoview() to return 1 if there is a matching ↵Michael Elkins
mailcap entry and either $implicit_autoview is set or the MIME type matches the user's auto_view list. closes #3496 closes #3426
2010-04-01fix comment typosSimon Ruderich
2009-06-21Pass buffer size to mutt_mktemp()Rocco Rutte
2009-05-26Use charset parameter to view text attachments using <view-attach>. Closes ↵Rocco Rutte
#3234.
2009-05-25Mark strings for translationRocco Rutte
2009-05-13Don't loose error message when attachment saving fails. Closes #3156.Rocco Rutte
2009-04-17Enlarge buffer size for parsing mailcap filesRocco Rutte
We really need code for dynamic buffers which would solve a few other bugs, too. Closes #2205.
2009-03-15Use safe_fclose() instead of fclose(), add fclose() to check_sec.shRocco Rutte
2009-01-04Update copyrights. Closes #3016.Brendan Cully
I went through the logs of each file with a copyright header and updated the years for the authors in the headers for any non-comment changes they introduced. What a pain!
2008-06-11Do not attempt to close invalid descriptors. Closes #3075Alexey I. Froloff