mirror of
https://github.com/Pathoschild/SMAPI.git
synced 2026-10-12 02:08:51 +00:00
fix server error if a JSON file contains nested comments
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* Reduced response times with a new analysis cache and client-side fetch.
|
||||
* Removed support for very old SMAPI logs.
|
||||
* You can now download a JSON representation of the parsed log (see the download link at the bottom of the log page).
|
||||
* Fixed server error if a JSON file contains nested comment syntax.
|
||||
* Third-party libraries are now served from `smapi.io` instead of external CDNs.
|
||||
|
||||
## 4.2.1
|
||||
|
||||
@@ -110,9 +110,19 @@ internal class JsonValidatorController : Controller
|
||||
}
|
||||
|
||||
// format JSON
|
||||
string formatted = parsed.ToString(Formatting.Indented);
|
||||
result.SetContent(formatted, oldExpiry: file.OldExpiry, newExpiry: file.NewExpiry, uploadWarning: file.Warning);
|
||||
parsed = JToken.Parse(formatted); // update line number references
|
||||
try
|
||||
{
|
||||
string formatted = parsed.ToString(Formatting.Indented);
|
||||
result.SetContent(formatted, oldExpiry: file.OldExpiry, newExpiry: file.NewExpiry, uploadWarning: file.Warning);
|
||||
parsed = JToken.Parse(formatted); // update line number references
|
||||
}
|
||||
catch
|
||||
{
|
||||
// In rare cases, Json.NET will convert valid JSON to invalid JSON. For example,
|
||||
// it will change `// remove /* */` to /*remove /* */*/` so it can't be parsed
|
||||
// anymore. If that happens, just keep the JSON as-is; at worst line numbers will
|
||||
// be slightly off if there are schema errors.
|
||||
}
|
||||
}
|
||||
|
||||
// skip if no schema selected
|
||||
|
||||
Reference in New Issue
Block a user