Skip to content

Submitting forms with .requestSubmit() results in missing action handler #710

@dploeger

Description

@dploeger

I have the (probably niche) problem, that I'm using keeweb connect (think keepass connect, but for keeweb) for Firefox, which submits login forms using the .requestSubmit() method on the form without a parameter. This will submit the form using the form object. But as Iommi is dispatching actions based on the name of the specific button, this will lead to a error about a missing handler.

Looking into the source, I could provide a fix like this in part.py, line 149:

        dispatch_commands = {key: value for key, value in items(req_data) if key.startswith(dispatch_prefix)}
        assert len(dispatch_commands) in (0, 1), 'You can only have one or no dispatch commands'
        if request.method == 'POST' and len(dispatch_commands) == 0:
            # No dispatch commands found for POST request. Try to add -submit dispatch
            dispatch_commands = {"-submit": ""}

This will add a dispatcher based on the (probably existing) default submit button if a POST request is intercepted without any dispatch commands.

I haven't yet submitted a PR for this because I'd like to ask you if this actually makes sense to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions