sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 218 forks source link

Typo in Extensions class causes collisions with STRIKETHROUGH, WIKILINKS and ANCHORLINKS #161

Closed tcreswick closed 8 years ago

tcreswick commented 9 years ago

There is an issue with the way that Extensions are defined.

Specifically, there's a collision between STRIKETHROUGH, WIKILINKS and ANCHORLINKS.

This is because:

static final int WIKILINKS = 0x100;
static final int STRIKETHROUGH = 0x200;
static final int ANCHORLINKS = 0x300;

It looks like the bug is simply that ANCHORLINKS was supposed to be 0x400 and this is a simple typo.

Unfortunately because the check is done like this:

   public boolean ext(int extension) {
        return (options & extension) > 0;
    }

It means that you get the following collisions:

  1. If you enable WIKILINKS, it also enables ANCHORLINKS
  2. If you enable STRIKETHROUGH, it also enables ANCHORLINKS
  3. If you enable ANCHORLINKS it also enables WIKILINKS and STRIKETHROUGH
tcreswick commented 9 years ago

Have added a pull request with the fix https://github.com/sirthias/pegdown/pulls

eskatos commented 9 years ago

Now that this has been merged, what about a new pegdown version?

rabbitfr commented 9 years ago

Hi,

I stumbled upon this issue, could you please update pegdown ?

Thanks

jtzikas commented 9 years ago

+1 to a new release

kshchepanovskyi commented 9 years ago

+1 to a new release - I also faced with this issue.

sirthias commented 8 years ago

Closed by 8af0001a59690614b1f9dd39c1509e76f714e20c.

kshchepanovskyi commented 8 years ago

Thanks!