@@ -256,6 +261,11 @@ documentRoutes.get('/:rkey', async (c) => {
}
const rkey = c.req.param('rkey');
+
+ // Validate rkey format
+ if (!isValidTID(rkey)) {
+ return c.redirect('/documents');
+ }
try {
const response = await session.agent!.com.atproto.repo.getRecord({
@@ -266,6 +276,7 @@ documentRoutes.get('/:rkey', async (c) => {
const doc = response.data.value as any;
const isDraft = (doc.tags || []).includes('draft');
+ const csrfToken = c.get('csrfToken') as string;
const content = html`
@@ -288,14 +299,17 @@ documentRoutes.get('/:rkey', async (c) => {
Edit
${isDraft ? html`
` : html`
`}
Back to List
@@ -320,6 +334,10 @@ documentRoutes.get('/:rkey/edit', async (c) => {
}
const rkey = c.req.param('rkey');
+
+ if (!isValidTID(rkey)) {
+ return c.redirect('/documents');
+ }
try {
const response = await session.agent!.com.atproto.repo.getRecord({
@@ -329,12 +347,14 @@ documentRoutes.get('/:rkey/edit', async (c) => {
});
const doc = response.data.value as any;
+ const csrfToken = c.get('csrfToken') as string;
const content = html`