From: Paul Hänsch Date: Tue, 5 Mar 2024 00:42:07 +0000 (+0100) Subject: use temp files when unzipping documents X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=092bfad64ae6b2022991f6193f042d6d53bf10c2;p=rigidfind use temp files when unzipping documents --- diff --git a/index.cgi b/index.cgi index 9ba696a..0078a2f 100755 --- a/index.cgi +++ b/index.cgi @@ -9,7 +9,7 @@ debug "$REQUEST_METHOD $REQUEST_URI $SERVER_PROTOCOL $_DATE" ingest() { - local J="$1" + local J="$1" ztmp="${TMP:-/tmp}/zipfile_$$.zip" # json_get "$J" title # json_get "$J" parts.comments @@ -39,24 +39,28 @@ ingest() { | sed 's;<[^>]*>;;g' ;; *.docx) - printf %s "$content" |base64 -d \ - | unzip -qc /dev/stdin word/document.xml \ + printf %s "$content" |base64 -d >"$ztmp" + unzip -qc "$ztmp" word/document.xml \ | head -c 128M | sed 's;<[^>]*>;;g' + rm -- "$ztmp" ;; *.xlsx) - printf %s "$content" |base64 -d \ - | unzip -qc /dev/stdin xl/sharedStrings.xml \ + printf %s "$content" |base64 -d >"$ztmp" + unzip -qc "$ztmp" xl/sharedStrings.xml \ | head -c 128M | sed 's;<[^>]*>; ;g' + rm -- "$ztmp" ;; *.odt) - printf %s "$content" |base64 -d \ - | unzip -qc /dev/stdin content.xml \ + printf %s "$content" |base64 -d >"$ztmp" + unzip -qc "$ztmp" content.xml \ | head -c 128M | sed 's;<[^>]*>;;g' + rm -- "$ztmp" ;; *.ods|*.odp) - printf %s "$content" |base64 -d \ - | unzip -qc /dev/stdin content.xml \ + printf %s "$content" |base64 -d >"$ztmp" + unzip -qc "$ztmp" content.xml \ | head -c 128M | sed 's;<[^>]*>; ;g' + rm -- "$ztmp" ;; *):;; esac