Skip to content

Problem with escaping < and > #22

@myabc

Description

@myabc

From t.j.bent...@gmail.com 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions