In bbs.scm:view-thread you are recomputing the unchanging (posts-range range) for every single invocation of the lambda that is assigned to filter-func. Just save (posts-range range) in the let* and use it in the lambda.
And a test for lib/markup.scm:quotelink + bbs.scm:posts-range:foo
>>30---,,,---,,,---30
>>30
As expected, bbs.scm:posts-range:foo bites the dust.
error 500
internal server error
You need to tighten up the irregex in lib/markup.scm:quotelink, or the parsing in bbs.scm:posts-range:foo, or preferably both.
Here is a regular grammar for quotelink:
number -> [1-9][0-9]*
range -> number "-" number
numberorrange -> number | range
list -> numberorrange ("," numberorrange)*
The resulting regex, with extra parens for pair highlighting:
(([1-9][0-9]*)|(([1-9][0-9]*)-([1-9][0-9]*)))(,(([1-9][0-9]*)|(([1-9][0-9]*)-([1-9][0-9]*))))*
^^ number ^ ^^ number ^ ^ number ^^^ ^^ number ^ ^^ number ^ ^ number ^^^
|+-----------+ |+-----------+ +-----------+|| |+-----------+ |+-----------+ +-----------+||
| | range || | | range ||
| +---------------------------+| | +---------------------------+|
| numberorrange | | numberorrange |
+-------------------------------------------+ +-------------------------------------------+
This can be "simplified" by making the range-closing optional, but such "simplifications" tend to be counterproductive for long-term maintainability. And you should still add strict sanity checks in bbs.scm:posts-range.
I just realized that bbs.scm:posts-range:foo calls iota directly on user-controlled inputs. A small test:
>>1-64001001001
The test result I get is:
error 504
gateway timeout
You should probably validate the range to between 1 and *max-posts* or similar.