File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,8 +161,10 @@ private ReadOnlyMemory<char> GetTagName()
161161
162162 private bool TryCompleteTag ( ReadOnlyMemory < char > tagName )
163163 {
164+ var htmlLength = _html . Length ;
165+
164166 // tag names must be followed by whitespace, '/>', '?>, or '>' to be valid
165- char afterName = _cursor < _html . Length ? _html . Span [ _cursor ] : char . MinValue ;
167+ char afterName = _cursor < htmlLength ? _html . Span [ _cursor ] : char . MinValue ;
166168 if ( ! ( char . IsWhiteSpace ( afterName )
167169 || afterName == '>'
168170 || afterName == '/'
@@ -173,7 +175,7 @@ private bool TryCompleteTag(ReadOnlyMemory<char> tagName)
173175
174176 bool containsBadChars = false ;
175177
176- while ( _cursor < _html . Length && _html . Span [ _cursor ] != '>' )
178+ while ( _cursor < htmlLength && _html . Span [ _cursor ] != '>' )
177179 {
178180 // check that we do not have '<' character present in the tag
179181 if ( _html . Span [ _cursor ] == '<' )
@@ -184,7 +186,7 @@ private bool TryCompleteTag(ReadOnlyMemory<char> tagName)
184186 _cursor ++ ;
185187 }
186188
187- if ( _cursor == _html . Length )
189+ if ( _cursor == htmlLength )
188190 {
189191 // reached the end of the document without finding '>'
190192 return false ;
You can’t perform that action at this time.
0 commit comments