Refactor Dockerfile and Dockerfile.Staging to streamline package installations; enhance PictureService for safer SEO filename handling

This commit is contained in:
warrenchen 2025-12-10 18:00:11 +09:00
parent b894a94133
commit 048b160d04
3 changed files with 14 additions and 8 deletions

View File

@ -50,9 +50,8 @@ RUN apk add --no-cache icu-libs icu-data-full
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
# installs required packages
RUN apk add tiff --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/main/ --allow-untrusted
RUN apk add libgdiplus --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ --allow-untrusted
RUN apk add libc-dev tzdata --no-cache
RUN apk add --no-cache tiff libc-dev tzdata
RUN apk add --no-cache libgdiplus --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted
# copy entrypoint script
COPY ./entrypoint.sh /entrypoint.sh

View File

@ -50,9 +50,8 @@ RUN apk add --no-cache icu-libs icu-data-full
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
# installs required packages
RUN apk add tiff --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/main/ --allow-untrusted
RUN apk add libgdiplus --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ --allow-untrusted
RUN apk add libc-dev tzdata --no-cache
RUN apk add --no-cache tiff libc-dev tzdata
RUN apk add --no-cache libgdiplus --repository https://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted
# copy entrypoint script
COPY ./entrypoint.sh /entrypoint.sh

View File

@ -11,6 +11,7 @@ using Nop.Services.Logging;
using Nop.Services.Seo;
using SkiaSharp;
using Svg.Skia;
using System.IO;
namespace Nop.Services.Media;
@ -597,7 +598,14 @@ public partial class PictureService : IPictureService
false);
}
var seoFileName = picture.SeoFilename; // = GetPictureSeName(picture.SeoFilename); //just for sure
var seoFileName = picture.SeoFilename;
if (!string.IsNullOrEmpty(seoFileName))
{
// ensure seo filename is safe for filesystem (especially on Windows)
seoFileName = await GetPictureSeNameAsync(seoFileName);
var invalidChars = Path.GetInvalidFileNameChars();
seoFileName = string.Concat(seoFileName.Split(invalidChars, StringSplitOptions.RemoveEmptyEntries));
}
var lastPart = await GetFileExtensionFromMimeTypeAsync(picture.MimeType);