markdownj icon indicating copy to clipboard operation
markdownj copied to clipboard

Problem with escaping < and >

Open myabc opened this issue 12 years ago • 1 comments

From [email protected] on November 21, 2011 12:31:11

Found a bug in markdownj compiled from trunk.

Here's class to reproduce it:

import com.petebevin.markdown.MarkdownProcessor;

public class Foo {

    public static void main(String[] args) {
        System.out.println(new MarkdownProcessor().markdown(
                "`y>x` foo `y<x` bar `y>x`"));
        System.out.println(new MarkdownProcessor().markdown(
                "`y>x` foo\n`y<x` bar\n`y>x`\n"));
    }   
}

The printed strings are

<p><code>y&gt;x</code> foo <code>y&lt;x` bar `y&gt;x</code></p>

and

<p><code>y&gt;x</code> foo
`y<x` bar
`y>x`</p>

I tracked the problem down to runSpanGamut() and escapeSpecialCharsWithinTagAttributes(). The latter tried to get text between < and > and replace special chars within those tokens, but the tokenizing is going wrong.

I noticed that in the original markdown runSpanGamut() does the code spans first and then does the special chars, so unless they've been swapped for some other reason, that's probably the way to fix it. Otherwise TextEditor.tokenizeHTML() will need to do a better job.

I've previously reported this to alex via email, but got no response.

Original issue: http://code.google.com/p/markdownj/issues/detail?id=19

myabc avatar Nov 18 '13 21:11 myabc

From alex.coles on February 18, 2013 16:29:47

Status: Accepted

myabc avatar Nov 18 '13 21:11 myabc