mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
bug fixes
This commit is contained in:
4 files changed
+10
-7
No files matched your search
@@ -129,6 +129,9 @@ export function bufferToStream(buffer: Buffer): NodeJS.ReadableStream {
|
||||
return stream;
|
||||
}
|
||||
|
||||
let ObjectId: typeof import('bson').ObjectId; // eslint-disable-line
|
||||
let isMoment: (x: any) => x is Moment;
|
||||
|
||||
export namespace Time {
|
||||
export const second = 1000;
|
||||
export const minute = second * 60;
|
||||
@@ -145,15 +148,13 @@ export namespace Time {
|
||||
}
|
||||
|
||||
export function getObjectID(timestamp: string | Date | Moment, allZero = true) {
|
||||
let isMoment: (x: any) => x is Moment;
|
||||
let ObjectId: typeof import('bson').ObjectId; // eslint-disable-line
|
||||
try {
|
||||
({ ObjectId } = require('bson'));
|
||||
ObjectId ||= require('bson').ObjectId;
|
||||
} catch (e) {
|
||||
throw new Error('No bson module found');
|
||||
}
|
||||
try {
|
||||
({ isMoment } = require('moment'));
|
||||
isMoment ||= require('moment');
|
||||
} catch (e) {
|
||||
throw new Error('No moment module found');
|
||||
}
|
||||
|
||||
@@ -638,5 +638,6 @@ export const coreScripts: MigrationScript[] = [
|
||||
await rename(file.path, `contest/${domainId}/${tid}/public/${name || type}`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
];
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user