From be5e2862656b04ebdcd1993ba7c54d22e399c224 Mon Sep 17 00:00:00 2001 From: Austin Lee Date: Fri, 20 Nov 2026 14:52:23 +0800 Subject: [PATCH] fix(say): use same-origin Waline URLs and verify explicit targets --- packages/say/lib/comment-render.js | 14 +++++-- packages/say/test/waline-render.test.js | 55 +++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/packages/say/lib/comment-render.js b/packages/say/lib/comment-render.js index 9d270f2..e39d8ac 100644 --- a/packages/say/lib/comment-render.js +++ b/packages/say/lib/comment-render.js @@ -58,10 +58,15 @@ function renderComments(id, result, config) { module.exports = {renderComments}; function renderWalineComments(item, {options, public: publicConfig}) { + if (typeof item.pathname !== 'string' || !item.pathname.trim()) { + throw new TypeError('A stored Say pathname is required for native comments'); + } + // Waline 3.16 decodes path once before sending it. Protect query-value escapes + // so core receives the stored pathname, not an ID or a partially decoded value. + const path = `/says/${item.id}?pathname=${encodeURIComponent(item.pathname)}&type=3`; const settings = options.comment || {}; const config = { - serverURL: '/api/comment', - path: encodeURI(`/says/${item.id}?pathname=${encodeURIComponent(item.pathname)}&type=3`), + path: encodeURI(path), login: publicConfig.forceLogin ? 'force' : 'enable', lang: settings.locale && settings.locale !== 'auto' ? settings.locale : 'zh-CN', pageSize: Number(settings.pageSize) || 10, @@ -77,15 +82,16 @@ function renderWalineComments(item, {options, public: publicConfig}) {