Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Following - [this issue](qbittorrent/qBittorrent#22074) on the main qBittorrent repository - and the discussion on [this subsequent pull request](qbittorrent/qBittorrent#22075) Here is the fix for the piratebay search engine. A gist of the code is available [here](https://gist.github.com/biskweet/f06ff7b260ef1ce3a31d27ac1a9edcbf) for testing. ## Recalling the problem: API apibay.org returns weird JSON that causes the piratebay search engine to crash when handling its response. If some search results contain `"` (quotation marks) characters, the server escapes them by replacing `"` with `"` HTML entities in order to still provide a syntactically valid JSON response. While this is not incorrect, it would be best if apibay.org returned properly escaped quotes, i.e. using backslashes. When handling the response data, functions [`retrieve_url`](https://github.com/LightDestory/qBittorrent-Search-Plugins/blob/master/src/helpers.py#L75-L117) and [`htmlentitydecode`](https://github.com/LightDestory/qBittorrent-Search-Plugins/blob/master/src/helpers.py#L75-L117) blindly unescape all entities thereby corrupting previously valid JSON. As a consequence, `json.loads` crashes. For example: ```json { "title": "Ubuntu 22.04.5 LTS ("Jammy Jellyfish")" } ``` becomes ```json { "title": "Ubuntu 22.04.5 LTS ("Jammy Jellyfish")" } ``` ## Solution proposed We no longer use the `retrieve_url` function -- instead, I created a dedicated `retrieve_url` function (which is almost a copy-paste of the original) that fixes the problem by manually escaping quotes *before* escaping the rest of the data. PR #331.
- Loading branch information