mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'node-6.9'
This commit is contained in:
commit
e4e8520f27
14 changed files with 3369 additions and 3482 deletions
|
@ -1 +1 @@
|
|||
0.10.22
|
||||
6.9.5
|
||||
|
|
|
@ -85,10 +85,10 @@ module.exports = CompileController =
|
|||
res.contentType("application/pdf")
|
||||
if !!req.query.popupDownload
|
||||
logger.log project_id: project_id, "download pdf as popup download"
|
||||
res.header('Content-Disposition', "attachment; filename=#{project.getSafeProjectName()}.pdf")
|
||||
res.setContentDisposition('attachment', {filename: "#{project.getSafeProjectName()}.pdf"})
|
||||
else
|
||||
logger.log project_id: project_id, "download pdf to embed in browser"
|
||||
res.header('Content-Disposition', "filename=#{project.getSafeProjectName()}.pdf")
|
||||
res.setContentDisposition('', {filename: "#{project.getSafeProjectName()}.pdf"})
|
||||
|
||||
rateLimit (err, canContinue)->
|
||||
if err?
|
||||
|
|
|
@ -15,9 +15,9 @@ module.exports = ProjectDownloadsController =
|
|||
return next(error) if error?
|
||||
ProjectZipStreamManager.createZipStreamForProject project_id, (error, stream) ->
|
||||
return next(error) if error?
|
||||
res.header(
|
||||
"Content-Disposition",
|
||||
"attachment; filename=#{encodeURIComponent(project.name)}.zip"
|
||||
res.setContentDisposition(
|
||||
'attachment',
|
||||
{filename: "#{project.name}.zip"}
|
||||
)
|
||||
res.contentType('application/zip')
|
||||
stream.pipe(res)
|
||||
|
@ -30,9 +30,9 @@ module.exports = ProjectDownloadsController =
|
|||
return next(error) if error?
|
||||
ProjectZipStreamManager.createZipStreamForMultipleProjects project_ids, (error, stream) ->
|
||||
return next(error) if error?
|
||||
res.header(
|
||||
"Content-Disposition",
|
||||
"attachment; filename=ShareLaTeX Projects (#{project_ids.length} items).zip"
|
||||
res.setContentDisposition(
|
||||
'attachment',
|
||||
{filename: "ShareLaTeX Projects (#{project_ids.length} items).zip"}
|
||||
)
|
||||
res.contentType('application/zip')
|
||||
stream.pipe(res)
|
||||
|
|
|
@ -35,5 +35,5 @@ module.exports =
|
|||
if (is_mobile_safari(user_agent) and is_html(file))
|
||||
logger.log filename: file.name, user_agent: user_agent, "sending html file to mobile-safari as plain text"
|
||||
res.setHeader('Content-Type', 'text/plain')
|
||||
res.setHeader("Content-Disposition", "attachment; filename=#{file.name}")
|
||||
res.setContentDisposition('attachment', {filename: file.name})
|
||||
stream.pipe res
|
||||
|
|
|
@ -71,6 +71,19 @@ module.exports = (app, webRouter, apiRouter)->
|
|||
res.locals.session = req.session
|
||||
next()
|
||||
|
||||
addSetContentDisposition = (req, res, next) ->
|
||||
res.setContentDisposition = (type, opts) ->
|
||||
directives = for k, v of opts
|
||||
"#{k}=\"#{encodeURIComponent(v)}\""
|
||||
contentDispositionValue = "#{type}; #{directives.join('; ')}"
|
||||
res.setHeader(
|
||||
'Content-Disposition',
|
||||
contentDispositionValue
|
||||
)
|
||||
next()
|
||||
webRouter.use addSetContentDisposition
|
||||
apiRouter.use addSetContentDisposition
|
||||
|
||||
webRouter.use (req, res, next)->
|
||||
|
||||
cdnBlocked = req.query.nocdn == 'true' or req.session.cdnBlocked
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Settings = require "settings-sharelatex"
|
||||
mongojs = require "mongojs"
|
||||
db = mongojs.connect(Settings.mongo.url, ["projects", "users"])
|
||||
db = mongojs(Settings.mongo.url, ["projects", "users"])
|
||||
module.exports =
|
||||
db: db
|
||||
ObjectId: mongojs.ObjectId
|
||||
|
|
6753
services/web/npm-shrinkwrap.json
generated
6753
services/web/npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,7 @@
|
|||
"async": "0.6.2",
|
||||
"base64-stream": "^0.1.2",
|
||||
"basic-auth-connect": "^1.0.0",
|
||||
"bcrypt": "0.8.3",
|
||||
"bcrypt": "1.0.1",
|
||||
"body-parser": "^1.13.1",
|
||||
"bufferedstream": "1.6.0",
|
||||
"connect-redis": "^3.1.0",
|
||||
|
@ -25,21 +25,20 @@
|
|||
"dateformat": "1.0.4-1.2.3",
|
||||
"express": "4.13.0",
|
||||
"express-session": "^1.14.2",
|
||||
"grunt": "^0.4.5",
|
||||
"heapdump": "^0.3.7",
|
||||
"http-proxy": "^1.8.1",
|
||||
"ioredis": "^2.4.0",
|
||||
"jade": "~1.3.1",
|
||||
"ldapjs": "^1.0.0",
|
||||
"ldapjs": "^0.7.1",
|
||||
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#master",
|
||||
"lodash": "^4.13.1",
|
||||
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.3.1",
|
||||
"lynx": "0.1.1",
|
||||
"marked": "^0.3.5",
|
||||
"method-override": "^2.3.3",
|
||||
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
|
||||
"mimelib": "0.2.14",
|
||||
"mocha": "1.17.1",
|
||||
"mongojs": "0.18.2",
|
||||
"mongojs": "2.4.0",
|
||||
"mongoose": "4.1.0",
|
||||
"multer": "^0.1.8",
|
||||
"nodemailer": "2.1.0",
|
||||
|
@ -72,6 +71,7 @@
|
|||
"bunyan": "0.22.1",
|
||||
"chai": "",
|
||||
"chai-spies": "",
|
||||
"grunt": "0.4.5",
|
||||
"clean-css": "^3.4.18",
|
||||
"es6-promise": "^4.0.5",
|
||||
"grunt-available-tasks": "0.4.1",
|
||||
|
|
|
@ -128,16 +128,14 @@ describe "AuthenticationManager", ->
|
|||
@AuthenticationManager.setUserPassword(@user_id, @password, @callback)
|
||||
|
||||
it "should update the user's password in the database", ->
|
||||
@db.users.update
|
||||
.calledWith({
|
||||
_id: ObjectId(@user_id.toString())
|
||||
}, {
|
||||
$set: {
|
||||
"hashedPassword": @hashedPassword
|
||||
}
|
||||
$unset: password: true
|
||||
})
|
||||
.should.equal true
|
||||
args = @db.users.update.lastCall.args
|
||||
expect(args[0]).to.deep.equal {_id: ObjectId(@user_id.toString())}
|
||||
expect(args[1]).to.deep.equal {
|
||||
$set: {
|
||||
"hashedPassword": @hashedPassword
|
||||
}
|
||||
$unset: password: true
|
||||
}
|
||||
|
||||
it "should hash the password", ->
|
||||
@bcrypt.genSalt
|
||||
|
|
|
@ -136,8 +136,8 @@ describe "CompileController", ->
|
|||
.should.equal true
|
||||
|
||||
it "should set the content-disposition header with the project name", ->
|
||||
@res.header
|
||||
.calledWith("Content-Disposition", "filename=#{@safe_name}.pdf")
|
||||
@res.setContentDisposition
|
||||
.calledWith('', {filename: "#{@safe_name}.pdf"})
|
||||
.should.equal true
|
||||
|
||||
it "should increment the pdf-downloads metric", ->
|
||||
|
|
|
@ -59,10 +59,10 @@ describe "ProjectDownloadsController", ->
|
|||
@Project.findById.calledWith(@project_id, "name").should.equal(true)
|
||||
|
||||
it "should name the downloaded file after the project", ->
|
||||
@res.header
|
||||
@res.setContentDisposition
|
||||
.calledWith(
|
||||
"Content-Disposition",
|
||||
"attachment; filename=#{encodeURIComponent(@project_name)}.zip")
|
||||
'attachment',
|
||||
{filename: "#{@project_name}.zip"})
|
||||
.should.equal true
|
||||
|
||||
it "should record the action via Metrics", ->
|
||||
|
@ -107,10 +107,10 @@ describe "ProjectDownloadsController", ->
|
|||
.should.equal true
|
||||
|
||||
it "should name the downloaded file after the project", ->
|
||||
@res.header
|
||||
@res.setContentDisposition
|
||||
.calledWith(
|
||||
"Content-Disposition",
|
||||
"attachment; filename=ShareLaTeX Projects (2 items).zip")
|
||||
'attachment',
|
||||
{filename: "ShareLaTeX Projects (2 items).zip"})
|
||||
.should.equal true
|
||||
|
||||
it "should record the action via Metrics", ->
|
||||
|
|
|
@ -29,6 +29,7 @@ describe "FileStoreController", ->
|
|||
get: (key) -> undefined
|
||||
@res =
|
||||
setHeader: sinon.stub()
|
||||
setContentDisposition: sinon.stub()
|
||||
@file =
|
||||
name: "myfile.png"
|
||||
|
||||
|
@ -62,7 +63,9 @@ describe "FileStoreController", ->
|
|||
|
||||
it "should set the Content-Disposition header", (done)->
|
||||
@stream.pipe = (des)=>
|
||||
@res.setHeader.calledWith("Content-Disposition", "attachment; filename=#{@file.name}").should.equal true
|
||||
@res.setContentDisposition.calledWith(
|
||||
"attachment", {filename: @file.name}
|
||||
).should.equal true
|
||||
done()
|
||||
@controller.getFile @req, @res
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ describe "ProjectGetter", ->
|
|||
@ProjectGetter.getProjectWithoutDocLines @project_id, @callback
|
||||
|
||||
it "should call find with the project id", ->
|
||||
@db.projects.find.calledWith(_id: ObjectId(@project_id)).should.equal true
|
||||
expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
||||
_id: ObjectId(@project_id)
|
||||
}
|
||||
|
||||
it "should exclude the doc lines", ->
|
||||
excludes =
|
||||
|
@ -65,7 +67,9 @@ describe "ProjectGetter", ->
|
|||
@ProjectGetter.getProjectWithOnlyFolders @project_id, @callback
|
||||
|
||||
it "should call find with the project id", ->
|
||||
@db.projects.find.calledWith(_id: ObjectId(@project_id)).should.equal true
|
||||
expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
||||
_id: ObjectId(@project_id)
|
||||
}
|
||||
|
||||
it "should exclude the docs and files linesaaaa", ->
|
||||
excludes =
|
||||
|
@ -103,7 +107,9 @@ describe "ProjectGetter", ->
|
|||
@ProjectGetter.getProjectWithOnlyFolders @project_id, @callback
|
||||
|
||||
it "should call find with the project id", ->
|
||||
@db.projects.find.calledWith(_id: ObjectId(@project_id)).should.equal true
|
||||
expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
||||
_id: ObjectId(@project_id)
|
||||
}
|
||||
|
||||
it "should exclude the docs and files linesaaaa", ->
|
||||
excludes =
|
||||
|
|
|
@ -70,6 +70,8 @@ class MockResponse
|
|||
setHeader: (header, value) ->
|
||||
@headers[header] = value
|
||||
|
||||
setContentDisposition: sinon.stub()
|
||||
|
||||
setTimeout: (@timout)->
|
||||
|
||||
header: sinon.stub()
|
||||
|
|
Loading…
Reference in a new issue