HtmlAgilityPack interprets a string to Load() as a path apparently

This commit is contained in:
barelyprofessional
2025-07-22 23:01:33 -05:00
parent 58f101bc61
commit 9462048a29

View File

@@ -87,7 +87,7 @@ public class KfTokenService
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync(_ctx); var content = await response.Content.ReadAsStringAsync(_ctx);
var document = new HtmlDocument(); var document = new HtmlDocument();
document.Load(content); document.LoadHtml(content);
var challengeData = document.DocumentNode.SelectSingleNode("//html[@id=\"sssg\"]"); var challengeData = document.DocumentNode.SelectSingleNode("//html[@id=\"sssg\"]");
if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation && challengeData != null) if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation && challengeData != null)
{ {
@@ -100,7 +100,7 @@ public class KfTokenService
public async Task<bool> IsLoggedIn() public async Task<bool> IsLoggedIn()
{ {
var document = new HtmlDocument(); var document = new HtmlDocument();
document.Load(await GetLoginPage()); document.LoadHtml(await GetLoginPage());
var html = document.DocumentNode.SelectSingleNode("//html"); var html = document.DocumentNode.SelectSingleNode("//html");
if (html == null) throw new Exception("Caught a null when retrieving html element"); if (html == null) throw new Exception("Caught a null when retrieving html element");
if (!html.Attributes.Contains("data-logged-in")) if (!html.Attributes.Contains("data-logged-in"))