Skip to content

Node.js based forum software built for the modern web

add some checks to templatesOnDemand

Barış Soner Uşaklı575b70b5ab52
diff --git a/src/middleware/index.js b/src/middleware/index.js
index c0cce7623a..b1e065b3fd 100644
--- a/src/middleware/index.js
+++ b/src/middleware/index.js
@@ -237,12 +237,18 @@ middleware.templatesOnDemand = function (req, res, next) {
fs.readFile(filePath.replace(/\.js$/, '.tpl'), 'utf8', cb);
},
function (source, cb) {
+ if (!source) {
+ return cb(new Error('[[error:templatesOnDemand.source-template-empty]]'));
+ }
Benchpress.precompile({
source: source,
minify: global.env !== 'development',
}, cb);
},
function (compiled, cb) {
+ if (!compiled) {
+ return cb(new Error('[[error:templatesOnDemand.compiled-template-empty]]'));
+ }
fs.writeFile(filePath, compiled, cb);
},
], function (err) {