Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flexmark-ext-resizable-image crashes on inline parsing when a block ends with an exclamation mark! #513

Open
bvarner opened this issue Jun 24, 2022 · 2 comments

Comments

@bvarner
Copy link

bvarner commented Jun 24, 2022

A markdown block like:

This is soooo cool!

![the thing](the_thing.jpg =120x60)

Will fail with a StringIndexOutOfBoundsException.

The issue is with ResizableImageInlineParserExtension.java

    @Override
    public boolean parse(@NotNull LightInlineParser inlineParser) {
        int index = inlineParser.getIndex();
        char c = inlineParser.getInput().charAt(index + 1);
        if (c == '[') {
            BasedSequence[] matches = inlineParser.matchWithGroups(IMAGE_PATTERN);

Note the use of index + 1 without a prior bounds check. The offending exclamation mark happens to be at the end of a block, so the index + 1 character check for a following [ puts us past the end of the block, and out of range.

Expected behavior
If the input is not long enough to check the next character, it's clearly not going to be a [. This shouldn't crash. :-)

@bvarner
Copy link
Author

bvarner commented Jun 24, 2022

Looks like this is addressed by #503

@ghost
Copy link

ghost commented Jun 18, 2023

@bvarner: Would you mind closing your ticket if it is fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant