mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 13:32:45 +00:00
Catch zero length filenames
This commit is contained in:
@@ -8,10 +8,13 @@ const shareFunction = function(req, res, type) {
|
|||||||
GoogleActions.readFileMetadata(config.get('google_api_key'), googleId, shareId, 'share')
|
GoogleActions.readFileMetadata(config.get('google_api_key'), googleId, shareId, 'share')
|
||||||
.then((brew)=>{
|
.then((brew)=>{
|
||||||
if(type == 'source') {
|
if(type == 'source') {
|
||||||
return res.status(200).send(brew.sanitizeHtml());
|
return res.status(200).send(brew.escapeTextForHtmlDisplay());
|
||||||
} else if(type == 'download') {
|
} else if(type == 'download') {
|
||||||
let fileName = sanitizeFilename(brew.title);
|
let fileName = sanitizeFilename(brew.title);
|
||||||
fileName = fileName.replaceAll(' ', '-');
|
fileName = fileName.replaceAll(' ', '-');
|
||||||
|
if(!fileName || !fileName.length) {
|
||||||
|
fileName = 'Untitled-Brew';
|
||||||
|
}
|
||||||
res.status(200);
|
res.status(200);
|
||||||
res.set({
|
res.set({
|
||||||
'Cache-Control' : 'no-cache',
|
'Cache-Control' : 'no-cache',
|
||||||
@@ -31,7 +34,7 @@ const shareFunction = function(req, res, type) {
|
|||||||
HomebrewModel.get({ shareId: req.params.id })
|
HomebrewModel.get({ shareId: req.params.id })
|
||||||
.then((brew)=>{
|
.then((brew)=>{
|
||||||
if(type == 'source') {
|
if(type == 'source') {
|
||||||
return res.status(200).send(brew.sanitizeHtml());
|
return res.status(200).send(brew.escapeTextForHtmlDisplay());
|
||||||
} else if(type == 'download') {
|
} else if(type == 'download') {
|
||||||
let fileName = sanitizeFilename(brew.title);
|
let fileName = sanitizeFilename(brew.title);
|
||||||
fileName = fileName.replaceAll(' ', '-');
|
fileName = fileName.replaceAll(' ', '-');
|
||||||
|
|||||||
Reference in New Issue
Block a user