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}">
@@ -79,7 +79,7 @@
<span class="problem__tag-item icon icon-comparison" style="font-size: .75rem;margin: 0;padding: 0 5px!important;">{{ pdict[pid].config.memoryMax if pdict[pid].config.memoryMax == pdict[pid].config.memoryMin else pdict[pid].config.memoryMin+'~'+pdict[pid].config.memoryMax }}MiB</span>
{% endif %}
{% if pdict[pid].config.type != 'objective' %}
<a href="{{ url('problem_submit', pid=pdict[pid].pid, query={tid:tdoc.docId}) }}" target="_blank" class="typo-a" style="float: right;"><span class="icon icon-send">{{ _('Submit') }}</span></a>
<a href="{{ url('problem_submit', pid=pid, query={tid:tdoc.docId}) }}" target="_blank" class="typo-a" style="float: right;"><span class="icon icon-send">{{ _('Submit') }}</span></a>
{% endif %}
</td>
</tr>