Bug fix: Lexer hangs on single entry bundles.

This commit is contained in:
Netscape Navigator 2020-03-23 08:20:05 -05:00
parent 33cf84fa7b
commit d10d9bbadc
2 changed files with 5 additions and 6 deletions

View File

@ -26,7 +26,7 @@ module Pigeon
KIND = /kind #{ALPHANUMERICISH}\n/
BODY_ENTRY = /#{ALPHANUMERICISH}:#{ANY_VALUE}\n/
FOOTER_ENTRY = /signature .*{40,90}\.sig\.ed25519\n/
FOOTER_ENTRY = /signature .*{87,88}\.sig\.ed25519\n?/
LEXER_STATES = [HEADER = :header, BODY = :body, FOOTER = :footer]
@ -118,6 +118,7 @@ module Pigeon
# Reset the lexer to ingest the next entry.
# If scanner.eos? == true, it will just terminate.
# This freezes everything:
if scanner.scan(FOOTER_ENTRY)
sig = scanner.matched.strip.gsub("signature ", "")
@tokens << [:SIGNATURE, sig]

View File

@ -43,10 +43,8 @@ RSpec.describe Pigeon::Lexer do
end
it "tokenizes a single message" do
fail([
"This currently freezes the lexer.",
"Maybe I need to add a scanner.peek call or sth?",
].join(" "))
tokens = Pigeon::Lexer.tokenize(message.render)
string = message.render
tokens = Pigeon::Lexer.tokenize(string)
binding.pry
end
end