mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: validate media URL before downloading content from message (#1560)
This commit is contained in:
committed by
GitHub
parent
210338c747
commit
591c98f3e6
@@ -448,7 +448,12 @@ export const downloadContentFromMessage = async (
|
|||||||
type: MediaType,
|
type: MediaType,
|
||||||
opts: MediaDownloadOptions = {}
|
opts: MediaDownloadOptions = {}
|
||||||
) => {
|
) => {
|
||||||
const downloadUrl = url || getUrlFromDirectPath(directPath!)
|
const isValidMediaUrl = url?.startsWith('https://mmg.whatsapp.net/')
|
||||||
|
const downloadUrl = isValidMediaUrl ? url : getUrlFromDirectPath(directPath!)
|
||||||
|
if (!downloadUrl) {
|
||||||
|
throw new Boom('No valid media URL or directPath present in message', { statusCode: 400 })
|
||||||
|
}
|
||||||
|
|
||||||
const keys = await getMediaKeys(mediaKey, type)
|
const keys = await getMediaKeys(mediaKey, type)
|
||||||
|
|
||||||
return downloadEncryptedContent(downloadUrl, keys, opts)
|
return downloadEncryptedContent(downloadUrl, keys, opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user