feat: support mailing-list and monthly mail capture paths
Build and publish container images / images (push) Successful in 11m59s
Release container images / release (push) Successful in 22s

This commit is contained in:
Anya Tokugawa committed 2026-11-06 09:51:45 +09:00
1 parent 543814cbd6
commit 1a451023f0
7 files changed
+165 -5

No files matched your search

+9
View File
@@ -6,6 +6,7 @@ import (
"encoding/json"
"html"
"path"
"regexp"
"strings"
"time"
"unicode"
@@ -40,6 +41,14 @@ func TaskCaptureWikiPath(prefix, title, request string) string {
return strings.TrimRight(prefix, "/") + "/mail-" + request
}
var mailListSuffix = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,99}/(0|[1-9][0-9]{0,19})$`)
var mailMonthSuffix = regexp.MustCompile(`^[0-9]{4}/(0[1-9]|1[0-2])/([0-9a-f]{64}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$`)
// Only the two mail layouts are accepted; no arbitrary relative path traversal.
func ValidTaskMailSuffix(s string) bool {
return mailListSuffix.MatchString(s) || (mailMonthSuffix.MatchString(s) && !strings.HasPrefix(s, "0000/"))
}
func (s *Store) createCapturedTaskWiki(ctx context.Context, tx *sql.Tx, domain, actor string, item *TaskRecord, target, body string) error {
if target == "" || !ValidTaskWikiPrefix(path.Dir(target)) || path.Clean(target) != target || item.PageUUID != "" || len(body) > 256<<10 || !utf8.ValidString(body) || strings.IndexByte(body, 0) >= 0 {
return ErrTaskInvalid