From fc57b48eb864a6604f724a277e7c640ba0cf3cc6 Mon Sep 17 00:00:00 2001 From: Oliver Hofmann Date: Tue, 2 Jun 2026 21:03:13 +0200 Subject: [PATCH] fix: robustify EndSetup detection and add warning test --- filter/kyofilter | 2 +- tests/test_kyofilter.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/filter/kyofilter b/filter/kyofilter index 5045a7c..2fbb99d 100755 --- a/filter/kyofilter +++ b/filter/kyofilter @@ -34,7 +34,7 @@ def process_stream(lines, account_code): for line in lines: stripped = line.rstrip(b'\r\n') - if not injected and (stripped == b'%%EndSetup' or stripped.startswith(b'%%Page:')): + if not injected and (stripped.rstrip() == b'%%EndSetup' or stripped.startswith(b'%%Page:')): yield inject injected = True yield line diff --git a/tests/test_kyofilter.py b/tests/test_kyofilter.py index dc66f2c..10f6269 100644 --- a/tests/test_kyofilter.py +++ b/tests/test_kyofilter.py @@ -79,3 +79,9 @@ class TestProcessStream: ps = "%!PS\n%%BeginSetup\n%%EndSetup\nshowpage\n" result = self._collect(ps, "00012345") assert b"showpage\n" in result + + def test_warns_when_no_injection_point(self, capsys): + ps = "%!PS\nshowpage\n" + self._collect(ps, "00012345") + captured = capsys.readouterr() + assert "WARNING" in captured.err