mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(commands): guard shortenText against non-positive maxLen (#99917)
* fix(commands): guard shortenText against non-positive maxLen * fix(commands): guard shortenText against non-positive maxLen --------- Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,7 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Command output truncation:** return an empty string for non-positive shortening limits instead of emitting an over-budget ellipsis. (#99917) Thanks @Super-Cabbage.
|
||||
- **Agent helper downloads:** bound fd and ripgrep archive downloads and extraction with declared and streamed byte caps, extraction limits, timeouts, traversal-safe unpacking, and partial-file cleanup. (#98988) Thanks @LeonidasLux.
|
||||
- **Control UI cron actions:** localize the overflow-menu label and due-only run action across all supported locales.
|
||||
- **OpenRouter OAuth and Discord webhook response bounds:** cap successful JSON response bodies while preserving Discord's no-body webhook mode. (#98098) Thanks @lwy-2.
|
||||
|
||||
@@ -11,6 +11,11 @@ describe("shortenText", () => {
|
||||
expect(shortenText("openclaw-status-output", 10)).toBe("openclaw-…");
|
||||
});
|
||||
|
||||
it("returns an empty string for non-positive limits", () => {
|
||||
expect(shortenText("openclaw", 0)).toBe("");
|
||||
expect(shortenText("openclaw", -1)).toBe("");
|
||||
});
|
||||
|
||||
it("counts multi-byte characters correctly", () => {
|
||||
expect(shortenText("hello🙂world", 7)).toBe("hello🙂…");
|
||||
});
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
/** Shortens text to maxLen code points, appending an ellipsis when truncated. */
|
||||
export const shortenText = (value: string, maxLen: number) => {
|
||||
if (maxLen <= 0) {
|
||||
return "";
|
||||
}
|
||||
const chars = Array.from(value);
|
||||
if (chars.length <= maxLen) {
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user