@@ -201,6 +201,7 @@ TFormTrackerModify = class(TForm)
201201 FTreeNodeRoot: TTreeNode;
202202 FControlerGridTorrentData: TControlerGridTorrentData;
203203
204+ procedure SanatizeTrackerList (StringList:TStringList);
204205 procedure RemoveTrackersFromList (RemoveList, UpdatedList: TStringList);
205206 procedure UpdateTorrent ;
206207 procedure AddButIngnoreDuplicates (StringList: TStringList; const Str: UTF8String);
@@ -1391,6 +1392,9 @@ procedure TFormTrackerModify.LoadTrackersTextFileRemoveTrackers;
13911392 except
13921393 FFilePresentBanByUserList := False;
13931394 end ;
1395+
1396+ SanatizeTrackerList(FTrackerBanByUserList);
1397+
13941398end ;
13951399
13961400
@@ -1471,6 +1475,7 @@ function TFormTrackerModify.ReadAddTrackerFileFromUser(
14711475 TrackerFileList := TStringList.Create;
14721476 try
14731477 TrackerFileList.LoadFromFile(FileName);
1478+ SanatizeTrackerList(TrackerFileList);
14741479 MemoNewTrackers.Text := UTF8Trim(TrackerFileList.Text);
14751480 Result := True;
14761481 except
@@ -2037,6 +2042,40 @@ procedure TFormTrackerModify.ShowHourGlassCursor(HourGlass: boolean);
20372042
20382043end ;
20392044
2045+ procedure TFormTrackerModify.SanatizeTrackerList (StringList: TStringList);
2046+ var
2047+ TrackerStr: UTF8String;
2048+ i: integer;
2049+ PositionSpace: PtrInt;
2050+ begin
2051+ // remove all empty space and comment after the URL
2052+
2053+ if StringList.Count > 0 then
2054+ begin
2055+ for i := 0 to StringList.Count - 1 do
2056+ begin
2057+ // process every line one by one
2058+ TrackerStr := StringList[i];
2059+
2060+ // remove empty spaces at the begin/end of line
2061+ TrackerStr := UTF8Trim(TrackerStr);
2062+
2063+ // find the first 'space' found in line
2064+ PositionSpace := UTF8Pos(' ' , TrackerStr);
2065+ if PositionSpace > 0 then
2066+ begin
2067+ // There is a 'space' found
2068+ // Remove everything after this 'space'
2069+ TrackerStr := UTF8LeftStr(TrackerStr, PositionSpace - 1 );
2070+ end ;
2071+
2072+ // write the modified string back
2073+ StringList[i] := TrackerStr;
2074+ end ;
2075+ end ;
2076+
2077+
2078+ end ;
20402079
20412080
20422081end .
0 commit comments