From ba1fb4f55e1941dca5b2b1bcc8981ef980b173e8 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 30 Mar 2021 21:39:26 -0700 Subject: [PATCH] Use submission list from base ref for duplicate URL check Previously, the duplicate URL check was configured to use the submission list at the head ref, where two ocurrences of the URL indicated a duplicate. A more secure approach is to use the submission list at the base ref, and this means that a single ocurrence of the URL indicates a duplicate. --- main.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index e7d123e..d5e6216 100644 --- a/main.go +++ b/main.go @@ -246,7 +246,6 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT // Check if the URL is already in the index. listLines, err := listPath.ReadFileAsLines() - occurrences := 0 for _, listURL := range listLines { listURLObject, err := url.Parse(strings.TrimSpace(listURL)) if err != nil { @@ -255,11 +254,8 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT normalizedListURLObject := normalizeURL(listURLObject) if normalizedListURLObject.String() == normalizedURLObject.String() { - occurrences++ - if occurrences > 1 { - submission.Error = "Submission URL is already in the Library Manager index." - return submission, "" - } + submission.Error = "Submission URL is already in the Library Manager index." + return submission, "" } }