Skip to content

Commit afd25e9

Browse files
authored
Bad Launcher URI message (Suprcode#969)
1 parent 0e6dcd5 commit afd25e9

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

Client/Forms/AMain.cs

+25-11
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,23 @@ public byte[] Download(string fileName)
349349
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo);
350350
}
351351

352-
var task = Task.Run(() => client
353-
.GetAsync(new Uri(Settings.P_Host + Path.ChangeExtension(fileName, ".gz")), HttpCompletionOption.ResponseHeadersRead));
352+
string uriString = Settings.P_Host + Path.ChangeExtension(fileName, ".gz");
354353

355-
var response = task.Result;
356-
357-
using Stream sm = response.Content.ReadAsStream();
358-
using MemoryStream ms = new();
359-
sm.CopyTo(ms);
360-
byte[] data = ms.ToArray();
361-
return data;
354+
if (Uri.IsWellFormedUriString(uriString, UriKind.Absolute))
355+
{
356+
var task = Task.Run(() => client.GetAsync(new Uri(uriString), HttpCompletionOption.ResponseHeadersRead));
357+
var response = task.Result;
358+
using Stream sm = response.Content.ReadAsStream();
359+
using MemoryStream ms = new();
360+
sm.CopyTo(ms);
361+
byte[] data = ms.ToArray();
362+
return data;
363+
}
364+
else
365+
{
366+
MessageBox.Show(string.Format("Please Check Launcher HOST Setting is formatted correctly\nCan be caused by missing or extra slashes and spelling mistakes.\nThis error can be ignored if patching is not required."), "Bad HOST Format");
367+
return null;
368+
}
362369
}
363370
}
364371

@@ -414,8 +421,15 @@ private void AMain_Load(object sender, EventArgs e)
414421

415422
if (Settings.P_BrowserAddress != "")
416423
{
417-
Main_browser.NavigationCompleted += Main_browser_NavigationCompleted;
418-
Main_browser.Source = new Uri(Settings.P_BrowserAddress);
424+
if (Uri.IsWellFormedUriString(Settings.P_BrowserAddress, UriKind.Absolute))
425+
{
426+
Main_browser.NavigationCompleted += Main_browser_NavigationCompleted;
427+
Main_browser.Source = new Uri(Settings.P_BrowserAddress);
428+
}
429+
else
430+
{
431+
MessageBox.Show(string.Format("Please Check Launcher BROWSER Setting is formatted correctly.\nCan be caused by missing or extra slashes and spelling mistakes.\nThis error can be ignored."), "Bad BROWSER Format");
432+
}
419433
}
420434

421435
RepairOldFiles();

0 commit comments

Comments
 (0)