Skip to content

Commit

Permalink
Validate the repository id for the init and add command
Browse files Browse the repository at this point in the history
Only letter, numbers, dashes, and underscores are allowed.
  • Loading branch information
gilbertchen committed Nov 5, 2020
1 parent bec3a0e commit 5eed6c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions duplicacy/duplicacy_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

2 comments on commit 5eed6c6

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/init-accepts-invalid-snapshot-ids/4418/2

@gilbertchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Duplicacy Forum. There might be relevant details there:

https://forum.duplicacy.com/t/cli-2-7-2-is-now-available/4483/1

Please sign in to comment.