mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 09:49:24 +02:00
x-accel: encode all paths to URIs
updates util function encodeUriPath to use node:url with a file:// path prefix, and updates all instances x-accel redirection to use this helper util instead of sending unencoded paths into the header.
This commit is contained in:
parent
e56b8edc0a
commit
207ba7ec8e
4 changed files with 26 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
|||
const Logger = require('../Logger')
|
||||
const { encodeUriPath } = require('../utils/fileUtils')
|
||||
|
||||
class BackupController {
|
||||
constructor() { }
|
||||
|
@ -37,8 +38,9 @@ class BackupController {
|
|||
*/
|
||||
download(req, res) {
|
||||
if (global.XAccel) {
|
||||
Logger.debug(`Use X-Accel to serve static file ${req.backup.fullPath}`)
|
||||
return res.status(204).header({ 'X-Accel-Redirect': global.XAccel + req.backup.fullPath }).send()
|
||||
const encodedURI = encodeUriPath(global.XAccel + req.backup.fullPath)
|
||||
Logger.debug(`Use X-Accel to serve static file ${encodedURI}`)
|
||||
return res.status(204).header({ 'X-Accel-Redirect': encodedURI }).send()
|
||||
}
|
||||
res.sendFile(req.backup.fullPath)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue