Read the text form with blank lines in front, as age does (closes #77) #88

Merged
clawbot merged 1 commits from issue-77-armor-leading-whitespace into next 2026-10-14 22:35:30 +02:00
Collaborator

For #77.

age decrypt took the text form (--armor output) only when the input began exactly with -----BEGIN AGE ENCRYPTED FILE-----. A blank line in front, as pasting from mail or a terminal can leave, made it read the file as the binary form and refuse it with unexpected intro.

unarmored in internal/agekey/agekey.go now looks for that line past up to 1024 bytes of whitespace, the same check the age tool makes in its own decrypt. The text form reader from filippo.io/age/armor already skips blank lines in front of the first line, up to the same limit, so nothing else changes.

A test in internal/agekey/agekey_test.go puts a blank line and a line of two spaces in front of a text-form file and expects the plaintext. The README's age decrypt section now says the text form needs no flag and that up to 1024 bytes of blank lines in front of it are skipped.

Judgement call: the issue's test names a newline and two spaces in front of the file. Written straight before the first line, the spaces end up on the line -----BEGIN AGE ENCRYPTED FILE-----, which the armor reader refuses (invalid first line), in age as here. The test puts the two spaces on a line of their own instead, to match age.

Model: opus-5-5

For https://git.eeqj.de/sneak/keyfunc/issues/77. `age decrypt` took the text form (`--armor` output) only when the input began exactly with `-----BEGIN AGE ENCRYPTED FILE-----`. A blank line in front, as pasting from mail or a terminal can leave, made it read the file as the binary form and refuse it with `unexpected intro`. `unarmored` in `internal/agekey/agekey.go` now looks for that line past up to 1024 bytes of whitespace, the same check the `age` tool makes in its own decrypt. The text form reader from `filippo.io/age/armor` already skips blank lines in front of the first line, up to the same limit, so nothing else changes. A test in `internal/agekey/agekey_test.go` puts a blank line and a line of two spaces in front of a text-form file and expects the plaintext. The README's `age decrypt` section now says the text form needs no flag and that up to 1024 bytes of blank lines in front of it are skipped. Judgement call: the issue's test names a newline and two spaces in front of the file. Written straight before the first line, the spaces end up on the line ` -----BEGIN AGE ENCRYPTED FILE-----`, which the armor reader refuses (`invalid first line`), in `age` as here. The test puts the two spaces on a line of their own instead, to match `age`. Model: opus-5-5
clawbot added the needs-review label 2026-10-14 21:20:45 +02:00
clawbot self-assigned this 2026-10-14 21:20:45 +02:00
Author
Collaborator

One finding.

  • README.md:284-286, age decrypt: the new sentence says blank lines in front of the text form are skipped, with no limit. The code skips at most 1024 bytes of them; with more, the file is refused with the same unexpected intro: "\n" message that #77 is about. Acceptable: the sentence says that up to 1024 bytes of blank lines are skipped, as age skips them.

Judgement call accepted: the test puts its two spaces on a line of their own rather than straight before the first line, because age refuses spaces on that line too and the definition of done asks for the same result as age.

Model: opus-5-5

One finding. - `README.md:284-286`, `age decrypt`: the new sentence says blank lines in front of the text form are skipped, with no limit. The code skips at most 1024 bytes of them; with more, the file is refused with the same `unexpected intro: "\n"` message that https://git.eeqj.de/sneak/keyfunc/issues/77 is about. Acceptable: the sentence says that up to 1024 bytes of blank lines are skipped, as `age` skips them. Judgement call accepted: the test puts its two spaces on a line of their own rather than straight before the first line, because `age` refuses spaces on that line too and the definition of done asks for the same result as `age`. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-14 21:44:50 +02:00
clawbot added 1 commit 2026-10-14 21:52:36 +02:00
age decrypt took the text form only when the file began exactly with
-----BEGIN AGE ENCRYPTED FILE-----, so a blank line in front made it
read the file as the binary form and refuse it. It now looks for that
line past up to 1024 bytes of whitespace, as the age tool does, and
the text form reader skips the blank lines. A test puts a blank line
and a line of two spaces in front of a text-form file. The README's
age decrypt section says so.

Judgement call: that first line with spaces in front of it on the same
line is still refused, as age refuses it.

Model: opus-5-5
clawbot force-pushed issue-77-armor-leading-whitespace from 759e39f59a to bb41583356 2026-10-14 21:52:36 +02:00 Compare
Author
Collaborator

Rework: the README's age decrypt sentence now says that up to 1024 bytes of blank lines in front of the text form are skipped, as age skips them. The PR body says the same. Rebased onto next, still one commit.

Model: opus-5-5

Rework: the README's `age decrypt` sentence now says that up to 1024 bytes of blank lines in front of the text form are skipped, as `age` skips them. The PR body says the same. Rebased onto `next`, still one commit. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-14 21:52:48 +02:00
Author
Collaborator

Review passed: #88 is ready to merge into next.

Unverified: the reference age tool is not installed here, so the last step of the issue's "How to see" was compared against its v1.3.2 decrypt code instead of run.

Model: opus-5-5

Review passed: https://git.eeqj.de/sneak/keyfunc/pulls/88 is ready to merge into `next`. Unverified: the reference `age` tool is not installed here, so the last step of the issue's "How to see" was compared against its v1.3.2 decrypt code instead of run. Model: opus-5-5
clawbot merged commit f1e27814cd into next 2026-10-14 22:35:30 +02:00
clawbot deleted branch issue-77-armor-leading-whitespace 2026-10-14 22:35:31 +02:00
Sign in to join this conversation.