From 2a11ca13a3c88d94a35b06e5b9a13f359918d4c9 Mon Sep 17 00:00:00 2001
From: Junoh Moon <mjo970625@gmail.com>
Date: Fri, 19 May 2023 13:09:37 +0900
Subject: [PATCH] Add mime.types to docker container to select charset properly
 (#547)

* Add charset to content type in getHandler

Add charset to content type in the getHandler function to fix CJK-letter related issues.
If the content type is empty after trimming, set it to "text/plain; charset=utf-8".

* Add mailcap and mime.types to transfer.sh container

This commit includes /etc/mime.types file to the container, which is necessary to properly select the charset using MIME typing during file upload.

For more information, read https://github.com/dutchcoders/transfer.sh/pull/545#issuecomment-1528712181

---------

Co-authored-by: Andrea Spacca <andrea.spacca@gmail.com>
---
 Dockerfile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index ada4fc3d..1ac34cdd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,7 @@ ARG GO_VERSION=1.20
 FROM golang:${GO_VERSION}-alpine as build
 
 # Necessary to run 'go get' and to compile the linked binary
-RUN apk add git musl-dev
+RUN apk add git musl-dev mailcap
 
 ADD . /go/src/github.com/dutchcoders/transfer.sh
 
@@ -29,6 +29,7 @@ FROM scratch AS final
 LABEL maintainer="Andrea Spacca <andrea.spacca@gmail.com>"
 ARG RUNAS
 
+COPY --from=build /etc/mime.types /etc/mime.types
 COPY --from=build /tmp/empty /tmp
 COPY --from=build /tmp/useradd/* /etc/
 COPY --from=build --chown=${RUNAS}  /go/bin/transfersh /go/bin/transfersh
-- 
GitLab