Skip to content

Commit ba07278

Browse files
Handle invalid server URLs and missing depend versions
1 parent 61004b1 commit ba07278

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Source/HedgeModManager/ModGeneric.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ public void Parse(Ini file)
9696
var server = mainSection.Get("UpdateServer", string.Empty);
9797
if (!string.IsNullOrEmpty(server))
9898
{
99-
Updater = new UpdateSourceGMI<ModGeneric>(this, new Uri(server));
99+
if (Uri.TryCreate(server, UriKind.RelativeOrAbsolute, out Uri? uri))
100+
{
101+
Updater = new UpdateSourceGMI<ModGeneric>(this, uri);
102+
}
103+
else
104+
{
105+
logError($"Invalid Update URI ({server})");
106+
}
100107
}
101108

102109
var codeFiles = mainSection.Get("CodeFile", string.Empty);
@@ -129,22 +136,21 @@ public void Parse(Ini file)
129136
foreach (var dependency in dependencies)
130137
{
131138
var splits = dependency.Split('|');
132-
if (splits.Length == 4)
139+
if (splits.Length >= 3)
133140
{
134141
Dependencies.Add(new ModDependency()
135142
{
136143
ID = splits[0],
137144
Title = splits[1],
138145
Url = splits[2],
139-
Version = splits[3]
146+
Version = splits.Length > 3 ? splits[3] : string.Empty
140147
});
141148
}
142149
else
143150
{
144-
logError($"Split count != 4 ({splits.Length})");
151+
logError($"Split count < 3 ({splits.Length})");
145152
}
146153
}
147-
148154
}
149155

150156
if (string.IsNullOrEmpty(ID))

0 commit comments

Comments
 (0)