From 5eed6c65f688aa5dda1c45143837f4f0f886fff4 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Wed, 4 Nov 2020 21:32:07 -0500 Subject: [PATCH] Validate the repository id for the init and add command Only letter, numbers, dashes, and underscores are allowed. --- duplicacy/duplicacy_main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/duplicacy/duplicacy_main.go b/duplicacy/duplicacy_main.go index 61a43c8a..b7cd559b 100644 --- a/duplicacy/duplicacy_main.go +++ b/duplicacy/duplicacy_main.go @@ -274,6 +274,13 @@ func configRepository(context *cli.Context, init bool) { } } + snapshotIDRegex := regexp.MustCompile(`^[A-Za-z0-9_\-]+$`) + matched := snapshotIDRegex.FindStringSubmatch(snapshotID) + if matched == nil { + duplicacy.LOG_ERROR("PREFERENCE_INVALID", "'%s' is an invalid snapshot id", snapshotID) + return + } + var repository string var err error