summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-05-05 22:18:52 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-05-05 22:18:52 -0400
commit5121ae7b4a0b97b9e227b67903d0c6c88f3a3982 (patch)
tree23d9e077755c86cb963d8df8743878b919b9ec3a
parent30bf40ab2b03600b66091a6cbd61515cf0721844 (diff)
downloadSMAPI-5121ae7b4a0b97b9e227b67903d0c6c88f3a3982.tar.gz
SMAPI-5121ae7b4a0b97b9e227b67903d0c6c88f3a3982.tar.bz2
SMAPI-5121ae7b4a0b97b9e227b67903d0c6c88f3a3982.zip
enforce mod ID convention (only alphanumeric, hyphen, dot, and underscore)
-rw-r--r--docs/release-notes.md7
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs8
2 files changed, 12 insertions, 3 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index d1a78aaa..e4ae720d 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -27,9 +27,10 @@
* Fixed console command input not saved to the log.
* Fixed `helper.ModRegistry.GetApi` interface validation errors not mentioning which interface caused the issue.
* **Breaking changes** (see [migration guide](https://stardewvalleywiki.com/Modding:Migrate_to_Stardew_Valley_1.3)):
- * dropped some deprecated APIs;
- * `LocationEvents` have been rewritten (see above);
- * mods can't intercept chatbox input, including the game's hotkeys to toggle the chatbox (default `T` and `?`).
+ * Dropped some deprecated APIs.
+ * `LocationEvents` have been rewritten (see above).
+ * Mods can't intercept chatbox input, including the game's hotkeys to toggle the chatbox (default `T` and `?`).
+ * Mod IDs should only contain letters, numbers, hyphens, dots, and underscores (so they can be safely used in many contexts like URLs); this restriction is now enforced.
* In console commands:
* Added `player_add name`, which lets you add items to your inventory by name instead of ID.
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs
index a9896278..cec37fca 100644
--- a/src/SMAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Text.RegularExpressions;
using StardewModdingAPI.Framework.Exceptions;
using StardewModdingAPI.Framework.ModData;
using StardewModdingAPI.Framework.Models;
@@ -194,8 +195,15 @@ namespace StardewModdingAPI.Framework.ModLoading
missingFields.Add(nameof(IManifest.UniqueID));
if (missingFields.Any())
+ {
mod.SetStatus(ModMetadataStatus.Failed, $"its manifest is missing required fields ({string.Join(", ", missingFields)}).");
+ continue;
+ }
}
+
+ // validate ID format
+ if (Regex.IsMatch(mod.Manifest.UniqueID, "[^a-z0-9_.-]", RegexOptions.IgnoreCase))
+ mod.SetStatus(ModMetadataStatus.Failed, "its manifest specifies an invalid ID (IDs must only contain letters, numbers, underscores, periods, or hyphens).");
}
// validate IDs are unique