fix(gateway): purify global notice HTML

This commit is contained in:
2026-07-31 16:47:26 +00:00
parent 1168813eb3
commit 864cbfc0d0
10 changed files with 299 additions and 8 deletions
+6 -4
View File
@@ -12,6 +12,7 @@ import { toPublicUser } from './auth/userRepository.js';
import type { AdminAuthContext } from './adminAuth.js';
import type { GatewayApiContext } from './context.js';
import { GATEWAY_BUILD_STATUSES, GATEWAY_PROFILE_STATUSES } from './orchestrator/profileRepository.js';
import { purifyGatewayNoticeHtml } from './security/gatewayNoticeHtml.js';
const zProfileStatus = z.enum(GATEWAY_PROFILE_STATUSES);
const zBuildStatus = z.enum(GATEWAY_BUILD_STATUSES);
@@ -399,7 +400,7 @@ export const adminRouter = router({
const setting = await ctx.prisma.systemSetting.findUnique({
where: { id: 1 },
});
return { notice: setting?.notice ?? '' };
return { notice: purifyGatewayNoticeHtml(setting?.notice) };
}),
setNotice: noticeAdminProcedure
.input(
@@ -408,17 +409,18 @@ export const adminRouter = router({
})
)
.mutation(async ({ ctx, input }) => {
const notice = purifyGatewayNoticeHtml(input.notice);
const setting = await ctx.prisma.systemSetting.upsert({
where: { id: 1 },
create: {
id: 1,
notice: input.notice,
notice,
},
update: {
notice: input.notice,
notice,
},
});
return { notice: setting.notice };
return { notice: purifyGatewayNoticeHtml(setting.notice) };
}),
}),
users: router({