Skip to content

POST body value will become variable name if -form #114

@sgohl

Description

@sgohl

I use both -cgi and -form as a receiver for a bitbucket webhook (i can't control the format of the payload) and I'm hardwired to both options - I know with -cgi only, the payload would come as stdin, but i really need both (file uploads, etc)

To reproduce, try the example from #79

Run shell2http container:

docker run -it --rm -p 80:80 msoap/shell2http -port 80 -no-index -show-errors -export-all-vars -form -cgi -include-stderr -500 / 'env | grep ^v'

Send payload:

curl -X POST -d '{"id":123}' localhost/
v_{"id":123}=

as you see, the json payload is not the value of the variable as expected, but the variable name itself.
This could be prevented by modifying the post payload to a named one, like -d 'test={"id":123}'
but for payloads you can not control, you can't address the payload

To fix that, the payload should also not be transformed into a variable with a not fixed name depending on the content of the payload, rather than a fixed variable name for the actual raw body payload.

Perhaps there's a way to fix this while not making this a breaking change by checking if the resulting variable name would be $v_ ?

so instead of this

v_{"id":123}=

it should look like this.

v_={"id":123}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions