0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-28 07:02:38 +00:00

Catch zero length filenames

This commit is contained in:
G.Ambatte
2021-01-21 07:39:08 +13:00
parent 8060ed5f8e
commit 0e8348f360

View File

@@ -8,10 +8,13 @@ const shareFunction = function(req, res, type) {
GoogleActions.readFileMetadata(config.get('google_api_key'), googleId, shareId, 'share')
.then((brew)=>{
if(type == 'source') {
return res.status(200).send(brew.sanitizeHtml());
return res.status(200).send(brew.escapeTextForHtmlDisplay());
} else if(type == 'download') {
let fileName = sanitizeFilename(brew.title);
fileName = fileName.replaceAll(' ', '-');
if(!fileName || !fileName.length) {
fileName = 'Untitled-Brew';
}
res.status(200);
res.set({
'Cache-Control' : 'no-cache',
@@ -31,7 +34,7 @@ const shareFunction = function(req, res, type) {
HomebrewModel.get({ shareId: req.params.id })
.then((brew)=>{
if(type == 'source') {
return res.status(200).send(brew.sanitizeHtml());
return res.status(200).send(brew.escapeTextForHtmlDisplay());
} else if(type == 'download') {
let fileName = sanitizeFilename(brew.title);
fileName = fileName.replaceAll(' ', '-');