mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	fix: update signature parsing logic to handle values with equal signs in them, closes #12538
This commit is contained in:
		| @@ -76,7 +76,10 @@ middleware.validate = async function (req, res, next) { | |||||||
| 	await activitypub.actors.assert(actor); | 	await activitypub.actors.assert(actor); | ||||||
| 	const compare = await db.getObjectField(`userRemote:${actor}:keys`, 'id'); | 	const compare = await db.getObjectField(`userRemote:${actor}:keys`, 'id'); | ||||||
| 	const { signature } = req.headers; | 	const { signature } = req.headers; | ||||||
| 	const keyId = new Map(signature.split(',').filter(Boolean).map(v => v.split('='))).get('keyId'); | 	const keyId = new Map(signature.split(',').filter(Boolean).map((v) => { | ||||||
|  | 		const index = v.indexOf('='); | ||||||
|  | 		return [v.substring(0, index), v.slice(index + 1)]; | ||||||
|  | 	})).get('keyId'); | ||||||
| 	if (`"${compare}"` !== keyId) { | 	if (`"${compare}"` !== keyId) { | ||||||
| 		winston.verbose('[middleware/activitypub] Key ownership cross-check failed.'); | 		winston.verbose('[middleware/activitypub] Key ownership cross-check failed.'); | ||||||
| 		return res.sendStatus(403); | 		return res.sendStatus(403); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user