fix: preserve delivered page links when auto images fail
This commit is contained in:
+25
-4
@@ -503,6 +503,25 @@ function buildMissingPublicHtmlNotice(filename) {
|
||||
return `(页面生成未完成,已阻止显示失效链接:${filename || '页面'}。)`;
|
||||
}
|
||||
|
||||
function publicHtmlRootsForUser(owner) {
|
||||
const roots = [
|
||||
path.resolve(process.cwd(), PUBLISH_ROOT_DIR, owner),
|
||||
];
|
||||
const sharedPublishRoots = [
|
||||
process.env.GOOSED_SANDBOX_PUBLISH_ROOT,
|
||||
process.env.MEMIND_SHARED_PUBLISH_ROOT,
|
||||
];
|
||||
for (const configuredRoot of sharedPublishRoots) {
|
||||
const value = String(configuredRoot ?? '').trim();
|
||||
if (value) roots.push(path.resolve(value, owner));
|
||||
}
|
||||
const usersRoot = String(process.env.H5_USERS_ROOT ?? '').trim();
|
||||
if (usersRoot) {
|
||||
roots.push(path.resolve(path.dirname(usersRoot), PUBLISH_ROOT_DIR, owner));
|
||||
}
|
||||
return [...new Set(roots)];
|
||||
}
|
||||
|
||||
function publicHtmlExistsForUser(owner, relativePath, currentUser) {
|
||||
const normalizedOwner = String(owner ?? '').trim().toLowerCase();
|
||||
const normalizedUserId = String(currentUser?.id ?? '').trim().toLowerCase();
|
||||
@@ -511,10 +530,12 @@ function publicHtmlExistsForUser(owner, relativePath, currentUser) {
|
||||
if (normalizedOwner !== normalizedUserId && normalizedOwner !== normalizedUsername) return true;
|
||||
const normalizedRelativePath = normalizeStaticHtmlRelativePath(relativePath);
|
||||
if (!normalizedRelativePath || !normalizedRelativePath.toLowerCase().endsWith('.html')) return false;
|
||||
const root = path.resolve(process.cwd(), PUBLISH_ROOT_DIR, normalizedOwner);
|
||||
const target = path.resolve(root, normalizedRelativePath);
|
||||
if (target !== root && !target.startsWith(`${root}${path.sep}`)) return false;
|
||||
return fs.existsSync(target) && fs.statSync(target).isFile();
|
||||
for (const root of publicHtmlRootsForUser(normalizedOwner)) {
|
||||
const target = path.resolve(root, normalizedRelativePath);
|
||||
if (target !== root && !target.startsWith(`${root}${path.sep}`)) continue;
|
||||
if (fs.existsSync(target) && fs.statSync(target).isFile()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function sanitizeOwnPublicHtmlUrl(publicUrl, owner, rawRelativePath, currentUser) {
|
||||
|
||||
Reference in New Issue
Block a user