nja
nja

Reputation: 67

flask- Wrong URL encoding

I am facing very strange issue in Flask and flask-rest-jsonapi spec.

If I send below url using postman i am getting very weird behavior :-

Not working URL:-

http://127.0.0.1:5000/v1/recordings?filter=[
  {
    "name": "rtags",
    "op": "any",
    "val": {
      "name": "tag",
      "op": "ilike",
      "val": "%car%"
    }
  }
]

In encoded url ca is replaced by different characters %EF%BF%BD .

http://127.0.0.1:5000/v1/recordings?filter=%5B%0A++%7B%0A++++%22name%22%3A+%22rtags%22%2C%0A++++%22op%22%3A+%22any%22%2C%0A++++%22val%22%3A+%7B%0A++++++%22name%22%3A+%22tag%22%2C%0A++++++%22op%22%3A+%22ilike%22%2C%0A++++++%22val%22%3A+%22**%EF%BF%BD**r%25%22%0A++++%7D%0A++%7D%0A%5D

However if i send instead of car some different word like traffic then encoded url string is fine.

Working URL :-

http://127.0.0.1:5000/v1/recordings?filter=[
  {
    "name": "rtags",
    "op": "any",
    "val": {
      "name": "tag",
      "op": "ilike",
      "val": "%traffic%"
    }
  }
] 

e.g.

"http://127.0.0.1:5000/v1/recordings?filter=%5B%0A++%7B%0A++++%22name%22%3A+%22rtags%22%2C%0A++++%22op%22%3A+%22any%22%2C%0A++++%22val%22%3A+%7B%0A++++++%22name%22%3A+%22tag%22%2C%0A++++++%22op%22%3A+%22ilike%22%2C%0A++++++%22val%22%3A+%22%25**traffic**%25%22%0A++++%7D%0A++%7D%0A%5D"

Also if i put the breakpoint in app.py Flask file i get first two characters as capital "CAr" instead of "car" which i have send in query-string parameter.

<Request 'http://127.0.0.1:5000/v1/recordings?filter=%5B%0A%20%20%7B%0A%20%20%20%20%22name%22:%20%22rtags%22,%0A%20%20%20%20%22op%22:%20%22any%22,%0A%20%20%20%20%22val%22:%20%7B%0A%20%20%20%20%20%20%22name%22:%20%22tag%22,%0A%20%20%20%20%20%20%22op%22:%20%22ilike%22,%0A%20%20%20%20%20%20%22val%22:%20%22%CAr%25%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%5D' [GET]>}

Upvotes: 1

Views: 1244

Answers (0)

Related Questions