diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2018-12-16 01:44:59 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-12-16 01:44:59 +0900 |
| commit | ffb80efe2103b9a368ba03a856d809151c41d53b (patch) | |
| tree | 314ce6b0c3caa1e30de0613acc372d100025ded5 /src/server/activitypub/featured.ts | |
| parent | Update analog-clock.vue (diff) | |
| download | sharkey-ffb80efe2103b9a368ba03a856d809151c41d53b.tar.gz sharkey-ffb80efe2103b9a368ba03a856d809151c41d53b.tar.bz2 sharkey-ffb80efe2103b9a368ba03a856d809151c41d53b.zip | |
Return 404 for invalid Object ID (#3627)
* Update activitypub.ts
* Update activitypub.ts
* Update featured.ts
* Update followers.ts
* Update following.ts
* Update outbox.ts
* Fix following, outbox
Diffstat (limited to 'src/server/activitypub/featured.ts')
| -rw-r--r-- | src/server/activitypub/featured.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/server/activitypub/featured.ts b/src/server/activitypub/featured.ts index f400cc416f..12613b3ecf 100644 --- a/src/server/activitypub/featured.ts +++ b/src/server/activitypub/featured.ts @@ -1,4 +1,4 @@ -import * as mongo from 'mongodb'; +import { ObjectID } from 'mongodb'; import * as Router from 'koa-router'; import config from '../../config'; import User from '../../models/user'; @@ -9,7 +9,12 @@ import Note from '../../models/note'; import renderNote from '../../remote/activitypub/renderer/note'; export default async (ctx: Router.IRouterContext) => { - const userId = new mongo.ObjectID(ctx.params.user); + if (!ObjectID.isValid(ctx.params.user)) { + ctx.status = 404; + return; + } + + const userId = new ObjectID(ctx.params.user); // Verify user const user = await User.findOne({ @@ -24,7 +29,7 @@ export default async (ctx: Router.IRouterContext) => { const pinnedNoteIds = user.pinnedNoteIds || []; - const pinnedNotes = await Promise.all(pinnedNoteIds.map(id => Note.findOne({ _id: id }))); + const pinnedNotes = await Promise.all(pinnedNoteIds.filter(ObjectID.isValid).map(id => Note.findOne({ _id: id }))); const renderedNotes = await Promise.all(pinnedNotes.map(note => renderNote(note))); |