mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add lang.isBinary option
This commit is contained in:
3 files changed
+4
-3
No files matched your search
@@ -483,8 +483,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
|||||||
if (!file || file.size === 0) throw new ValidationError('code');
|
if (!file || file.size === 0) throw new ValidationError('code');
|
||||||
const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : lengthLimit;
|
const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : lengthLimit;
|
||||||
if (file.size > sizeLimit) throw new ValidationError('file');
|
if (file.size > sizeLimit) throw new ValidationError('file');
|
||||||
if (file.size < lengthLimit && !file.filepath.endsWith('.zip')) {
|
if (file.size < lengthLimit && !file.filepath.endsWith('.zip') && !setting.langs[lang].isBinary) {
|
||||||
// TODO auto detect & convert encoding
|
|
||||||
// TODO submission file shape
|
// TODO submission file shape
|
||||||
code = await readFile(file.filepath, 'utf-8');
|
code = await readFile(file.filepath, 'utf-8');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export interface ProblemSource {
|
|||||||
source?: string,
|
source?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildContent(source: ProblemSource, type: 'markdown' | 'html' = 'markdown', translate?: Function) {
|
export function buildContent(source: ProblemSource, type: 'markdown' | 'html' = 'markdown', translate?: (s: string) => string) {
|
||||||
const _ = translate || ((s: string) => s);
|
const _ = translate || ((s: string) => s);
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
// Keep it for backward compatibility, but don't add to typings
|
// Keep it for backward compatibility, but don't add to typings
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface LangConfig {
|
|||||||
target?: string;
|
target?: string;
|
||||||
key: string;
|
key: string;
|
||||||
hidden: boolean;
|
hidden: boolean;
|
||||||
|
isBinary?: boolean;
|
||||||
analysis?: string;
|
analysis?: string;
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
remote?: string;
|
remote?: string;
|
||||||
@@ -52,6 +53,7 @@ export function parseLang(config: string): Record<string, LangConfig> {
|
|||||||
entry.key = key;
|
entry.key = key;
|
||||||
entry.hidden ||= false;
|
entry.hidden ||= false;
|
||||||
entry.disabled ||= false;
|
entry.disabled ||= false;
|
||||||
|
entry.isBinary ||= false;
|
||||||
entry.validAs ||= {};
|
entry.validAs ||= {};
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
|
|||||||
Reference in new issue
Block a user