mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 04:16:06 +00:00
Add two new channel implementations for Facebook Fanpage (comment + Messenger auto-reply, first inbox DM) and Pancake/pages.fm (multi-platform inbox via Facebook, Zalo, Instagram, TikTok, WhatsApp, LINE). Key features: - Facebook: comment auto-reply, Messenger auto-reply, first inbox DM, HMAC-SHA256 webhook verification, multi-page webhook routing - Pancake: multi-platform inbox, outbound echo dedup with HTML normalization, race-condition-safe echo fingerprinting, platform-aware formatting - Bootstrap skip: pre-fill USER.md from channel metadata (Pancake) - SanitizeDisplayName across all channels (defense in depth) Code audit fixes: - Fix truncateForTikTok byte→rune slicing (UTF-8 corruption) - Fix empty message.ID shared dedup slot (silent message loss) - Fix DisplayName markdown injection in buildPrefilledUser - Consolidate duplicate ChannelMeta type (agent→bootstrap) - Compile-time interface assertions, alphabetical type constants - Per-message logs demoted to slog.Debug, errors.As for wrapped errors - UI: alphabetical channel ordering, complete config schemas - Remove deprecated WhatsApp bridge_url, fix nested error parsing
18 lines
527 B
Go
18 lines
527 B
Go
package channels
|
|
|
|
import "strings"
|
|
|
|
// SanitizeDisplayName strips newlines and markdown heading markers from a
|
|
// channel-provided display name to prevent injection into markdown templates
|
|
// (e.g. USER.md). Caps length at 100 runes.
|
|
func SanitizeDisplayName(name string) string {
|
|
name = strings.ReplaceAll(name, "\n", " ")
|
|
name = strings.ReplaceAll(name, "\r", " ")
|
|
name = strings.ReplaceAll(name, "#", "")
|
|
name = strings.TrimSpace(name)
|
|
if len([]rune(name)) > 100 {
|
|
name = string([]rune(name)[:100])
|
|
}
|
|
return name
|
|
}
|