This commit is contained in:
May 2023-01-26 22:01:47 -08:00
parent 8f2f6d2778
commit 1ba3b271ea
3 changed files with 16 additions and 5 deletions

View file

@ -20,8 +20,9 @@ TOKEN=KILL-YOURSELF.NOW
- [X] 1.2.0 add file parameters section + custom ids - [X] 1.2.0 add file parameters section + custom ids
- [X] 1.2.1 add file counter to main page - [X] 1.2.1 add file counter to main page
- [X] 1.2.2 clean up this shitty code - [X] 1.2.2 clean up this shitty code
- [ ] 1.2.3 add id locks, allowing you to set a key for a file that allows you to overwrite the file in the future - [X] 1.2.3 bugfixes
- [ ] 1.2.4 prevent cloning of local/private ip addresses - [ ] 1.2.4 add id locks, allowing you to set a key for a file that allows you to overwrite the file in the future
- [ ] 1.2.5 prevent cloning of local/private ip addresses
- [ ] 1.3.0 add simple moderation tools - [ ] 1.3.0 add simple moderation tools
- [ ] 2.0.0 rewrite using theUnfunny's code as a base/rewrite using monofile-core - [ ] 2.0.0 rewrite using theUnfunny's code as a base/rewrite using monofile-core

View file

@ -1,6 +1,6 @@
{ {
"name": "monofile", "name": "monofile",
"version": "1.2.2", "version": "1.2.3",
"description": "Discord-based file sharing", "description": "Discord-based file sharing",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View file

@ -106,7 +106,7 @@ app.post("/clone",(req,res) => {
res.send("[err] invalid url") res.send("[err] invalid url")
} }
axios.get(j.url,{responseType:"arraybuffer"}).then((data:AxiosResponse) => { axios.get(j.url,{responseType:"arraybuffer"}).then((data:AxiosResponse) => {
files.uploadFile({name:req.body.split("/")[req.body.split("/").length-1] || "generic",mime:data.headers["content-type"],uploadId:j.uploadId},Buffer.from(data.data)) files.uploadFile({name:j.url.split("/")[req.body.split("/").length-1] || "generic",mime:data.headers["content-type"],uploadId:j.uploadId},Buffer.from(data.data))
.then((uID) => res.send(uID)) .then((uID) => res.send(uID))
.catch((stat) => {res.status(stat.status);res.send(`[err] ${stat.message}`)}) .catch((stat) => {res.status(stat.status);res.send(`[err] ${stat.message}`)})
}).catch((err) => { }).catch((err) => {
@ -128,7 +128,17 @@ app.get("/download/:fileId",(req,res) => {
fs.readFile(__dirname+"/../pages/download.html",(err,buf) => { fs.readFile(__dirname+"/../pages/download.html",(err,buf) => {
if (err) {res.sendStatus(500);console.log(err);return} if (err) {res.sendStatus(500);console.log(err);return}
res.send(buf.toString().replace(/\$FileId/g,req.params.fileId).replace(/\$Version/g,pkg.version).replace(/\$FileName/g,file.filename)) res.send(
buf.toString()
.replace(/\$FileId/g,req.params.fileId)
.replace(/\$Version/g,pkg.version)
.replace(/\$FileName/g,
file.filename
.replace(/\&/g,"&")
.replace(/\</g,"&lt;")
.replace(/\>/g,"&gt;")
)
)
}) })
} else { } else {
ThrowError(res,404,"File not found.") ThrowError(res,404,"File not found.")