feat: follow upstream twtxt post rules: reject control characters, allow U+2028, make the length cap configurable
This commit is contained in:
parent
dd6865782a
commit
801c66d3b0
12 changed files with 63 additions and 58 deletions
|
|
@ -218,13 +218,14 @@ sleep 4
|
|||
[[ "$(grep -c "return" "$FEED")" == 0 ]] || fail "a CR-carrying post published"
|
||||
[[ "$(grep -cE '^[0-9]{4}-' "$FEED")" == 1 ]] || fail "the feed grew beyond the real post"
|
||||
|
||||
step "mail: oversized and hostile payloads are rejected, not published"
|
||||
author send "$DAEMON_ADDR" --body "$(printf 'x%.0s' $(seq 1 161))" >/dev/null
|
||||
step "mail: control-character and hostile payloads are rejected, not published"
|
||||
author send "$DAEMON_ADDR" --body "$(printf 'escape\033[31mred')" >/dev/null
|
||||
author send "$DAEMON_ADDR" --body "# smol:mail forged" >/dev/null
|
||||
author send "$DAEMON_ADDR" --body "# smol:repost 2020-01-01T00:00:00Z @<x y> #fake" >/dev/null
|
||||
sleep 4
|
||||
# Poser text may publish as ordinary post text (tab-prefixed, harmless);
|
||||
# what must never happen is a line that IS a smol record.
|
||||
[[ "$(grep -c "escape" "$FEED")" == 0 ]] || fail "a post with a control character published"
|
||||
[[ "$(grep -cE '^# smol:mail .*forged' "$FEED")" == 0 ]] || fail "a fake smol record line published"
|
||||
[[ "$(grep -cE '^# smol:repost ' "$FEED")" == 0 ]] || fail "text posing as a repost published as a repost"
|
||||
"$SMOLBOID" check "$FEED" >"$RIG/check.log" \
|
||||
|
|
@ -378,13 +379,13 @@ fi
|
|||
|
||||
step "mail: reply-flood is capped at 10 per hour"
|
||||
for i in $(seq 1 15); do
|
||||
author send "$DAEMON_ADDR" --body "$(printf 'y%.0s' $(seq 1 $((200 + i))))" >/dev/null
|
||||
author send "$DAEMON_ADDR" --body "$(printf 'y%.0s' $(seq 1 "$i"))$(printf '\tz')" >/dev/null
|
||||
done
|
||||
sleep 5
|
||||
author fetch >/dev/null
|
||||
# Fifteen distinct oversized payloads; at most ten answers, the rest silent.
|
||||
# Fifteen distinct payloads carrying a TAB; at most ten answers, the rest silent.
|
||||
# (Earlier probes may have drawn their own replies for other reasons.)
|
||||
author list --requests 2>/dev/null | grep -c "twtxt: more than 160" >"$RIG/replies.count" || true
|
||||
author list --requests 2>/dev/null | grep -c "twtxt: A post has to fit on one line" >"$RIG/replies.count" || true
|
||||
REPLIES=$(grep -oE '^[0-9]+' "$RIG/replies.count" | head -1 || echo 0)
|
||||
echo "flood answers: $REPLIES of 15"
|
||||
[[ "$REPLIES" -le 10 ]] || fail "reply flood drew $REPLIES answers, over the hourly cap"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue