Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory method FiltersSet.__create_filter does not accept non-string parameters #104

Open
ishurmer opened this issue Jan 22, 2021 · 0 comments · May be fixed by #113
Open

Factory method FiltersSet.__create_filter does not accept non-string parameters #104

ishurmer opened this issue Jan 22, 2021 · 0 comments · May be fixed by #113

Comments

@ishurmer
Copy link

I have been attempting to create a vacation filter using the add_to_filterset function, as per the following example. I have reduced the actual parameters for the purpose of this issue, but the error is still replicated:

    from sievelib import factory
    
    filter_set = factory.FiltersSet
    
    filter_set.addfilter(
        "test_autoresponder", [(
            "Subject", ":matches", "*"
        )], [(
            "vacation",
            ":subject", "Example Autoresponder Subject",
            ":days", 7,
            ":mime",
            "Example Autoresponder Body"
        )]
    )

This gives an AttributeError: AttributeError: 'int' object has no attribute 'startswith'

The offending code appears to be this line (https://github.com/tonioo/sievelib/blob/1.2.1/sievelib/factory.py#L260):

if arg.startswith(":"):

Obviously the startswith method is not present on Python integers. In addition, attempting to cast the int to a string results in a commands.BadValue Exception being raised.

Delving into the commands.py module, it is clear the VacationCommand definition is accepting a argument of type "number" (https://github.com/tonioo/sievelib/blob/1.2.1/sievelib/commands.py#L1026), which according to the above code reference, seems as if it can never be passed in via the factory.

I believe the factory.py method should be updated to check for numeric arguments, and pass in the appropriate "number" type via atype = "number".

I have only just started to use sievelib so please forgive any ignorance in this issue, but I would be happy to submit a pull request if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants