From 15cfc84c52f0bfb34001f6a6b91817ad5423a135 Mon Sep 17 00:00:00 2001 From: Sverre Date: Sun, 21 Jan 2018 19:09:17 +0100 Subject: [PATCH] Fixed a crash if inserting a whitespace after a _ or ^ symbol. --- src/WpfMath.Tests/ParserTests.fs | 6 +++++- src/WpfMath/TexFormulaParser.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/WpfMath.Tests/ParserTests.fs b/src/WpfMath.Tests/ParserTests.fs index f0330e62..0baf648f 100644 --- a/src/WpfMath.Tests/ParserTests.fs +++ b/src/WpfMath.Tests/ParserTests.fs @@ -1,4 +1,4 @@ -module WpfMath.Tests.ParserTests +module WpfMath.Tests.ParserTests open System @@ -188,3 +188,7 @@ let ``Delimiter with scripts should be parsed properly`` () = [] let ``\sqrt{} should throw a TexParseException``() = assertParseThrows @"\sqrt{}" + +[] +let ``"\sum_" should throw a TexParseException``() = + assertParseThrows @"\sum_ " diff --git a/src/WpfMath/TexFormulaParser.cs b/src/WpfMath/TexFormulaParser.cs index b5d0cbb0..70ba08c5 100644 --- a/src/WpfMath/TexFormulaParser.cs +++ b/src/WpfMath/TexFormulaParser.cs @@ -271,10 +271,10 @@ private string ReadGroup(TexFormula formula, string value, ref int position, cha private TexFormula ReadScript(TexFormula formula, string value, ref int position) { + SkipWhiteSpace(value, ref position); if (position == value.Length) throw new TexParseException("illegal end, missing script!"); - SkipWhiteSpace(value, ref position); var ch = value[position]; if (ch == leftGroupChar) {