From 98ea0d57c3dd966d2559aeffb8d560aff7c6d31e Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Thu, 30 May 2024 23:22:29 +0300 Subject: [PATCH] Fixed env variable injection --- src/BUTR.NexusUploader/Commands/UploadCommand.cs | 12 +++++++++++- src/BUTR.NexusUploader/Services/ManageClient.cs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/BUTR.NexusUploader/Commands/UploadCommand.cs b/src/BUTR.NexusUploader/Commands/UploadCommand.cs index 2dc43c7..1446a06 100644 --- a/src/BUTR.NexusUploader/Commands/UploadCommand.cs +++ b/src/BUTR.NexusUploader/Commands/UploadCommand.cs @@ -14,7 +14,7 @@ using System.ComponentModel; using System.IO; using System.Threading.Tasks; - +using Microsoft.Extensions.Configuration; using FileOptions = BUTR.NexusUploader.Models.FileOptions; namespace BUTR.NexusUploader.Commands; @@ -127,6 +127,13 @@ public override async Task ExecuteAsync(CommandContext context, Settings se public class Settings : CommandSettings { + private readonly IConfiguration _configuration; + + public Settings(IConfiguration configuration) + { + _configuration = configuration; + } + [CommandArgument(0, "")] [Description("The NexusMods mod Id to upload the file to.")] public int ModId { get; set; } = 0; @@ -187,6 +194,9 @@ public class Settings : CommandSettings public override ValidationResult Validate() { + FileDescription = _configuration.GetValue("FILEDESCRIPTION", FileDescription) ?? string.Empty; + PreviousFile = _configuration.GetValue("PREVIOUSFILE", PreviousFile) ?? string.Empty; + if (!AreSettingsValid()) { return ValidationResult.Error("Not all required settings provided!"); diff --git a/src/BUTR.NexusUploader/Services/ManageClient.cs b/src/BUTR.NexusUploader/Services/ManageClient.cs index 6237ef8..ac968e3 100644 --- a/src/BUTR.NexusUploader/Services/ManageClient.cs +++ b/src/BUTR.NexusUploader/Services/ManageClient.cs @@ -70,7 +70,7 @@ public async Task AddFile(GameRef game, int modId, UploadedFile upload, Fi { using var message = new HttpRequestMessage(HttpMethod.Post, "/Core/Libs/Common/Managers/Mods?AddFile"); message.Headers.Add("X-Requested-With", "XMLHttpRequest"); - message.Headers.Add("Referer", $"https://www.nexusmods.com/{game.Name}/mods/edit/?step=docs&id={modId}"); + message.Headers.Add("Referer", $"https://www.nexusmods.com/{game.Name}/mods/edit/?step=files&id={modId}&game_id={game.Id}"); using var content = new MultipartFormDataContent(); content.Add(game.Id.ToContent(), "game_id"); content.Add(options.Name.ToContent(), "name");