_query_data(): Use urllib.parse.urlencode() instead of QUrl/QUrlQuery

Note: previously spaces weren't encoded, with this change they are (as plus) which is more conform to expected format for application/x-www-form-urlencoded
Actually this was a bug in previous version, as addQueryItem() didn't encode spaces as they should
See https://doc.qt.io/qt-5/qurlquery.html#addQueryItem
"This method does not treat spaces (ASCII 0x20) and plus ("+") signs as the same, like HTML forms do. If you need spaces to be represented as plus signs, use actual plus signs."

It wasn't an issue because none of passed data should contain spaces in our current code
This commit is contained in:
Laurent Monin
2022-01-06 14:41:09 +01:00
parent d1de2a7208
commit 8b787482ff
2 changed files with 3 additions and 13 deletions

View File

@@ -33,4 +33,4 @@ class OAuthManagerTest(PicardTestCase):
'': '',
}
data = OAuthManager._query_data(params)
self.assertEqual(data, "a%26b=a b&c d=c%26d")
self.assertEqual(data, "a%26b=a+b&c+d=c%26d")