Add NFC normalization to all FormData inputs across 41 server actions
Local Build and Deploy / deploy (push) Successful in 59s
Local Build and Deploy / deploy (push) Successful in 59s
All user-supplied string values from FormData now go through
String.prototype.normalize('NFC') to prevent Unicode homoglyph
attacks and canonicalization bypasses. NFC is idempotent for
already-normalized strings, so this is a pure security improvement
with zero behavioral change for legitimate users.
This commit is contained in:
1 parent
e2fc7ea1a4
commit
e5ae51bff7
41 files changed
+152
-152
No files matched your search
@@ -19,10 +19,10 @@ async function uniqueSlug(title: string): Promise<string> {
|
||||
|
||||
export async function createArticle(formData: FormData): Promise<void> {
|
||||
const staff = await requireStaff();
|
||||
const title = String(formData.get("title") ?? "").trim();
|
||||
const shortStory = String(formData.get("shortStory") ?? "").trim();
|
||||
const fullStory = String(formData.get("fullStory") ?? "").trim();
|
||||
const image = String(formData.get("image") ?? "").trim();
|
||||
const title = String(formData.get("title") ?? "").normalize("NFC").trim();
|
||||
const shortStory = String(formData.get("shortStory") ?? "").normalize("NFC").trim();
|
||||
const fullStory = String(formData.get("fullStory") ?? "").normalize("NFC").trim();
|
||||
const image = String(formData.get("image") ?? "").normalize("NFC").trim();
|
||||
if (!title) return;
|
||||
|
||||
try {
|
||||
@@ -53,14 +53,14 @@ export async function updateArticle(formData: FormData): Promise<void> {
|
||||
await prisma.websiteArticles.update({
|
||||
where: { id },
|
||||
data: {
|
||||
title: String(formData.get("title") ?? "")
|
||||
title: String(formData.get("title") ?? "").normalize("NFC")
|
||||
.trim()
|
||||
.slice(0, 255),
|
||||
shortStory: String(formData.get("shortStory") ?? "")
|
||||
shortStory: String(formData.get("shortStory") ?? "").normalize("NFC")
|
||||
.trim()
|
||||
.slice(0, 255),
|
||||
fullStory: String(formData.get("fullStory") ?? "").trim(),
|
||||
image: String(formData.get("image") ?? "")
|
||||
fullStory: String(formData.get("fullStory") ?? "").normalize("NFC").trim(),
|
||||
image: String(formData.get("image") ?? "").normalize("NFC")
|
||||
.trim()
|
||||
.slice(0, 255),
|
||||
updatedAt: new Date(),
|
||||
|
||||
Reference in new issue
Block a user