From d76b097b2eb33231f98e30e615051f9c70b43f7d Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Fri, 21 Sep 2018 11:37:11 +0100 Subject: [PATCH] Add a thorough MIME image type check (#753) #555 https://github.com/DIYgod/RSSHub/issues/555#issuecomment-422837421 --- routes/jike/common.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/routes/jike/common.js b/routes/jike/common.js index 0d90d0390..1c1135f7f 100644 --- a/routes/jike/common.js +++ b/routes/jike/common.js @@ -84,12 +84,28 @@ module.exports = { // 5. 图片 if (item.pictures) { - item.pictures.forEach( - (pic) => - (description += `
`; + } else { + // jpeg, bmp, png, gif, webp + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types + let type = 'jpeg'; + switch (pic.format) { + case 'bmp': + type = 'bmp'; + break; + case 'png': + type = 'png'; + break; + default: + break; + } + description += `
`) - ); + }" type="image/${type}">`; + } + }); } // rss标题