Bad MbzRequestSearch results when query contains special characters
Problem
When using MbzRequestSearch with a query containing special characters such as &, the search seems to be of lesser quality than it should.
After debugging the code, it seems to be because of this line:
- The URL passed to the
requests.getis created by simply doingurl + request - However, if the query (contained in
request) contains a special URL character (like&), it will not be interpreted as the query but as a "new section" of the URL
Solution
The first solution would be to call urllib.parse.quote on the query before it is put into the URL.
The better solution would be to pass the requests parameters using the params parameter of requests.get, which is the proper and secure way of sending them.
- This would apply for
MbzRequestSearchobviously, but it would also be best to use this forMbzRequestBrowse