0

I have a simple flask application with one endpoint

@app.route('/', methods=['GET', 'POST'])
def index():
  if request.method == 'GET':
    return render_template('form.html')
  return request.form['a']

the form.html looks like this:

<!DOCTYPE html>
<form method="POST">
  <input type="text" name="a" value="öäü"><br>
  <input type="submit" value="submit">
</form>

when I open the form in firefox i can enter values like äöü send the POST-request end receive the correct response äöü.

However, when I simply try to send the POST-request using curl like this:

curl http://localhost -F "a=öäü"

I get the cryptic response:

´┐¢´┐¢´┐¢

I also tried the solution from How do I POST form data with UTF-8 encoding by using curl?

curl -v -X POST -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" --data-ascii "a=äöü" http://localhost

but i still get the same result. I am using curl on a Windows 7 with codepage 850

Any help how to even debug this behavior is deeply appreciated

jan-seins
  • 1,253
  • 1
  • 18
  • 31

2 Answers2

0

You can urlencode the data:

curl http://localhost -F "a%3D%C3%B6%C3%A4%C3%BC"

To do it automatically curl has the --data-urlencode flag.

max
  • 677
  • 1
  • 9
  • 34
  • `--data-urlencode` gives the same output as `-F`. `curl http://localhost -F "a%3D%C3%B6%C3%A4%C3%BC"` gives the output `Warning: Illegally formatted input field!` `curl: option -F: is badly used here` – jan-seins Nov 29 '18 at 07:30
  • Based on your solution I tried it this way: `curl -v -X POST -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" --data-raw "a=%C3%B6%C3%A4%C3%BC" http://localhost` which works fine. However i am still stuggeling how to generate the string `%C3%B6%C3%A4%C3%BC` from `äöü` – jan-seins Nov 29 '18 at 10:05
0

I not windows pc, it's not confirm, you can try curl -X POST -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" --data-urlencode "a=öäü" http://localhost

Jun
  • 21
  • 2