Skip to content

Commit bc831ef

Browse files
committed
fix: add style attribute support and logging for public notes
- Allow style attribute in HTML sanitization for text/background colors - Add [PUBLIC API] logging for public note views and not-found attempts - Add [PUBLIC_NOTES] logging for public note updates
1 parent 0b9cb66 commit bc831ef

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/routes/public-notes/crud.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function sanitizeHtml(html: string): string {
5252
"href", "src", "alt", "title", "class", "id",
5353
"target", "rel", "width", "height",
5454
"colspan", "rowspan",
55+
"style", // For text color/background color support
5556
],
5657
// Only allow safe URL protocols (blocks javascript:, data:, vbscript:, etc.)
5758
ALLOWED_URI_REGEXP: /^(?:https?|mailto|tel):/i,
@@ -254,9 +255,20 @@ crudRouter.openapi(getPublicNoteRoute, async (c) => {
254255
logger.databaseQuery("select", "public_notes", Date.now() - selectStart);
255256

256257
if (!publicNote) {
258+
logger.info("[PUBLIC API] Public note not found", {
259+
type: "public_api_event",
260+
event_type: "public_note_not_found",
261+
slug,
262+
});
257263
throw new HTTPException(404, { message: "Public note not found" });
258264
}
259265

266+
logger.info("[PUBLIC API] Public note viewed", {
267+
type: "public_api_event",
268+
event_type: "public_note_viewed",
269+
slug,
270+
});
271+
260272
return c.json(publicNote, 200);
261273
});
262274

@@ -343,6 +355,14 @@ crudRouter.openapi(updatePublicNoteRoute, async (c) => {
343355
.returning();
344356
logger.databaseQuery("update", "public_notes", Date.now() - updateStart, userId);
345357

358+
logger.info("[PUBLIC_NOTES] Public note updated", {
359+
type: "public_note_event",
360+
event_type: "public_note_updated",
361+
"user.id": userId,
362+
publicNoteId: existingPublicNote.id,
363+
slug,
364+
});
365+
346366
return c.json(updatedPublicNote, 200);
347367
});
348368

0 commit comments

Comments
 (0)