Article View: linux.debian.bugs.dist
Article #2958Bug#1152840: lesspipe: add .docx and OpenDocument (.odt/.ods/.odp) support
From: Koyo Keiter
Date: Mon, 02 Nov 2026 07:10
Date: Mon, 02 Nov 2026 07:10
150 lines
6522 bytes
6522 bytes
This is a multi-part MIME message sent by reportbug. --===============2028045530226529324== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Package: less Version: 668-1 Severity: wishlist Tags: patch Dear Maintainer, lesspipe handles .doc (catdoc) and .pdf (pdftotext), but .docx and OpenDocument files currently fall through to the raw zip. The attached patch adds: *.docx -> docx2txt (package docx2txt) *.odt, *.ods, *.odp -> odt2txt (package odt2txt) It follows the existing pattern: the converter is used when installed, otherwise a one-line "No ... available" message is shown. lesspipe.1 lists the new extensions. Two details: - docx2txt 1.4 runs unzip through a shell with the filename inside double quotes, so passing a hostile name such as 'x"; touch PWNED; ".docx' directly executes the embedded command (verified). The patch instead hands docx2txt a symlink with a fixed name inside a mktemp -d directory, and passes '-' so the text goes to stdout rather than to an infile.txt created next to the viewed file. A docx2txt failure is reported instead of showing nothing. - odt2txt is given --width=-1 so lines are not re-wrapped at 65 columns. Tested with docx2txt 1.4-5 and odt2txt 0.5-7build1, in both lesspipe and lessfile modes and through less via LESSOPEN/LESSCLOSE: a real .docx (output byte-identical to running docx2txt directly), synthetic .odt/.ods/.odp files, uppercase extensions, names containing spaces, quotes and a leading '-', and a corrupt .docx. The patch is git format-patch output against master on salsa and applies with git am. -- System Information: Debian Release: trixie/sid APT prefers noble-updates APT policy: (500, 'noble-updates'), (500, 'noble-security'), (500, 'noble'), (100, 'noble-backports') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 7.0.0-42-generic (SMP w/8 CPU threads; PREEMPT) Kernel taint flags: TAINT_USER Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled --===============2028045530226529324== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-lesspipe-add-.docx-and-OpenDocument-.odt-.ods-.odp-s.patch" From 817dd96dfc60ffda9c0e8aa4eb49d58371a794a7 Mon Sep 17 00:00:00 2001 From: CyberKoyo <koyo.keiter@gmail.com> 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 1.4 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..e64358d 100644 --- a/debian/lesspipe +++ b/debian/lesspipe @@ -127,6 +127,18 @@ if [ $# -eq 1 ] ; then fi ;; + *.docx) + if [ -x "`which docx2txt`" ]; then + # docx2txt passes the filename to a shell, 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 --===============2028045530226529324==--
Technical Details
Message-ID:
<NUUl3-9mv6-1@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod From: Koyo Keiter <koyo.keiter@gmail.com> Newsgroups: linux.debian.bugs.dist Subject: Bug#1152840: lesspipe: add .docx and OpenDocument (.odt/.ods/.odp) support Date: Mon, 02 Nov 2026 08:10:01 +0100 Message-ID: <NUUl3-9mv6-1@gated-at.bofh.it> X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Mon Nov 2 07:03:12 2026 Old-Return-Path: <debbugs@buxtehude.debian.org> X-Spam-Flag: NO X-Spam-Score: 1.126 Reply-To: Koyo Keiter <koyo.keiter@gmail.com>, 1152840@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: milan@debian.org X-Debian-Pr-Message: report 1152840 X-Debian-Pr-Package: less X-Debian-Pr-Keywords: patch X-Debian-Pr-Source: less Content-Type: multipart/mixed; boundary="===============2028045530226529324==" MIME-Version: 1.0 X-Mailer: reportbug 13.0.1+ubuntu1 X-Debian-Message: from BTS X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2000187 List-ID: <debian-bugs-dist.lists.debian.org> List-URL: <https://lists.debian.org/debian-bugs-dist/> Approved: robomod@news.nic.it Lines: 150 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Mon, 02 Nov 2026 02:01:44 -0500 X-Original-Message-ID: <179360288951.162871.4689656113727074020.reportbug@Gotham>