aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-07-17 19:42:45 +0200
committerGitHub <noreply@github.com>2023-07-17 19:42:45 +0200
commit605d7a137e94f5b86e45182c3709128ef57237ae (patch)
tree0e4ee273416b6ee26893dc1d211d144fcb00df4a /src-tauri
parent5d679ca8cdc2e79b6e6db7dd7ca2fc099da5a709 (diff)
downloadFlightCore-605d7a137e94f5b86e45182c3709128ef57237ae.tar.gz
FlightCore-605d7a137e94f5b86e45182c3709128ef57237ae.zip
fix: Add regex check for parsing TS mod string (#421)
Otherwise we accept improper formatted Thunderstore mod strings like `AUTHOR-MOD-VERSION-RANDOM_STUFF`
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/src/mod_management/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index 6c45a23b..afcead16 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -22,6 +22,12 @@ impl std::str::FromStr for ParsedThunderstoreModString {
type Err = &'static str; // todo use an better error management
fn from_str(s: &str) -> Result<Self, Self::Err> {
+ // Check whether Thunderstore string passse reges
+ let re = regex::Regex::new(r"^[a-zA-Z0-9_]+-[a-zA-Z0-9_]+-\d+\.\d+\.\d++$").unwrap();
+ if !re.is_match(s) {
+ return Err("Incorrect format");
+ }
+
let mut parts = s.split('-');
let author_name = parts.next().ok_or("None value on author_name")?.to_string();