From 40891272dcb7d8f481456cc7496f46538e6aaada Mon Sep 17 00:00:00 2001 From: Steve Larson <9larsons@gmail.com> Date: Tue, 23 Jan 2024 14:45:27 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20custom=20excerpts=20some?= =?UTF-8?q?times=20being=20cut=20off=20(#19560)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs TryGhost/Ghost#19559 - custom excerpts are truncated based on character length - escaped characters added extra length but we didn't account for this, resulting in poor truncation of excerpts --- ghost/core/core/frontend/helpers/excerpt.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ghost/core/core/frontend/helpers/excerpt.js b/ghost/core/core/frontend/helpers/excerpt.js index 6b574a4865..27a037d19f 100644 --- a/ghost/core/core/frontend/helpers/excerpt.js +++ b/ghost/core/core/frontend/helpers/excerpt.js @@ -22,7 +22,7 @@ module.exports = function excerpt(options) { } else { excerptText = ''; } - + excerptText = _.escape(excerptText); truncateOptions = _.reduce(truncateOptions, (_truncateOptions, value, key) => { @@ -32,8 +32,9 @@ module.exports = function excerpt(options) { return _truncateOptions; }, {}); + // For custom excerpts, make sure we truncate them only based on length if (!_.isEmpty(this.custom_excerpt)) { - truncateOptions.characters = this.custom_excerpt.length; + truncateOptions.characters = excerptText.length; // length is expanded by use of escaped characters if (truncateOptions.words) { delete truncateOptions.words; }