[ prog / sol / mona ]

prog


How can I run my own instance of this

30 2020-02-18 21:20

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

31 2020-02-18 21:36

>>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.

32 2020-02-18 23:54

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.

33 2020-02-19 04:05

I just realized that bbs.scm:posts-range:foo calls iota directly on user-controlled inputs. A small test:
>>1-64001001001

34 2020-02-19 04:11

The test result I get is:

error 504
gateway timeout

You should probably validate the range to between 1 and *max-posts* or similar.

301


VIP:

do not edit these