From 13e5e5a8df8be31c79b92e72e9b9394f69fb2d5d Mon Sep 17 00:00:00 2001 From: agrath Date: Sun, 31 Jul 2011 11:16:45 -1200 Subject: [PATCH] Fixed a bug in @Library.Truncate regarding attempting to close tags which were not open when the truncation occurred before any tags had been opened. --- .../RazorDynamicNode/RazorLibraryCore.cs | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs index 967f725a8c..7587ebab40 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/RazorLibraryCore.cs @@ -333,7 +333,10 @@ namespace umbraco.MacroEngines.Library if (ic == (int)'<') { - IsInsideElement = true; + if (!lengthReached) + { + IsInsideElement = true; + } insideTagSpaceEncountered = false; currentTag = string.Empty; isTagClose = false; @@ -344,26 +347,29 @@ namespace umbraco.MacroEngines.Library } else if (ic == (int)'>') { - IsInsideElement = false; - //if (write) - //{ - // outputtw.Write('>'); - //} - currentTextLength++; - if (isTagClose && tagStack.Count > 0) + if (IsInsideElement) { - string thisTag = tagStack.Pop(); - outputtw.Write(""); - } - if (!isTagClose && currentTag.Length > 0) - { - if (!lengthReached) + IsInsideElement = false; + //if (write) + //{ + // outputtw.Write('>'); + //} + currentTextLength++; + if (isTagClose && tagStack.Count > 0) { - tagStack.Push(currentTag); - outputtw.Write("<" + currentTag); - if (tr.Peek() != (int)' ') + string thisTag = tagStack.Pop(); + outputtw.Write(""); + } + if (!isTagClose && currentTag.Length > 0) + { + if (!lengthReached) { - outputtw.Write(">"); + tagStack.Push(currentTag); + outputtw.Write("<" + currentTag); + if (tr.Peek() != (int)' ') + { + outputtw.Write(">"); + } } } }