Skip to content

Commit

Permalink
Metadata removal
Browse files Browse the repository at this point in the history
  • Loading branch information
madprops committed Jan 16, 2025
1 parent a898ea1 commit cc85e24
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"tar": "~6.1.11",
"yaml": "~2.1.1",
"eslint": "~9.17.0",
"globals": "~15.9.0"
"globals": "~15.9.0",
"exiftool-vendored": "~29.0.0"
}
}
1 change: 1 addition & 0 deletions server/sockets/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports = (App) => {
App.i.cheerio = require(`cheerio`)
App.i.redis = require(`redis`)
App.i.he = require(`he`)
App.i.exiftool = require(`exiftool-vendored`).exiftool
}
1 change: 1 addition & 0 deletions server/sockets/modules/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = (App) => {

try {
await App.i.fsp.writeFile(path, data.file)
await App.strip_metadata(path)

let obj = {}

Expand Down
1 change: 1 addition & 0 deletions server/sockets/modules/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ module.exports = (App) => {

try {
await App.i.fsp.writeFile(path, data.image_file)
await App.strip_metadata(path)
await App.handler.do_change_background(socket, file_name, `hosted`)
}
catch (err) {
Expand Down
13 changes: 13 additions & 0 deletions server/sockets/modules/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,17 @@ module.exports = (App) => {
let full_file = Buffer.from(new Uint8Array(await res.arrayBuffer()))
return full_file
}

// Remove all metadata from a file
App.strip_metadata = async (path) => {
try {
return await App.i.exiftool.write(path, {
all: null,
})
}
catch (err) {
App.logger.log_error(err)
return path
}
}
}
2 changes: 2 additions & 0 deletions server/sockets/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ module.exports = (App) => {

try {
await App.i.fsp.writeFile(path, data.image_file)
await App.strip_metadata(path)
await App.handler.do_change_profilepic(socket, file_name)
}
catch (err) {
Expand Down Expand Up @@ -188,6 +189,7 @@ module.exports = (App) => {

try {
await App.i.fsp.writeFile(path, data.audio_file)
await App.strip_metadata(path)
await App.handler.do_change_audioclip(socket, file_name)
}
catch (err) {
Expand Down
3 changes: 1 addition & 2 deletions server/www
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,10 @@ function on_error(error) {
case `EACCES`:
console.error(bind + ` requires elevated privileges`)
process.exit(1)
break

case `EADDRINUSE`:
console.error(bind + ` is already in use`)
process.exit(1)
break

default:
throw error
Expand All @@ -269,6 +267,7 @@ function on_listening() {
function do_shutdown() {
App.vars.exiting = true

App.i.exiftool.end()
io.httpServer.close()
io.close()

Expand Down

0 comments on commit cc85e24

Please sign in to comment.