KIO bug: http proxy usage might spoil request query
Review Request #130040 - Created March 21, 2017 and submitted
I've been adjusting KTorrent 5.x for my needs and found out its HTTP Proxy feature doesn't work. I've workarounded this. The problem is desribben in review 130037. Btw, I think at least KIO documentation might be blamed for this so you might take a look into it too. It's about "UseProxy" and "ProxyUrls" metadata.
When KTorrent's HTTP proxy had stated to work I realized that some of my trackers gets
wrong info_hasherror replies from trackers. While everything is fine if I switch proxy off or with other torrents. I've tried some 3rd party http proxy instead of my machine's tor+privoxy - same result. Then I debug it and digged down to a problem in kio itself.
The torrent requests following URL from announce tracker:
http://bt4.t-ru.org/ann?peer_id=-KT50DV-KBXFxAWAVRPZ&port=6881&uploaded=0&downloaded=0&left=0&compact=1&numwant=200&key=1041295926&event=started&info_hash=%3F%B3j%14%E6%A4%8D%E7%EC%60%B4%D2%24%CD%B2%21%A46Gawhere last param is encoded SHA1 hash.
And in proxy log I saw it as
%CD%B2at the end. That's because
QUrl::PrettyDecodedby default which is
returned in a "pretty form", with most percent-encoded characters decoded. The exact behavior of PrettyDecoded varies from component to component and may also change from Qt release to Qt release.Note variable behaviour. I'm building projects with Qt 5.7.1 which is Kubuntu 17.04 defaut. For some reason it believes it should decode "%B2" etc. to my locale char that later is replaced with '?' as there is no such char in ASCII. To workaround this
QUrl::toString()must be called with
QUrl::FullyEncoded. KTorrent has own URL encoder that convert all non-ASCII chars to %XX beforehand then passes to KIO.
Unfortunately there is one place there KIO forgets to apply this string format parameter. Here it is. I fixed it and tested - KTorrent works fine with that and all torrent trackers ae able to understand torrent SHA hash passed throw HTTP proxy.
P.S. I'm new on KDE and don't know who is the right reviewer for KIO. And there is no KIO group. Feel free to addd the right person.