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

MultipartFormData section doesn't accept some key-value pair #457

Closed
linjan opened this issue Jan 24, 2022 · 3 comments · Fixed by #458
Closed

MultipartFormData section doesn't accept some key-value pair #457

linjan opened this issue Jan 24, 2022 · 3 comments · Fixed by #458
Labels
bug Something isn't working
Milestone

Comments

@linjan
Copy link

linjan commented Jan 24, 2022

Hello,

Params in Multipart Form Data according to grammar of Hurl accepts key-value, with key-string in it, accepting = <(alphanum | "_" | "-" | "." | escape-char)+ >
By the way, there are cases, where key-string must contain brackets, like on the image:

image

I tried several ways to encode (\u005b\u005d), escape (\) characters, but no result.
So for instance, '[]' (ascii square brackets or box brackets) should be accepted by Hurl.

The following Hurl file should be valid:

POST http://test.stand/upload
# Content-Type: multipart/form-data; charset=utf-8
[MultipartFormData]
authenticity_token: abcdef0123456789
package[sender_type]: Other;
package[package]: file,request.zip; application/zip

Actually, Hurl raises an error:

❯ hurl -x http://test.stand/upload request.hurl
error: Parsing Method
  --> request.hurl:69:1
   |
69 | package[sender_type]: Other;
   | ^ The HTTP method is not valid. Available HTTP Methods are GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE or PATCH
   |
@fabricereix
Copy link
Collaborator

Hi @linjan,
Thanks for your detailed explanations.
You're right, Hurl should accept square bracket in key string.
We will add it for the next release.

@fabricereix
Copy link
Collaborator

Escaping can work as follows:
package[sender_type]: Other
written in the Hurl file as:
package\u{5b}sender_type\u{5d}: Other

@fabricereix
Copy link
Collaborator

We might add the reasonable restriction that the key-string does not start with a '['.
So that there is no ambiguities in the parsing with the section name.

For example

[FormParams]
x[Cookies] # parsed as a form param
[Cookies]  # parsed as Cookie section
[xxx]      # parsing error - invalid section name

@fabricereix fabricereix added this to the 1.6.0 milestone Jan 24, 2022
@jcamiel jcamiel added the bug Something isn't working label Jan 24, 2022
@fabricereix fabricereix linked a pull request Jan 24, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants