Bug 255232 - print/texlive-base: pdfjam regex issue at runtime on 13.0 and newer
Summary: print/texlive-base: pdfjam regex issue at runtime on 13.0 and newer
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Hiroki Sato
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-19 17:24 UTC by Gordon
Modified: 2022-01-17 21:21 UTC (History)
6 users (show)

See Also:


Attachments
patch to fix regex problem with sed (1.34 KB, patch)
2021-05-07 07:32 UTC, Rainer Hurling
rhurlin: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon 2021-04-19 17:24:01 UTC

    
Comment 1 Gordon 2021-04-19 17:32:12 UTC
FreeBSD 13 changed the way sed and grep operate.

From the release notes:

"The regex(3) function no longer accepts redundant escapes for most ordinary characters. This will cause applications such as sed(1) and grep(1) to reject regular expressions using these escapes. adeebf4cd47c"

The pdfjam script from the texlive port no longer operates as intended.

The sed directive from the pdfjam script throws an error:

pdfjam "input.pdf" 1-20 -o output.pdf
sed: 1: "/\\\usepackage{hyperref}/d": RE error: trailing backslash (\)
sed: 1: "/\\\hypersetup.*/d": RE error: trailing backslash (\)
sed: 1: "/\\\usepackage.*{geomet ...": RE error: trailing backslash (\)
sed: 1: "/\\\usepackage.*{color}/d": RE error: trailing backslash (\)

This is probably an easy fix, although I am not knowledgeable enough to know where to start.  I believe this only affects FreeBSD 13 and later releases.
Comment 2 Steve Wills freebsd_committer freebsd_triage 2021-04-19 17:47:38 UTC
Re-open
Comment 3 Steve Wills freebsd_committer freebsd_triage 2021-04-19 17:48:10 UTC
Assign to maintainer
Comment 4 Rainer Hurling freebsd_committer freebsd_triage 2021-05-07 07:32:25 UTC
Created attachment 224744 [details]
patch to fix regex problem with sed

With this small corrections (turning '\\\' into '\\' for LaTeX functions) the scripts seems to work again as expected.

Tested with some pdflatex generated pdf files.

What I did not test is, if this breaks the regex behaviour on systems < 13.0.
Comment 5 Gordon 2021-05-07 22:13:54 UTC
I tested this patch on 13.0 and 12.2, it appears to work.

There are a few lines associated with pdfinfo, that may cause errors on 13.0, I never checked these.

The lines are 1094, 1095, 1097, 1098, 1100, 1101, 1103, 1104.
Comment 6 Rainer Hurling freebsd_committer freebsd_triage 2021-05-08 05:52:56 UTC
(In reply to Gordon from comment #5)

Hi Gordon,

I think that unlike the lines changed in the patch, the lines 1094, 1095, 1097, 1098, 1100, 1101, 1103, 1104 are not supposed to escape LaTeX functions (LaTeX function names preceded by '\').

I have looked at several converted files containing pdftitle, pdfauthor, pdfsubject and pdfkeyword. This information remains included in the conversion and can also be overwritten with '--pdfauthor newauthor', for example.

To be on the safe side, maybe someone with more regex experience should look at it ;)
Comment 7 Gordon 2021-05-08 18:21:12 UTC
(In reply to Rainer Hurling from comment #6)

Everything looks in order.  Thank you for your patch.

It looks like Hiroki can review it and hopefully will include it in a future update.
Comment 8 me 2022-01-11 21:06:45 UTC
Please, could this be committed?

pdfjam is broken on FreeBSD 13.0-RELEASE.

This patch fixes the problem at least for simple use cases and I could not find more similar problems searching for triple backslash. (The other lines mentioned by Gordon seem to be fine.)
Comment 9 commit-hook freebsd_committer freebsd_triage 2022-01-17 21:07:28 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=56f9e4aaa7c55c7dae44e35c1f836ba10659dab5

commit 56f9e4aaa7c55c7dae44e35c1f836ba10659dab5
Author:     Rainer Hurling <rhurlin@FreeBSD.org>
AuthorDate: 2022-01-17 21:00:34 +0000
Commit:     Rainer Hurling <rhurlin@FreeBSD.org>
CommitDate: 2022-01-17 21:05:23 +0000

    print/texlive-base: Fix pdfjam regex issue

    On FreeBSD >= 13.0 the pdfjam script throws an error:

    pdfjam "input.pdf" 1-20 -o output.pdf
    sed: 1: "/\\\usepackage{hyperref}/d": RE error: trailing backslash (\)
    sed: 1: "/\\\hypersetup.*/d": RE error: trailing backslash (\)
    sed: 1: "/\\\usepackage.*{geomet ...": RE error: trailing backslash (\)
    sed: 1: "/\\\usepackage.*{color}/d": RE error: trailing backslash (\)

    While here, pet portfmt.

    PR:             255232
    Reported by:    Gordon <gordon.friedman@hotmail.com>
    MFH:            2022Q1

    Approved by:    Hiroki Sato <hrs@FreeBSD.org> (maintainer timeout)

 print/texlive-base/Makefile                        |  7 +++---
 ...exk_texlive_linked__scripts_pdfjam_pdfjam (new) | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2022-01-17 21:19:36 UTC
A commit in branch 2022Q1 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d6a68d239233231a7f0d5c8b40bf52d6610f342c

commit d6a68d239233231a7f0d5c8b40bf52d6610f342c
Author:     Rainer Hurling <rhurlin@FreeBSD.org>
AuthorDate: 2022-01-17 21:00:34 +0000
Commit:     Rainer Hurling <rhurlin@FreeBSD.org>
CommitDate: 2022-01-17 21:18:38 +0000

    print/texlive-base: Fix pdfjam regex issue

    On FreeBSD >= 13.0 the pdfjam script throws an error:

    pdfjam "input.pdf" 1-20 -o output.pdf
    sed: 1: "/\\\usepackage{hyperref}/d": RE error: trailing backslash (\)
    sed: 1: "/\\\hypersetup.*/d": RE error: trailing backslash (\)
    sed: 1: "/\\\usepackage.*{geomet ...": RE error: trailing backslash (\)
    sed: 1: "/\\\usepackage.*{color}/d": RE error: trailing backslash (\)

    While here, pet portfmt.

    PR:             255232
    Reported by:    Gordon <gordon.friedman@hotmail.com>
    MFH:            2022Q1

    Approved by:    Hiroki Sato <hrs@FreeBSD.org> (maintainer timeout)

    (cherry picked from commit 56f9e4aaa7c55c7dae44e35c1f836ba10659dab5)

 print/texlive-base/Makefile                        |  8 ++++---
 ...exk_texlive_linked__scripts_pdfjam_pdfjam (new) | 26 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)
Comment 11 Rainer Hurling freebsd_committer freebsd_triage 2022-01-17 21:21:22 UTC
Committed on main and 2022Q1 with maintainer timeout.
Thanks again, Gordon, for the report.