编码路径测试

Test_HIR_Net8
hang 2026-06-05 14:24:09 +08:00
parent c72f50c1f7
commit bddfc633f4
1 changed files with 7 additions and 4 deletions

View File

@ -56,6 +56,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Path = System.IO.Path;
namespace IRaCIS.Core.API.Controllers
@ -1300,6 +1301,8 @@ namespace IRaCIS.Core.API.Controllers
var data = await _readingImageTaskService.GetReadingReportAndImage(inCommand);
var abortToken = HttpContext.RequestAborted;
Log.Logger.Warning(data.ToJsonStr());
string SanitizePathSegment(string? value, string defaultValue)
{
var result = string.IsNullOrWhiteSpace(value) ? defaultValue : value.Trim();
@ -1311,7 +1314,7 @@ namespace IRaCIS.Core.API.Controllers
return string.IsNullOrWhiteSpace(result) ? defaultValue : result;
}
string GetEntryFileName(string? sourcePath, string defaultPrefix, int index)
string GetEntryFileName(string? sourcePath, string defaultPrefix, int index)
{
var fileName = Path.GetFileName(sourcePath ?? string.Empty);
if (string.IsNullOrWhiteSpace(fileName))
@ -1365,7 +1368,7 @@ namespace IRaCIS.Core.API.Controllers
var fileName = GetEntryFileName(reportUrl, "Report", existingEntryPaths.Count + 1);
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
await using (var source = await _oSSService.GetStreamFromOSSAsync(reportUrl))
await using (var source = await _oSSService.GetStreamFromOSSAsync(HttpUtility.UrlDecode(reportUrl)))
{
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
@ -1391,7 +1394,7 @@ namespace IRaCIS.Core.API.Controllers
var entryPath = BuildUniqueEntryPath(existingEntryPaths, folderName, fileName);
await using (var source = await _oSSService.GetStreamFromOSSAsync(imageUrl))
await using (var source = await _oSSService.GetStreamFromOSSAsync(HttpUtility.UrlDecode(imageUrl)))
{
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
@ -1400,7 +1403,7 @@ namespace IRaCIS.Core.API.Controllers
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
}
}
catch (Exception ex)
{