mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-16 19:08:42 +01:00
Fix:Sanitize new podcast folder names and ensure feedUrl is in feed metadata #589
This commit is contained in:
parent
578a946ca5
commit
113026ce13
@ -151,7 +151,7 @@ export default {
|
||||
this.fullPath = ''
|
||||
return
|
||||
}
|
||||
this.fullPath = Path.join(this.selectedFolderPath, this.podcast.title)
|
||||
this.fullPath = Path.join(this.selectedFolderPath, this.$sanitizeFilename(this.podcast.title))
|
||||
},
|
||||
submit() {
|
||||
const podcastPayload = {
|
||||
|
@ -114,10 +114,11 @@ Vue.prototype.$calculateTextSize = (text, styles = {}) => {
|
||||
}
|
||||
}
|
||||
|
||||
Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
|
||||
Vue.prototype.$sanitizeFilename = (input, colonReplacement = ' - ') => {
|
||||
if (typeof input !== 'string') {
|
||||
return false
|
||||
}
|
||||
var replacement = ''
|
||||
var illegalRe = /[\/\?<>\\:\*\|"]/g;
|
||||
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
|
||||
var reservedRe = /^\.+$/;
|
||||
@ -125,6 +126,7 @@ Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
|
||||
var windowsTrailingRe = /[\. ]+$/;
|
||||
|
||||
var sanitized = input
|
||||
.replace(':', colonReplacement) // Replace first occurrence of a colon
|
||||
.replace(illegalRe, replacement)
|
||||
.replace(controlRe, replacement)
|
||||
.replace(reservedRe, replacement)
|
||||
|
@ -1,9 +1,10 @@
|
||||
const axios = require('axios')
|
||||
const fs = require('fs-extra')
|
||||
const Path = require('path')
|
||||
const Logger = require('../Logger')
|
||||
const { parsePodcastRssFeedXml } = require('../utils/podcastUtils')
|
||||
const LibraryItem = require('../objects/LibraryItem')
|
||||
const { getFileTimestampsWithIno } = require('../utils/fileUtils')
|
||||
const { getFileTimestampsWithIno, sanitizeFilename } = require('../utils/fileUtils')
|
||||
const filePerms = require('../utils/filePerms')
|
||||
|
||||
class PodcastController {
|
||||
@ -107,6 +108,12 @@ class PodcastController {
|
||||
if (!payload) {
|
||||
return res.status(500).send('Invalid podcast RSS feed')
|
||||
}
|
||||
|
||||
if (!payload.podcast.metadata.feedUrl) {
|
||||
// Not every RSS feed will put the feed url in their metadata
|
||||
payload.podcast.metadata.feedUrl = url
|
||||
}
|
||||
|
||||
res.json(payload)
|
||||
}).catch((error) => {
|
||||
console.error('Failed', error)
|
||||
|
@ -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…
Reference in New Issue
Block a user