Merge commit from fork

This commit is contained in:
Timothy Carambat 2026-01-23 17:06:44 -08:00 committed by GitHub
parent 20efe35ae6
commit 4de5e30ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,6 +11,8 @@ const {
sanitizeFileName,
writeToServerDocuments,
documentsFolder,
normalizePath,
isWithin,
} = require("../../../files");
const { default: slugify } = require("slugify");
const path = require("path");
@ -312,10 +314,14 @@ class DrupalWiki {
}
const buffer = await attachmentResponse.arrayBuffer();
const localFilePath = `${WATCH_DIRECTORY}/${fileName}`;
require("fs").writeFileSync(localFilePath, Buffer.from(buffer));
const localFilePath = normalizePath(sanitizeFileName(path.resolve(WATCH_DIRECTORY, fileName)));
if (!isWithin(path.resolve(WATCH_DIRECTORY), localFilePath)) {
console.error(`[DrupalWiki Loader]: File name ${localFilePath} is not within the storage path ${path.resolve(WATCH_DIRECTORY)}`);
continue;
}
await processSingleFile(fileName);
require("fs").writeFileSync(localFilePath, Buffer.from(buffer));
await processSingleFile(localFilePath);
}
} catch (err) {
console.error(`Fetching/processing attachments failed:`, err);