Skip to content

Commit 5eed6c6

Browse files
committed
Validate the repository id for the init and add command
Only letter, numbers, dashes, and underscores are allowed.
1 parent bec3a0e commit 5eed6c6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

duplicacy/duplicacy_main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ func configRepository(context *cli.Context, init bool) {
274274
}
275275
}
276276

277+
snapshotIDRegex := regexp.MustCompile(`^[A-Za-z0-9_\-]+$`)
278+
matched := snapshotIDRegex.FindStringSubmatch(snapshotID)
279+
if matched == nil {
280+
duplicacy.LOG_ERROR("PREFERENCE_INVALID", "'%s' is an invalid snapshot id", snapshotID)
281+
return
282+
}
283+
277284
var repository string
278285
var err error
279286

0 commit comments

Comments
 (0)