mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 11:38:42 +00:00
fix(remote_judger/codeforces): include referer when submitting problem
This commit is contained in:
parent
3d63a011ac
commit
a5a2b4547b
@ -146,8 +146,8 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
return _tta;
|
return _tta;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCsrfToken(url: string) {
|
async getCsrfToken(url: string, referer = '') {
|
||||||
const { text: html } = await this.get(url);
|
const { text: html } = await this.get(url).set('Referer', referer);
|
||||||
const {
|
const {
|
||||||
window: { document },
|
window: { document },
|
||||||
} = new JSDOM(html);
|
} = new JSDOM(html);
|
||||||
@ -257,9 +257,17 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [type, contestId, problemId] = parseProblemId(id);
|
const [type, contestId, problemId] = parseProblemId(id);
|
||||||
|
const referer =
|
||||||
|
this.account.endpoint +
|
||||||
|
(type !== 'GYM'
|
||||||
|
? `/problemset/problem/${contestId}/${problemId}`
|
||||||
|
: `/gym/${contestId}/problem/${problemId}`);
|
||||||
|
|
||||||
|
logger.debug('referer', referer);
|
||||||
|
|
||||||
const [csrf, ftaa, bfaa] = await this.getCsrfToken(
|
const [csrf, ftaa, bfaa] = await this.getCsrfToken(
|
||||||
type !== 'GYM' ? '/problemset/submit' : `/gym/${contestId}/submit`
|
type !== 'GYM' ? '/problemset/submit' : `/gym/${contestId}/submit`,
|
||||||
|
referer
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@ -275,25 +283,27 @@ export default class CodeforcesProvider implements IBasicProvider {
|
|||||||
`/${
|
`/${
|
||||||
type !== 'GYM' ? 'problemset' : `gym/${contestId}`
|
type !== 'GYM' ? 'problemset' : `gym/${contestId}`
|
||||||
}/submit?csrf_token=${csrf}`
|
}/submit?csrf_token=${csrf}`
|
||||||
).send({
|
)
|
||||||
csrf_token: csrf,
|
.send({
|
||||||
action: 'submitSolutionFormSubmitted',
|
csrf_token: csrf,
|
||||||
programTypeId: programType.id,
|
action: 'submitSolutionFormSubmitted',
|
||||||
source: code,
|
programTypeId: programType.id,
|
||||||
tabsize: 4,
|
source: code,
|
||||||
sourceFile: '',
|
tabsize: 4,
|
||||||
ftaa,
|
sourceFile: '',
|
||||||
bfaa,
|
ftaa,
|
||||||
_tta: this.tta(this.getCookie('39ce7')),
|
bfaa,
|
||||||
...(type !== 'GYM'
|
_tta: this.tta(this.getCookie('39ce7')),
|
||||||
? {
|
...(type !== 'GYM'
|
||||||
submittedProblemCode: contestId + problemId,
|
? {
|
||||||
sourceCodeConfirmed: true,
|
submittedProblemCode: contestId + problemId,
|
||||||
}
|
sourceCodeConfirmed: true,
|
||||||
: {
|
}
|
||||||
submittedProblemIndex: problemId,
|
: {
|
||||||
}),
|
submittedProblemIndex: problemId,
|
||||||
});
|
}),
|
||||||
|
})
|
||||||
|
.set('Referer', referer);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
end({
|
end({
|
||||||
|
Loading…
Reference in New Issue
Block a user