From c8b23195f6ebadeeba83d58fd91f59b1e4ca32b9 Mon Sep 17 00:00:00 2001 From: Lotte Pitcher Date: Thu, 3 Nov 2016 14:30:38 +0000 Subject: [PATCH] When truncating if the last characters was the first half of a two word unicode character, also include the second half to avoid YSOD --- src/Umbraco.Web/HtmlStringUtilities.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Umbraco.Web/HtmlStringUtilities.cs b/src/Umbraco.Web/HtmlStringUtilities.cs index 5ba1d17f4e..24a643b5b0 100644 --- a/src/Umbraco.Web/HtmlStringUtilities.cs +++ b/src/Umbraco.Web/HtmlStringUtilities.cs @@ -211,6 +211,13 @@ namespace Umbraco.Web if (!lengthReached && currentTextLength >= length) { + // if the last character added was the first of a two character unicode pair, add the second character + if (Char.IsHighSurrogate((char)ic)) + { + var lowSurrogate = tr.Read(); + outputtw.Write((char)lowSurrogate); + } + // Reached truncate limit. if (addElipsis) {