惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
A
About on SuperTechFans
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
月光博客
月光博客
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
Jina AI
Jina AI
有赞技术团队
有赞技术团队
博客园_首页

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(synology-chat): truncate sanitized input on UTF-16 bo...
llagy009 · 2026-06-28 · via Recent Commits to openclaw:main

File tree

  • extensions/synology-chat/src

Original file line numberDiff line numberDiff line change

@@ -433,6 +433,31 @@ describe("synology-chat security helpers", () => {

433433

expect(result).toContain("[truncated]");

434434

});

435435
436+

it("truncates long inputs without splitting a surrogate pair", () => {

437+

const loneSurrogatePattern =

438+

/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]/u;

439+

const input = "a".repeat(3999) + "\u{1F600}" + "b".repeat(2000);

440+
441+

const result = sanitizeInput(input);

442+
443+

expect(result).toContain("[truncated]");

444+

expect(result).not.toMatch(loneSurrogatePattern);

445+

expect(result).toBe(`${"a".repeat(3999)}... [truncated]`);

446+

});

447+
448+

it("keeps complete supplementary-plane characters that fit before truncation", () => {

449+

const loneSurrogatePattern =

450+

/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]/u;

451+

const emoji = "\u{1F600}";

452+

const input = "a".repeat(3998) + emoji + "b".repeat(2000);

453+
454+

const result = sanitizeInput(input);

455+
456+

expect(result).toContain("[truncated]");

457+

expect(result.startsWith(`${"a".repeat(3998)}${emoji}`)).toBe(true);

458+

expect(result).not.toMatch(loneSurrogatePattern);

459+

});

460+
436461

it("rate limits per user and caps tracked state", () => {

437462

const limiter = new RateLimiter(3, 60);

438463

expect(limiter.check("user1")).toBe(true);

Original file line numberDiff line numberDiff line change

@@ -5,6 +5,7 @@

55

import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";

66

import { finiteSecondsToTimerSafeMilliseconds } from "openclaw/plugin-sdk/number-runtime";

77

import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";

8+

import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";

89

import {

910

createFixedWindowRateLimiter,

1011

type FixedWindowRateLimiter,

@@ -64,7 +65,7 @@ export function sanitizeInput(text: string): string {

6465
6566

const maxLength = 4000;

6667

if (sanitized.length > maxLength) {

67-

sanitized = sanitized.slice(0, maxLength) + "... [truncated]";

68+

sanitized = truncateUtf16Safe(sanitized, maxLength) + "... [truncated]";

6869

}

6970
7071

return sanitized;

Original file line numberDiff line numberDiff line change

@@ -6,6 +6,7 @@

66

import type { IncomingMessage, ServerResponse } from "node:http";

77

import * as querystring from "node:querystring";

88

import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";

9+

import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";

910

import {

1011

beginWebhookRequestPipelineOrReject,

1112

createWebhookInFlightLimiter,

@@ -503,7 +504,7 @@ async function parseAndAuthorizeSynologyWebhook(params: {

503504

respondNoContent(params.res);

504505

return { ok: false };

505506

}

506-

const preview = cleanText.length > 100 ? `${cleanText.slice(0, 100)}...` : cleanText;

507+

const preview = cleanText.length > 100 ? `${truncateUtf16Safe(cleanText, 100)}...` : cleanText;

507508

return {

508509

ok: true,

509510

message: {

@@ -574,7 +575,7 @@ async function processAuthorizedSynologyWebhook(params: {

574575

deliveryUserId,

575576

params.account.allowInsecureSsl,

576577

);

577-

const replyPreview = reply.length > 100 ? `${reply.slice(0, 100)}...` : reply;

578+

const replyPreview = reply.length > 100 ? `${truncateUtf16Safe(reply, 100)}...` : reply;

578579

params.log?.info?.(

579580

`Reply sent to ${params.message.payload.username} (${deliveryUserId}): ${replyPreview}`,

580581

);