Merge branch 'master' into develop

This commit is contained in:
Barış Soner Uşaklı
2025-12-17 10:21:00 -05:00
2 changed files with 14 additions and 5 deletions

View File

@@ -285,7 +285,7 @@ define('forum/category/tools', [
}
async function onTopicMoved(data) {
if (ajaxify.data.template.category) {
if (ajaxify.data.template.category || String(data.toCid) === '-1') {
getTopicEl(data.tid).remove();
} else {
const category = await api.get(`/categories/${data.toCid}`);

View File

@@ -273,10 +273,19 @@ middleware.buildSkinAsset = helpers.try(async (req, res, next) => {
middleware.addUploadHeaders = function addUploadHeaders(req, res, next) {
// Trim uploaded files' timestamps when downloading + force download if html
let basename = path.basename(req.path);
const extname = path.extname(req.path);
if (req.path.startsWith('/uploads/files/') && middleware.regexes.timestampedUpload.test(basename)) {
basename = basename.slice(14);
res.header('Content-Disposition', `${extname.startsWith('.htm') ? 'attachment' : 'inline'}; filename="${basename}"`);
const extname = path.extname(req.path).toLowerCase();
const unsafeExtensions = [
'.html', '.htm', '.xhtml', '.mht', '.mhtml', '.stm', '.shtm', '.shtml',
'.svg', '.svgz',
'.xml', '.xsl', '.xslt',
];
const isInlineSafe = !unsafeExtensions.includes(extname);
const dispositionType = isInlineSafe ? 'inline' : 'attachment';
if (req.path.startsWith('/uploads/files/')) {
if (middleware.regexes.timestampedUpload.test(basename)) {
basename = basename.slice(14);
}
res.header('Content-Disposition', `${dispositionType}; filename="${basename}"`);
}
next();