Skip to content

Commit

Permalink
Merge pull request #100 from datasektionen/revert-99-fix/maybe-remove…
Browse files Browse the repository at this point in the history
…-arbitrary-file-inclusion

Revert "Fix arbitrary file incusion"
  • Loading branch information
TerraDOOM authored Nov 8, 2022
2 parents c625079 + 1361b61 commit 781bbe3
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions server/fileupload.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
var fs = Npm.require('fs')
var path = Npm.require('path')

var basedir = "../../../../../uploaded/"

Router.map(function() {
this.route('files', {
path: '/uploaded/:path',
where: 'server',
action: function() {
var p = path.join(basedir, this.params.path)
if (!p.startsWith(basedir)) {
this.response.writeHead(400)
return this.response.end()
}
var file = fs.readFileSync(p)
var path = this.params.path
var basedir = "../../../../../uploaded/"
var file = fs.readFileSync(basedir + path)
this.response.writeHead(200)
return this.response.end(file)
}
Expand All @@ -23,11 +17,7 @@ Router.map(function() {

Meteor.methods({
"file-upload": function(info, data) {
var p = path.join(basedir, info.name)
if (!p.startsWith(basedir)) {
this.response.writeHead(400)
return this.response.end()
}
var path = "../../../../../uploaded/" + info.name
if(info.type.split("/")[0] == "image") {
fs.writeFileSync(path, new Buffer(data, 'binary'))
} else {
Expand Down

0 comments on commit 781bbe3

Please sign in to comment.