Skip to content

Commit

Permalink
Fix (grimoire): check for opening and closing brackets in source
Browse files Browse the repository at this point in the history
  • Loading branch information
yunginnanet committed Jun 26, 2024
1 parent 5724075 commit e0b4c0a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func SetupHeffalump(config *config.Parameters) error {
return fmt.Errorf("%w: grimoire file '%s' appears to be empty", io.EOF, config.Bespoke.Grimoire)
}

if !strings.Contains(src, "<") || !strings.Contains(src, ">") {
return fmt.Errorf("%w: grimoire file '%s' does not appear to be a valid source text, missing brackets",
io.ErrUnexpectedEOF, config.Bespoke.Grimoire)
}

markovMap := heffalump.MakeMarkovMap(strings.NewReader(src))
hellpotHeffalump = heffalump.NewHeffalump(markovMap, heffalump.DefaultBuffSize)
default:
Expand Down

0 comments on commit e0b4c0a

Please sign in to comment.