erickok / transdroid-search

Cross-app torrent search results provider for Android
GNU Lesser General Public License v3.0
157 stars 55 forks source link

skytorrents.in broken #64

Closed Niluge-KiWi closed 7 years ago

Niluge-KiWi commented 7 years ago

Now the rss feed returns magnet links, but still with broken URL escaping on the torrent name part of the magnet URI (dn querystring value): magnet:?xt=urn:btih:8b774f03e001086aa9632db1b137bfee73fbca0c&dn=Metallica - Hardwired…To Self-Destruct (2016) MP3&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Feddie4.nl%3A6969&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969&tr=udp%3A%2F%2Fopentrack

URI constructor throws this exception:

java.net.URISyntaxException: Illegal character in scheme specific part at index 73: magnet:?xt=urn:btih:8b774f03e001086aa9632db1b137bfee73fbca0c&dn=Metallica - Hardwired…To Self-Destruct (2016) MP3&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Feddie4.nl%3A6969&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969&tr=udp%3A%2F%2Fopentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337

We previously had the same issue when the rss item link was a HTTP URL (https://github.com/erickok/transdroid-search/pull/58), I fixed it by exploiting the fact that java.net.URL accepts such invalid urls, and re-constructed a proper URI using java.net.URI, from the parsed URL. The URI constructor properly encoded the path part, assuming it was not encoded yet. However, now that the link is a magnet link URI, this workaround fails: the URL constructor rightly refuses the magnet protocol (it's not an URL): java.net.MalformedURLException: Unknown protocol: magnet

I'll try to contact the maintainer of skytorrents, because I don't know how to correct the URI without rewriting a URI parser + querystring parser, because we cannot just url-encode everything: the rest of the magnet querystring parameters would wrongly be encoded two times.

If anyone has another solution, PR are welcome !

Niluge-KiWi commented 7 years ago

skytorrents.in seems to have been fixing the dn escaping issue. Closing this issue.

However, the current transdroid-search code could be cleaned-up as the workaround form #58 is not needed anymore.