#1152840 lesspipe: add .docx and OpenDocument (.odt/.ods/.odp) support

Package:
less
Source:
less
Description:
pager program similar to more
Submitter:
Koyo Keiter
Date:
2026-11-02 07:03:02 UTC
Severity:
normal
Tags:
#1152840#5
Date:
2026-11-02 07:01:44 UTC
From:
To:
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.