Follow-up on the docx2txt workaround in the patch. The shell injection in docx2txt that the patch works around was reported as #1152844 and is fixed in docx2txt 1.4-6, uploaded to unstable on 2026-11-02. bullseye, bookworm, trixie and forky still have 1.4-5, so lesspipe keeps the workaround: it gives docx2txt a symlink with a fixed name in a mktemp -d directory.
The attached updated patch only changes the comment and commit message to reference #1152844 and the fixed version, so the workaround can be dropped once 1.4-5 is no longer in a supported release. The code is unchanged. Thanks, Koyo Keiter
From acb883b218e88442aa2ef023888812cd65dabe8e Mon Sep 17 00:00:00 2001 From: CyberKoyo <[email protected]> Date: Mon, 2 Nov 2026 00:41:35 -0500 Subject: [PATCH] lesspipe: add .docx and OpenDocument (.odt/.ods/.odp) support Use docx2txt and odt2txt when installed, following the existing catdoc/pdftotext pattern. docx2txt before 1.4-6 (#1152844) runs unzip through a shell with the filename inside double quotes, so a name containing $(...) or backticks would be executed. Hand it a symlink with a fixed name in a mktemp -d directory instead. It is given '-' so it writes to stdout rather than creating infile.txt next to the viewed file, and a failure is reported instead of showing nothing. odt2txt is given --width=-1 so lines are not re-wrapped at 65 columns. --- debian/lesspipe | 16 ++++++++++++++++ debian/lesspipe.1 | 2 ++ 2 files changed, 18 insertions(+) diff --git a/debian/lesspipe b/debian/lesspipe index 57ef4f1..1c93dcb 100644 --- a/debian/lesspipe +++ b/debian/lesspipe @@ -127,6 +127,18 @@ if [ $# -eq 1 ] ; then fi ;; + *.docx) + if [ -x "`which docx2txt`" ]; then + # docx2txt < 1.4-6 passes the filename to a shell (#1152844), so give it a fixed safe one + d=$(mktemp -d) && ln -s "$(readlink -f -- "$1")" "$d/f.docx" || exit + docx2txt "$d/f.docx" -; rc=$? + rm -rf "$d" + [ $rc -eq 0 ] || echo "docx2txt failed on $1" + else + echo "No docx2txt available" + fi + ;; + *.egg) if [ -x "`which unzip`" ]; then unzip -p "$1" EGG-INFO/PKG-INFO | \ @@ -196,6 +208,10 @@ if [ $# -eq 1 ] ; then fi ;; + *.odt|*.ods|*.odp) + if [ -x "`which odt2txt`" ]; then odt2txt --width=-1 "$1" + else echo "No odt2txt available"; fi ;; + *.pdf) if [ -x "`which pdftotext`" ]; then pdftotext -layout "$1" - else echo "No pdftotext available"; fi ;; diff --git a/debian/lesspipe.1 b/debian/lesspipe.1 index 8e842ef..6142b71 100644 --- a/debian/lesspipe.1 +++ b/debian/lesspipe.1 @@ -68,6 +68,7 @@ This is a list of currently supported extensions *.bz2 *.deb, *.udeb, *.ddeb *.doc + *.docx *.egg *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif *.iso, *.raw, *.bin @@ -75,6 +76,7 @@ This is a list of currently supported extensions *.tar.lz, *.tlz *.lz *.7z + *.odt, *.ods, *.odp *.pdf *.rar, *.r[0-9][0-9] *.rpm -- 2.43.0

