Skip to content

A record is what was written - #15

Merged
sepehr-safari merged 1 commit into
mainfrom
a-record-is-what-was-written
Sep 22, 2026
Merged

sepehr-safari merged 1 commit into
mainfrom
a-record-is-what-was-written

Conversation

@sepehr-safari

Copy link
Copy Markdown
Contributor

Closes #14.

The record reader trimmed spaces and tabs off both ends of every line. For a code or a JSON object that is harmless. For deed encrypt the record is the message.

printf "  hello  \n" | deed encrypt ...   ->  encrypts "hello"

Nothing said so, and the payload is sealed, so there is no reading it back to notice.

Input now hands back the record as written, minus the line terminator, and the verbs whose records are a code, an event or a draft trim for themselves. \r from CRLF still comes off: that is how the line ended, not part of what was in it. A truly empty line still separates; a line of spaces is now a record, because for encrypt that is a message somebody chose to send.

Two smaller ones, same family

Both are about refusing to carry what the reader gave.

deed encrypt could not send a message starting with a hyphen, which came back as an unknown option. -- ends the options now.

deed key public on 64 hex characters outside the curve range printed deed: InvalidSecretKey, a Zig error name that escaped to the top-level handler. It says what is wrong with the input now.

Checked

49 to 53 tests. Restoring the trim fails two of the new ones, on the message and on the line of spaces.

before after
printf " hello " through encrypt hello hello
a code with surrounding space decodes decodes
CRLF input works works
empty line between records separator separator
encrypt -- "-dash first" unknown option sends it
key public with an unusable key deed: InvalidSecretKey a sentence

The record reader trimmed spaces and tabs off both ends of every line before handing it to a verb. For a NIP-19 code or a JSON object that is harmless. For `deed encrypt` the record IS the message.

`printf '  hello  ' | deed encrypt` encrypted `hello`. The spaces were gone, nothing said so, and the payload is sealed, so there is no reading it back to notice. Somebody sending an indented line or significant trailing whitespace got something other than what they typed, encrypted in their name.

So `Input` hands back the record as written, minus the line terminator, and the verbs whose records are a code, an event or a draft trim for themselves. A `\r` from CRLF still comes off, because that is how the line ended rather than part of what was in it. A truly empty line still separates records; a line of spaces is now a record, because for `encrypt` that is a message somebody chose to send.

Two smaller ones in the same family, both about refusing to carry what the reader gave.

`deed encrypt` could not send a message beginning with a hyphen: it came back as an unknown option, which is a refusal on account of a first character. `--` ends the options now, the way it does everywhere else.

`deed key public` on 64 hex characters outside the curve's range printed `deed: InvalidSecretKey`, a Zig error name that escaped to the top-level handler. It now says what is wrong with what was pasted, like every other failure in that verb.

Checked by restoring the trim: two of the new tests fail, one on the message and one on the line of spaces.

Closes #14.
@sepehr-safari
sepehr-safari merged commit f708e61 into main Sep 22, 2026
2 checks passed
@sepehr-safari
sepehr-safari deleted the a-record-is-what-was-written branch September 22, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A piped message is altered before it is encrypted

1 participant