[STABLE] Pass all message creation (even local messages) through the message lexer/parser for validation.

This commit is contained in:
Netscape Navigator 2020-04-09 07:31:31 -05:00
parent 8df1336702
commit 58926b4c68
3 changed files with 3 additions and 4 deletions

View File

@ -51,6 +51,7 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
- [X] refactor `Bundle.create` to use `message find-all`.
- [X] Rename `message find` to `message read`, since other finders return a multihash.
- [ ] Message.ingest should be the only code path to message authoring.
- [ ] Make all methods private except those required for the CLI.
- [ ] Don't allow any type of whitespace in `kind` or `string` keys. Write a test for this.
- [ ] Add Lipmaa links like the Bamboo folks do.
- [ ] Create regexes in ::Lexer using strings and Regexp.new() for cleaner regexes.

View File

@ -61,12 +61,11 @@ module Pigeon
# Author a new message.
def publish
count = store.get_message_count_for(author) - 1
template = MessageSerializer.new(self)
@author = LocalIdentity.current
@prev = store.get_message_by_depth(author.multihash, count)
@depth = store.get_message_count_for(author.multihash)
@prev = store.get_message_by_depth(author.multihash, @depth - 1)
@signature = author.sign(template.render_without_signature)
candidate = template.render

View File

@ -144,8 +144,7 @@ RSpec.describe Pigeon::Message do
kind[rand(0...8)] = n
draft = Pigeon::Draft.create(kind: kind)
draft["body"] = "empty"
tpl = draft.publish.render
boom = ->() { Pigeon::Lexer.tokenize(tpl) }
boom = ->() { Pigeon::Lexer.tokenize(draft.publish.render) }
expect(boom).to raise_error(Pigeon::Lexer::LexError)
end
end