summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md3
-rw-r--r--src/SMAPI.Web/Controllers/LogParserController.cs16
2 files changed, 14 insertions, 5 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 1734ca2d..5626dcc8 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -31,7 +31,8 @@
* Added log parser warning about performance of PyTK 1.23.0 or earlier.
* Converted images to SVG (thanks to ishan!).
* Updated log parser for new update alert format in SMAPI 3.15.1.
- * Fixed parsing for invalid content packs.
+ * Fixed log parsing for invalid content packs.
+ * Fixed log parsing if a mod logged a null character.
## 3.15.1
Released 06 July 2022 for Stardew Valley 1.5.6 or later.
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);