flexmark-java
flexmark-java copied to clipboard
flexmark-ext-resizable-image crashes on inline parsing when a block ends with an exclamation mark!
A markdown block like:
This is soooo cool!

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. :-)
Looks like this is addressed by #503
@bvarner: Would you mind closing your ticket if it is fixed?