fedarovich / qbittorrent-net-client

qBittorrent client library for .Net
MIT License
32 stars 14 forks source link

Incorrect Handling of Tracker URLs in DeleteTrackers Method #25

Open GaZzNL opened 8 months ago

GaZzNL commented 8 months ago

I was unable to remove trackers from torrent. The DeleteTrackers method repository has a bug related to the handling of tracker URLs. The issue arises when constructing the request content for deletion of trackers. Current code:

public override (Uri url, HttpContent request) DeleteTrackers(string hash, IEnumerable<Uri> trackerUrls)
{
    return BuildForm(Url.DeleteTrackers(),
        ("hash", hash),
        ("urls", string.Join("|", trackerUrls.Select(u => u.AbsoluteUri))));
}

Fixed code:

public override (Uri url, HttpContent request) DeleteTrackers(string hash, IEnumerable<Uri> trackerUrls)
{
    return BuildForm(Url.DeleteTrackers(),
        ("hash", hash),
        ("urls", string.Join("|", trackerUrls.Select(u => u.OriginalString))));
}

The original code incorrectly uses u.AbsoluteUri when constructing the "urls" parameter. This results in the removal of the port number from the tracker URLs, potentially causing issues in scenarios where the port number is significant.