From 77bd9d343cae6329c1980e0faf3b9855e4dd1602 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 7 Jan 2019 19:37:08 -0800 Subject: [PATCH] Fixed exception with non taghelper start/end void tags \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/ee8fdae75612e9d5c20b6947c1e3945d5c917cbd --- .../src/Legacy/TagHelperParseTreeRewriter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs index 13a6a89cdc..3ad6edcff9 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs @@ -144,8 +144,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Non-TagHelper tag. ValidateParentAllowsPlainStartTag(startTag); - if (!startTag.IsSelfClosing() && !startTag.IsVoidElement()) + if (node.EndTag != null || (!startTag.IsSelfClosing() && !startTag.IsVoidElement())) { + // Ideally we don't want to keep track of self-closing or void tags. + // But if a matching end tag exists, keep track of the start tag no matter what. + // We will just assume the parser had a good reason to do this. var tracker = new TagTracker(tagName, isTagHelper: false); _trackerStack.Push(tracker); }