Skip to content

Commit d47efac

Browse files
committed
Limit tag param lengths
1 parent 67cd847 commit d47efac

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

backend/src/plugin/tags/command/tag.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { OptionType } from "#plugin/core/public/command.ts";
33
import { defineCommand } from "#plugin/core/public/extensionPoints.ts";
44
import { permissionsGuard } from "#plugin/core/public/helper/commandGuards.ts";
55
import { icons } from "#plugin/core/public/icons.ts";
6-
import { tagsConfigStore } from "#plugin/tags/index.ts";
6+
import { MAX_TAG_NAME_LENGTH, tagsConfigStore } from "#plugin/tags/index.ts";
77
import { getTag, searchTags } from "#plugin/tags/storage/tags.ts";
88

99
export default defineCommand({
@@ -15,6 +15,7 @@ export default defineCommand({
1515
name: ["name", "n"],
1616
required: true,
1717
position: 0,
18+
maxLength: MAX_TAG_NAME_LENGTH,
1819

1920
autocomplete: (ctx, value) =>
2021
searchTags(ctx.squirrelCtx.db, ctx.guild.id, value),

backend/src/plugin/tags/command/tagDelete.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { OptionType } from "#plugin/core/public/command.ts";
33
import { defineCommand } from "#plugin/core/public/extensionPoints.ts";
44
import { permissionsGuard } from "#plugin/core/public/helper/commandGuards.ts";
55
import { icons } from "#plugin/core/public/icons.ts";
6-
import { tagsConfigStore } from "#plugin/tags/index.ts";
6+
import { MAX_TAG_NAME_LENGTH, tagsConfigStore } from "#plugin/tags/index.ts";
77
import { deleteTag, searchTags } from "#plugin/tags/storage/tags.ts";
88

99
export default defineCommand({
@@ -16,6 +16,7 @@ export default defineCommand({
1616
name: ["name", "n"],
1717
required: true,
1818
position: 0,
19+
maxLength: MAX_TAG_NAME_LENGTH,
1920

2021
autocomplete: (ctx, value) =>
2122
searchTags(ctx.squirrelCtx.db, ctx.guild.id, value),

backend/src/plugin/tags/command/tagSet.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { OptionType } from "#plugin/core/public/command.ts";
33
import { defineCommand } from "#plugin/core/public/extensionPoints.ts";
44
import { permissionsGuard } from "#plugin/core/public/helper/commandGuards.ts";
55
import { icons } from "#plugin/core/public/icons.ts";
6-
import { tagsConfigStore } from "#plugin/tags/index.ts";
6+
import {
7+
MAX_TAG_CONTENT_LENGTH,
8+
MAX_TAG_NAME_LENGTH,
9+
tagsConfigStore,
10+
} from "#plugin/tags/index.ts";
711
import {
812
createTag,
913
searchTags,
@@ -23,6 +27,7 @@ export default defineCommand({
2327
"The name of the tag - a tag with this name will be created if it doesn't currently exist.",
2428
required: true,
2529
position: 0,
30+
maxLength: MAX_TAG_NAME_LENGTH,
2631
greedy: false,
2732

2833
autocomplete: (ctx, value) =>
@@ -33,6 +38,7 @@ export default defineCommand({
3338
name: ["content", "c"],
3439
required: true,
3540
position: 1,
41+
maxLength: MAX_TAG_CONTENT_LENGTH,
3642
},
3743
existing: {
3844
type: OptionType.Flag,

backend/src/plugin/tags/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { TagsConfig } from "#plugin/tags/config.ts";
88

99
export const tagsConfigStore = new ConfigStore(TagsConfig);
1010

11+
export const MAX_TAG_NAME_LENGTH = 30;
12+
export const MAX_TAG_CONTENT_LENGTH = 4000;
13+
1114
const defaultConfig = `enabled = false
1215
1316
# Example: allow admins to create tags

0 commit comments

Comments
 (0)