Applied PR feedback (unit testst will be added as part of a separate commit)
This commit is contained in:
parent
32e2c533c7
commit
7357fa04ea
|
|
@ -496,6 +496,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
{
|
||||
using (Context.Builder.StartBlock(BlockKindInternal.HtmlComment))
|
||||
{
|
||||
// Accept the double-hyphen symbol at the beginning of the comment block.
|
||||
AcceptAndMoveNext();
|
||||
Output(SpanKindInternal.Markup, AcceptedCharactersInternal.None);
|
||||
|
||||
|
|
@ -503,8 +504,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
while (!EndOfFile)
|
||||
{
|
||||
SkipToAndParseCode(HtmlSymbolType.DoubleHyphen);
|
||||
if (At(HtmlSymbolType.DoubleHyphen))
|
||||
{
|
||||
var lastDoubleHyphen = AcceptAllButLastDoubleHypens();
|
||||
|
||||
if (At(HtmlSymbolType.CloseAngle))
|
||||
|
|
@ -525,7 +524,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CurrentSymbol.Type == HtmlSymbolType.LeftBracket)
|
||||
{
|
||||
if (AcceptAndMoveNext())
|
||||
|
|
@ -606,28 +604,27 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
}
|
||||
|
||||
// Check condition 2.2
|
||||
bool isValidComment = false;
|
||||
var isValidComment = false;
|
||||
LookaheadUntil((s, p) =>
|
||||
{
|
||||
bool breakLookahead = false;
|
||||
if (s.Type == HtmlSymbolType.DoubleHyphen)
|
||||
{
|
||||
if (NextIs(HtmlSymbolType.CloseAngle))
|
||||
{
|
||||
// Check condition 2.3: We're at the end of a comment. Check to make sure the text ending is allowed.
|
||||
isValidComment = !SymbolSequenceEndsWithItems(p, HtmlSymbolType.OpenAngle, HtmlSymbolType.Bang, HtmlSymbolType.DoubleHyphen);
|
||||
breakLookahead = true;
|
||||
return true;
|
||||
}
|
||||
else if (NextIs(ns => IsDashSymbol(ns) && NextIs(HtmlSymbolType.CloseAngle)))
|
||||
{
|
||||
// This is also a valid closing comment case, as the dashes lookup is treated with DoubleHyphen symbols first.
|
||||
isValidComment = true;
|
||||
breakLookahead = true;
|
||||
return true;
|
||||
}
|
||||
else if (NextIs(ns => ns.Type == HtmlSymbolType.Bang && NextIs(HtmlSymbolType.CloseAngle)))
|
||||
{
|
||||
isValidComment = false;
|
||||
breakLookahead = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (s.Type == HtmlSymbolType.OpenAngle)
|
||||
|
|
@ -635,11 +632,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
if (NextIs(ns => ns.Type == HtmlSymbolType.Bang && NextIs(HtmlSymbolType.DoubleHyphen)))
|
||||
{
|
||||
isValidComment = false;
|
||||
breakLookahead = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return breakLookahead;
|
||||
return false;
|
||||
});
|
||||
|
||||
return isValidComment;
|
||||
|
|
|
|||
|
|
@ -487,6 +487,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
}
|
||||
|
||||
private void ValidateParentAllowsContent(Span child, ErrorSink errorSink)
|
||||
{
|
||||
if (HasAllowedChildren())
|
||||
{
|
||||
var isDisallowedContent = true;
|
||||
if (_featureFlags.AllowHtmlCommentsInTagHelpers)
|
||||
|
|
@ -494,7 +496,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
isDisallowedContent = !IsComment(child) && child.Kind != SpanKindInternal.Transition && child.Kind != SpanKindInternal.Code;
|
||||
}
|
||||
|
||||
if (HasAllowedChildren() && isDisallowedContent)
|
||||
if (isDisallowedContent)
|
||||
{
|
||||
var content = child.Content;
|
||||
if (!string.IsNullOrWhiteSpace(content))
|
||||
|
|
@ -513,6 +515,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateParentAllowsPlainTag(Block tagBlock, ErrorSink errorSink)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -122,9 +122,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
throw new ArgumentNullException(nameof(condition));
|
||||
}
|
||||
|
||||
bool matchFound = false;
|
||||
var matchFound = false;
|
||||
|
||||
// We add 1 in order to store the current symbol.
|
||||
var symbols = new List<TSymbol>();
|
||||
symbols.Add(CurrentSymbol);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue