Anton Khirnov <[email protected]> writes:

> diff --git a/bindings/python-cffi/notmuch2/_build.py 
> b/bindings/python-cffi/notmuch2/_build.py
> index 2f3152c6..f918f96f 100644
> --- a/bindings/python-cffi/notmuch2/_build.py
> +++ b/bindings/python-cffi/notmuch2/_build.py
> @@ -328,6 +328,11 @@ ffibuilder.cdef(
>                                            notmuch_decryption_policy_t 
> decrypt_policy);
>      notmuch_decryption_policy_t
>      notmuch_indexopts_get_decrypt_policy (const notmuch_indexopts_t 
> *indexopts);
> +    notmuch_status_t
> +    notmuch_indexopts_set_filter (notmuch_indexopts_t *indexopts,
> +                                  const char *filter_cmd);
> +    const char *
> +    notmuch_indexopts_get_filter (const notmuch_indexopts_t *indexopts);
>      void
>      notmuch_indexopts_destroy (notmuch_indexopts_t *options);
>  
> diff --git a/bindings/python-cffi/notmuch2/_database.py 
> b/bindings/python-cffi/notmuch2/_database.py
> index ba389a42..78a43d72 100644
> --- a/bindings/python-cffi/notmuch2/_database.py
> +++ b/bindings/python-cffi/notmuch2/_database.py
> @@ -878,3 +878,24 @@ class IndexOptions(base.NotmuchObject):
>              self._opts_p, val.value)
>          if ret != capi.lib.NOTMUCH_STATUS_SUCCESS:
>              raise errors.NotmuchError(ret)
> +
> +    @property
> +    def filter_cmd(self):
> +        """Filtering program to extract text from non-text MIME parts.
> +
> +        CAUTION: improper use of this option may lead to remote code
> +        execution on the user's machine. See the `index.filter` section
> +        in :any:`notmuch-config(1)` for details. Make sure you read and
> +        understand it before setting this property.
> +
> +        The value is a string that is split in a shell-like manner and
> +        executed.
> +        """
> +        raw = capi.lib.notmuch_indexopts_get_filter(self._opts_p)
> +        return base.BinString.from_cffi(raw)
> +
> +    @filter_cmd.setter
> +    def filter_cmd(self, val):
> +        ret = capi.lib.notmuch_indexopts_set_filter(self._opts_p, val)
> +        if ret != capi.lib.NOTMUCH_STATUS_SUCCESS:
> +            raise errors.NotmuchError(ret)
> diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
> index 6a63e457..d2f80d19 100644

Although these are pretty simple, python being python, we
should at least exercise them with some simple tests. I didn't see any
tests for this in the remaining series. 

> +   The filter is a commandline split in a POSIX shell-like manner (without
> +   actually invoking the shell, so shell expansions are not performed and 
> shell
> +   constructs are not allowed) and executed. The payload of the MIME part to 
> be
> +   filtered will be supplied on its `stdin`, it is expected to write the text
> +   output to its `stdout`. The following environment variables will be set:
> +
> +   * NOTMUCH_FILTER_MIME_TYPE - the ``type/subtype`` part of the
> +     "content-type" header
> +   * NOTMUCH_FILTER_FILENAME - the file name associated with the attachment, 
> if
> +     present
> +   * NOTMUCH_FILTER_MESSAGE_ID - the message ID, without enclosing angle
> +     brackets <>

There is a sphinx "role" :envvar: used in various places in the docs
that might improve things here; if nothing else it would generate
anchors for people to link to.

_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to