mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: 修复base64文件名中出现/会导致无法下载的问题
This commit is contained in:
1 parent
7371b0c83c
commit
36fef2cd20
16 files changed
+45
-40
No files matched your search
+3
-3
@@ -20,7 +20,7 @@
|
||||
"devDependencies": {
|
||||
"@shelf/jest-mongodb": "^1.2.3",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^26.0.14",
|
||||
"@types/jest": "^26.0.18",
|
||||
"@types/node": "^14.14.10",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||
@@ -34,12 +34,12 @@
|
||||
"jest": "^26.6.3",
|
||||
"latest-version": "^5.1.0",
|
||||
"ora": "^5.1.0",
|
||||
"semver": "^7.3.2",
|
||||
"semver": "^7.3.4",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "4.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^9.0.1",
|
||||
"yargs": "^16.1.1"
|
||||
"yargs": "^16.2.0"
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,14 @@
|
||||
"author": "undefined <masnn0@outlook.com>",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.16",
|
||||
"adm-zip": "^0.5.1",
|
||||
"decode-html": "^2.0.0",
|
||||
"fs-extra": "^9.0.1",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/xml2js": "^0.4.7",
|
||||
"bson": "^4.1.0"
|
||||
"bson": "^4.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "^2.14.0"
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
"author": "masnn",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.16",
|
||||
"adm-zip": "^0.5.1",
|
||||
"axios": "^0.21.0",
|
||||
"bson": "^4.1.0",
|
||||
"bson": "^4.2.2",
|
||||
"fs-extra": "^9.0.1",
|
||||
"js-yaml": "^3.14.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.20",
|
||||
"p-queue": "^6.6.1",
|
||||
"shell-quote": "^1.7.2",
|
||||
"supports-color": "^8.0.0",
|
||||
"systeminformation": "^4.30.6",
|
||||
"yargs": "^16.1.1"
|
||||
"systeminformation": "^4.31.0",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "^2.13.3"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.14.7",
|
||||
"version": "2.14.8",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -11,12 +11,12 @@
|
||||
"node": ">=10.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.16",
|
||||
"adm-zip": "^0.5.1",
|
||||
"ansi_up": "^4.0.4",
|
||||
"cookies": "^0.8.0",
|
||||
"detect-browser": "^5.1.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"js-yaml": "^3.14.1",
|
||||
"koa": "^2.13.0",
|
||||
"koa-body": "^4.2.0",
|
||||
"koa-router": "^10.0.0",
|
||||
@@ -31,9 +31,9 @@
|
||||
"sockjs": "^0.3.20",
|
||||
"superagent": "^6.1.0",
|
||||
"supports-color": "^8.0.0",
|
||||
"systeminformation": "^4.30.6",
|
||||
"systeminformation": "^4.31.0",
|
||||
"wtfnode": "^0.8.4",
|
||||
"yargs": "^16.1.1"
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/adm-zip": "^0.4.33",
|
||||
@@ -51,7 +51,7 @@
|
||||
"@types/superagent": "^4.1.8",
|
||||
"@types/supports-color": "^7.2.0",
|
||||
"@types/wtfnode": "^0.7.0",
|
||||
"@types/yargs": "^15.0.10"
|
||||
"@types/yargs": "^15.0.11"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
|
||||
@@ -148,7 +148,6 @@ class DomainPermissionHandler extends ManageHandler {
|
||||
: [this.request.body[role]];
|
||||
// @ts-ignore
|
||||
roles[role] = 0n;
|
||||
console.log(role, perms);
|
||||
// @ts-ignore
|
||||
for (const r of perms) roles[role] += 1n << BigInt(r);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { JudgeResultBody, Rdoc, TestCase } from '../interface';
|
||||
import { sleep } from '../utils';
|
||||
import { Logger } from '../logger';
|
||||
import * as record from '../model/record';
|
||||
import * as problem from '../model/problem';
|
||||
import * as builtin from '../model/builtin';
|
||||
@@ -12,6 +13,8 @@ import {
|
||||
Route, Handler, Connection, ConnectionHandler,
|
||||
} from '../service/server';
|
||||
|
||||
const logger = new Logger('judge');
|
||||
|
||||
async function _postJudge(rdoc: Rdoc) {
|
||||
const accept = rdoc.status === builtin.STATUS.STATUS_ACCEPTED;
|
||||
const tasks = [];
|
||||
@@ -135,7 +138,7 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
|
||||
async message(msg) {
|
||||
console.log(msg);
|
||||
logger.info('%o', msg);
|
||||
if (msg.key === 'next') await next(msg);
|
||||
else if (msg.key === 'end') {
|
||||
await end({ judger: this.user._id, ...msg });
|
||||
|
||||
@@ -17,8 +17,8 @@ class FileDownloadHandler extends Handler {
|
||||
@param('fileId', Types.ObjectID)
|
||||
@param('secret', Types.String)
|
||||
@param('name', Types.String, true)
|
||||
async get(domainId: string, fileId: ObjectID, secret: string, name: string) {
|
||||
if (name) name = Buffer.from(name, 'base64').toString();
|
||||
async get(domainId: string, fileId: ObjectID, secret: string, name?: string) {
|
||||
if (name) name = Buffer.from(name.replace(/~/g, '/'), 'base64').toString();
|
||||
const doc = await file.getWithSecret(fileId, secret);
|
||||
this.response.attachment(name || fileId.toHexString(), doc);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { streamToBuffer } from '../utils';
|
||||
import {
|
||||
Pdoc, User, Rdoc, PathComponent,
|
||||
} from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
import paginate from '../lib/paginate';
|
||||
import { isTitle, isContent, isPid } from '../lib/validator';
|
||||
import { ProblemAdd } from '../lib/ui';
|
||||
@@ -28,6 +29,7 @@ import {
|
||||
|
||||
export const parseCategory = (value: string) => flatten(value.split('+').map((e) => e.split(','))).map((e) => e.trim());
|
||||
export const parsePid = (value: string) => (isSafeInteger(value) ? parseInt(value, 10) : value);
|
||||
const logger = new Logger('problem');
|
||||
|
||||
export class ProblemHandler extends Handler {
|
||||
async __prepare() {
|
||||
@@ -226,6 +228,7 @@ export class ProblemDetailHandler extends ProblemHandler {
|
||||
async postRejudge(domainId: string, pid: number) {
|
||||
this.checkPerm(PERM.PERM_REJUDGE_PROBLEM);
|
||||
// TODO maybe async?
|
||||
console.log(await record.getMulti(domainId, { pid }).count());
|
||||
await record.getMulti(domainId, { pid }).forEach(async (doc) => {
|
||||
await record.reset(domainId, doc._id, true);
|
||||
await record.judge(domainId, doc._id, -1);
|
||||
|
||||
@@ -495,7 +495,7 @@ export const ContestHandlerMixin = (c) => class extends c {
|
||||
async getScoreboard(
|
||||
domainId: string, tid: ObjectID,
|
||||
isExport = false, docType: 30 | 60 = document.TYPE_CONTEST,
|
||||
): Promise<[Tdoc, ScoreboardNode[][], Udict]> {
|
||||
): Promise<[Tdoc, ScoreboardRow[], Udict]> {
|
||||
const {
|
||||
tdoc, udict, pdict, rankedTsdocs,
|
||||
} = await this.getRawStatus(domainId, tid, docType);
|
||||
|
||||
@@ -97,22 +97,22 @@ export function getMulti(query: any) {
|
||||
return coll.find(query);
|
||||
}
|
||||
|
||||
async function _url(_id: ObjectID, name: string | undefined) {
|
||||
async function _url(_id: ObjectID, name?: string) {
|
||||
const file = await coll.findOne({ _id });
|
||||
const secret = hash(file.secret, _timestamp().toString());
|
||||
if (name) return `/fs/${_id}/${Buffer.from(name).toString('base64')}/${secret}`;
|
||||
if (name) return `/fs/${_id}/${Buffer.from(name).toString('base64').replace(/\//g, '~')}/${secret}`;
|
||||
return `/fs/${_id}/${secret}`;
|
||||
}
|
||||
|
||||
function __url(file: any, name: string | undefined) {
|
||||
function __url(file: Ufdoc, name?: string) {
|
||||
const secret = hash(file.secret, _timestamp().toString());
|
||||
if (name) return `/fs/${file._id}/${Buffer.from(name).toString('base64')}/${secret}`;
|
||||
if (name) return `/fs/${file._id}/${Buffer.from(name).toString('base64').replace(/\//g, '~')}/${secret}`;
|
||||
return `/fs/${file._id}/${secret}`;
|
||||
}
|
||||
|
||||
export function url(_id: ObjectID, name: string | undefined): Promise<string>;
|
||||
export function url(file: any, name: string | undefined): string;
|
||||
export function url(arg0: any, name: any) {
|
||||
export function url(_id: ObjectID, name?: string): Promise<string>;
|
||||
export function url(file: Ufdoc, name: string): string;
|
||||
export function url(arg0: ObjectID | Ufdoc, name?: string) {
|
||||
if (arg0 instanceof ObjectID) return _url(arg0, name);
|
||||
return __url(arg0, name);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ export async function create(
|
||||
gravatar: mail,
|
||||
});
|
||||
} catch (e) {
|
||||
logger.warn(e);
|
||||
logger.warn('%o', e);
|
||||
throw new UserAlreadyExistError([uid, uname, mail]);
|
||||
}
|
||||
return uid;
|
||||
|
||||
@@ -126,7 +126,7 @@ export async function serial<K extends keyof EventMap>(name: K, ...args: Paramet
|
||||
if (argv.showBus) logger.debug('serial: %s %o', name, args);
|
||||
const hooks = Array.from(_hooks[name] || []);
|
||||
for (const callback of hooks) {
|
||||
if (argv.busDetail) console.log(callback.toString());
|
||||
if (argv.busDetail) logger.debug(callback.toString());
|
||||
await callback.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,9 +443,9 @@ export class Handler {
|
||||
res = router.url(name, args, { query });
|
||||
if (anchor) return `${res}#${anchor}`;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
console.log(name, args);
|
||||
console.log(e.stack);
|
||||
logger.warn(e.message);
|
||||
logger.info('%s %o', name, args);
|
||||
logger.info('%s', e.stack);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -790,8 +790,8 @@ export class ConnectionHandler {
|
||||
res = router.url(name, args, { query });
|
||||
if (anchor) return `${res}#${anchor}`;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
console.log(name, args);
|
||||
logger.error(e.message);
|
||||
logger.info(name, args);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -877,7 +877,7 @@ export function Connection(
|
||||
if (h.finish) await h.finish(args);
|
||||
});
|
||||
} catch (e) {
|
||||
logger.warn(e);
|
||||
logger.warn('%o', e);
|
||||
await h.onerror(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.16",
|
||||
"adm-zip": "^0.5.1",
|
||||
"decode-html": "^2.0.0",
|
||||
"fs-extra": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bson": "^4.1.0"
|
||||
"bson": "^4.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "^2.14.0"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"hydrooj": "^2.13.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": "^7.4.0"
|
||||
"ws": "^7.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ws": "^7.4.0"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mysql": "^2.15.15"
|
||||
"@types/mysql": "^2.15.16"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hydrooj": "^2.14.0"
|
||||
|
||||
Reference in new issue
Block a user