summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-08-16 22:03:22 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-08-16 22:03:22 -0400
commitc51a593e93ba4d7e41971ed64cfa413449d501e3 (patch)
tree0cbdfc6fcd0044ad99ca51e1fe30381b79c25db0 /src/SMAPI.Web
parentf23cd450a0cca3ede1dacb198b4dd6432a44bf16 (diff)
downloadSMAPI-c51a593e93ba4d7e41971ed64cfa413449d501e3.tar.gz
SMAPI-c51a593e93ba4d7e41971ed64cfa413449d501e3.tar.bz2
SMAPI-c51a593e93ba4d7e41971ed64cfa413449d501e3.zip
fix log parser error if a mod logged a null character
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r--src/SMAPI.Web/Controllers/LogParserController.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs
index 33af5a81..a3bcf4c3 100644
--- a/src/SMAPI.Web/Controllers/LogParserController.cs
+++ b/src/SMAPI.Web/Controllers/LogParserController.cs
@@ -1,7 +1,9 @@
using System;
-using System.Linq;
+using System.Collections.Specialized;
+using System.IO;
using System.Text;
using System.Threading.Tasks;
+using System.Web;
using Microsoft.AspNetCore.Mvc;
using StardewModdingAPI.Toolkit.Utilities;
using StardewModdingAPI.Web.Framework;
@@ -87,9 +89,15 @@ namespace StardewModdingAPI.Web.Controllers
public async Task<ActionResult> PostAsync()
{
// get raw log text
- string? input = this.Request.Form["input"].FirstOrDefault();
- if (string.IsNullOrWhiteSpace(input))
- return this.View("Index", this.GetModel(null, uploadError: "The log file seems to be empty."));
+ // note: avoid this.Request.Form, which fails if any mod logged a null character.
+ string? input;
+ {
+ using StreamReader reader = new StreamReader(this.Request.Body);
+ NameValueCollection parsed = HttpUtility.ParseQueryString(await reader.ReadToEndAsync());
+ input = parsed["input"];
+ if (string.IsNullOrWhiteSpace(input))
+ return this.View("Index", this.GetModel(null, uploadError: "The log file seems to be empty."));
+ }
// upload log
UploadResult uploadResult = await this.Storage.SaveAsync(input);