KIO bug: http proxy usage might spoil request query

Review Request #130040 - Created March 21, 2017 and submitted

Alexander Trufanov
cullmann, dfaure

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_hash error 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: where last param is encoded SHA1 hash.

And in proxy log I saw it as Note ? instead of %CD%B2 at the end. That's because QUrl conversion to QString uses QUrl::PrettyDecoded by 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.

Alexander Trufanov
David Faure
Alexander Trufanov
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit c3fd249e578318effe97fa7b6820134e5da443b2 by Alexander Trufanov to branch master.