import: Allow import if pad does not yet exist

pull/4391/head
Richard Hansen 2020-10-01 21:27:23 -04:00 committed by John McLear
parent ed6fcefb67
commit 831528e8bc
2 changed files with 0 additions and 15 deletions

View File

@ -62,11 +62,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
// handle import requests // handle import requests
args.app.use('/p/:pad/import', limiter); args.app.use('/p/:pad/import', limiter);
args.app.post('/p/:pad/import', async function(req, res, next) { args.app.post('/p/:pad/import', async function(req, res, next) {
if (!(await padManager.doesPadExists(req.params.pad))) {
console.warn(`Someone tried to import into a pad that doesn't exist (${req.params.pad})`);
return next();
}
const {session: {user} = {}} = req; const {session: {user} = {}} = req;
const {accessStatus, authorID} = await securityManager.checkAccess( const {accessStatus, authorID} = await securityManager.checkAccess(
req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password, user); req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password, user);

View File

@ -211,16 +211,6 @@ describe('Imports and Exports', function(){
.expect(/<ul class="bullet"><li><ul class="bullet"><li>hello<\/ul><\/li><\/ul>/); .expect(/<ul class="bullet"><li><ul class="bullet"><li>hello<\/ul><\/li><\/ul>/);
}); });
it('tries to import Plain Text to a pad that does not exist', async function() {
const padId = testPadId + testPadId + testPadId;
await agent.post(`/p/${padId}/import`)
.attach('file', padText, {filename: '/test.txt', contentType: 'text/plain'})
.expect(405);
await agent.get(endPoint('getText') + `&padID=${padId}`)
.expect(200)
.expect((res) => assert.equal(res.body.code, 1));
});
it('Tries to import unsupported file type', async function() { it('Tries to import unsupported file type', async function() {
settings.allowUnknownFileEnds = false; settings.allowUnknownFileEnds = false;
await agent.post(`/p/${testPadId}/import`) await agent.post(`/p/${testPadId}/import`)