rjeschke / txtmark

Yet another markdown processor for the JVM
Apache License 2.0
449 stars 100 forks source link

StringIndexOutOfBoundsException #48

Open davidlbowen opened 8 years ago

davidlbowen commented 8 years ago

when a line contains only a '<' character.

I'm not able to submit a pull request, but here's a patch:

$ git diff 108cee6b209a362843729c032c2d982625d12d98
diff --git a/src/main/java/com/github/rjeschke/txtmark/Line.java b/src/main/java/com/github/rjeschke/txtmark/Line.java
index 4ef1c43..2afcbc0 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Line.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Line.java
@@ -517,7 +517,7 @@ class Line
         final LinkedList<String> tags = new LinkedList<String>();
         final StringBuilder temp = new StringBuilder();
         int pos = this.leading;
-        if (this.value.charAt(this.leading + 1) == '!')
+        if (this.leading + 1 < this.value.length() && this.value.charAt(this.leading + 1) == '!')
         {
             if (this.readXMLComment(this, this.leading) > 0)
             {
davidlbowen commented 8 years ago

I am forking this repo to fix this and other bugs.

https://github.com/davidlbowen/txtmark