@@ -1017,14 +1017,17 @@ procedure TFormTrackerModify.CheckedOnOffAllTrackers(Value: boolean);
10171017
10181018function TFormTrackerModify.CopyUserInputNewTrackersToList : boolean;
10191019var
1020- TrackerStrLoop, TrackerStr: UTF8String;
1020+ TrackerStrLoop, TrackerStr, ErrorStr : UTF8String;
10211021begin
10221022 {
10231023 Called after 'update torrent' is selected.
10241024 All the user entery from Memo text field will be add to FTrackerList.TrackerAddedByUserList.
10251025 }
10261026 FTrackerList.TrackerAddedByUserList.Clear;
10271027
1028+ // Will set to false when error is detected
1029+ Result := True;
1030+
10281031 for TrackerStrLoop in MemoNewTrackers.Lines do
10291032 begin
10301033 TrackerStr := UTF8trim(TrackerStrLoop);
@@ -1033,36 +1036,48 @@ function TFormTrackerModify.CopyUserInputNewTrackersToList: boolean;
10331036 if TrackerStr = ' ' then
10341037 continue;
10351038
1039+ // All the tracker must end with '/announce'
1040+ Result := TrackerURLWithAnnounce(TrackerStr);
1041+ if not Result then
1042+ begin
1043+ ErrorStr := ' ERROR: Tracker URL must end with /announce' ;
1044+ // do not continue the for loop
1045+ break;
1046+ end ;
1047+
10361048 // All the tracker must begin with 'http(s)://' or 'udp://'
1037- if ValidTrackerURL(TrackerStr) then
1049+ Result := ValidTrackerURL(TrackerStr);
1050+ if Result then
10381051 begin
10391052 AddButIngnoreDuplicates(FTrackerList.TrackerAddedByUserList, TrackerStr);
10401053 end
10411054 else
10421055 begin
1043- // There is error. Show the error and do not continue.
1044- if FConcoleMode then
1045- begin
1046- FTrackerList.LogStringList.Add(
1047- ' ERROR: Tracker URL must begin with http:// or udp://' );
1048- end
1049- else
1050- begin
1051- // Show error
1052- Application.MessageBox(PChar(@TrackerStr[1 ]),
1053- ' Error: Tracker URL must begin with http(s):// or udp://' , MB_ICONERROR);
1054- end ;
1055- // do not continue with error.
1056- Result := False;
1057- exit;
1056+ ErrorStr := ' ERROR: Tracker URL must begin with http:// or udp://' ;
1057+ // do not continue the for loop
1058+ break;
10581059 end ;
10591060
1060- end ;
1061-
1062- Result := True; // no error
1061+ end ;// for loop
10631062
1064- // Show the torrent list we have just created.
1065- MemoNewTrackers.Text := FTrackerList.TrackerAddedByUserList.Text;
1063+ if Result then
1064+ begin
1065+ // Show the torrent list we have just created.
1066+ MemoNewTrackers.Text := FTrackerList.TrackerAddedByUserList.Text;
1067+ end
1068+ else
1069+ begin
1070+ // There is error. Show the error.
1071+ if FConcoleMode then
1072+ begin
1073+ FTrackerList.LogStringList.Add(ErrorStr);
1074+ end
1075+ else
1076+ begin
1077+ // Show error
1078+ Application.MessageBox(PChar(@TrackerStr[1 ]), PChar(@ErrorStr[1 ]), MB_ICONERROR);
1079+ end ;
1080+ end ;
10661081
10671082end ;
10681083
0 commit comments