Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…- Unhandled Exception with embedded XML
  • Loading branch information
siegfriedpammer committed Jun 22, 2012
1 parent 9099e37 commit af52fa8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
Expand Up @@ -312,7 +312,10 @@ Token NextInternal()
if (ch == '%' && ReaderPeek() == '>') {
int x = Col - 1;
int y = Line;
inXmlMode = true;
// in invalid code xmlModeStack might happen to be empty.
// do not set lexer to XML mode, if there was no valid XML before the inline VB code.
// fixes http://community.sharpdevelop.net/forums/t/15920.aspx
inXmlMode = xmlModeStack.Any();
ReaderRead();
return new Token(Tokens.XmlEndInlineVB, new Location(x, y), new Location(Col, Line));
}
Expand Down
9 changes: 9 additions & 0 deletions src/Libraries/NRefactory/Test/Parser/SnippetParserTests.cs
Expand Up @@ -26,5 +26,14 @@ public void SimpleXmlDocument()
INode node = parser.Parse("Dim doc = <test><%= test %></test>");
Assert.IsTrue(parser.Errors.Count == 0);
}

[Test]
public void InvalidXmlLiteral()
{
// ensure we don't crash on this invalid VB code
SnippetParser parser = new SnippetParser(SupportedLanguage.VBNet);
INode node = parser.Parse("<Cell StyleID=<%= print_title %>>");
Assert.IsTrue(parser.Errors.Count > 0);
}
}
}

0 comments on commit af52fa8

Please sign in to comment.