mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-01 16:54:59 +02:00
Fix:Sanitize new podcast folder names and ensure feedUrl is in feed metadata #589
This commit is contained in:
parent
578a946ca5
commit
113026ce13
4 changed files with 17 additions and 5 deletions
|
@ -176,17 +176,20 @@ module.exports.downloadFile = async (url, filepath) => {
|
|||
})
|
||||
}
|
||||
|
||||
module.exports.sanitizeFilename = (filename, replacement = '') => {
|
||||
module.exports.sanitizeFilename = (filename, colonReplacement = ' - ') => {
|
||||
if (typeof filename !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
var replacement = ''
|
||||
var illegalRe = /[\/\?<>\\:\*\|"]/g;
|
||||
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
|
||||
var reservedRe = /^\.+$/;
|
||||
var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
|
||||
var windowsTrailingRe = /[\. ]+$/;
|
||||
|
||||
var sanitized = filename
|
||||
sanitized = filename
|
||||
.replace(':', colonReplacement) // Replace first occurrence of a colon
|
||||
.replace(illegalRe, replacement)
|
||||
.replace(controlRe, replacement)
|
||||
.replace(reservedRe, replacement)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue