bug fixes

This commit is contained in:
undefined committed 2025-11-20 13:23:38 +08:00
1 parent c77cc107ca
commit a2d2741682
4 files changed
+10 -7

No files matched your search

@@ -3,6 +3,7 @@
/* eslint-disable regexp/no-useless-non-capturing-group */
/* eslint-disable regexp/optimal-quantifier-concatenation */
import _ from 'lodash';
import type MarkdownIt from 'markdown-it';
import { v4 as uuid } from 'uuid';
@@ -101,10 +102,10 @@ export function Media(md: MarkdownIt) {
if (result) return result;
}
if (service === 'pdf') {
if (src.startsWith('file://') || src.startsWith('./') || (src[1] === '/' && src[2] !== '/')) src += src.includes('?') ? '&noDisposition=1' : '?noDisposition=1';
if (['file://', './', '../'].some((i) => src.startsWith(i)) || (src[1] === '/' && src[2] !== '/')) src += src.includes('?') ? '&noDisposition=1' : '?noDisposition=1';
// A response with has content-disposition header causes the browser to download the file automatically.
// As we cannot control response header from external sites, we block embedding external PDFs.
else return '<p>Embedding an external PDF is no longer supported.</p>';
else return `<p>Embedding an external PDF is no longer supported.</p> <a href="${_.escape(src)}">Download</a>`;
return `\
<object classid="clsid:${uuid().toUpperCase()}">
<param name="SRC" value="${src}">