mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 17:44:57 +00:00
fix(slack): guard against undefined text in includes calls during mention handling
This commit is contained in:
committed by
Peter Steinberger
parent
ce4faedad6
commit
2a98fd3d0b
@@ -57,6 +57,10 @@ describe("markdownToSlackMrkdwn", () => {
|
||||
"*Important:* Check the _docs_ at <https://example.com|link>\n\n• first\n• second",
|
||||
);
|
||||
});
|
||||
|
||||
it("does not throw when input is undefined at runtime", () => {
|
||||
expect(markdownToSlackMrkdwn(undefined as unknown as string)).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("escapeSlackMrkdwn", () => {
|
||||
|
||||
@@ -28,6 +28,9 @@ function isAllowedSlackAngleToken(token: string): boolean {
|
||||
}
|
||||
|
||||
function escapeSlackMrkdwnContent(text: string): string {
|
||||
if (!text) {
|
||||
return "";
|
||||
}
|
||||
if (!text.includes("&") && !text.includes("<") && !text.includes(">")) {
|
||||
return text;
|
||||
}
|
||||
@@ -53,6 +56,9 @@ function escapeSlackMrkdwnContent(text: string): string {
|
||||
}
|
||||
|
||||
function escapeSlackMrkdwnText(text: string): string {
|
||||
if (!text) {
|
||||
return "";
|
||||
}
|
||||
if (!text.includes("&") && !text.includes("<") && !text.includes(">")) {
|
||||
return text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user