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

Dangling pipe breaks table block parser #255

Closed
jk1 opened this issue Mar 1, 2022 · 1 comment
Closed

Dangling pipe breaks table block parser #255

jk1 opened this issue Mar 1, 2022 · 1 comment
Labels

Comments

@jk1
Copy link
Contributor

jk1 commented Mar 1, 2022

Steps to reproduce the problem (provide example Markdown if applicable):

Abc|Def
---|---
1|2
|

Expected behavior:

<table>
<thead>
<tr>
<th>Abc</th>
<th>Def</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>

Actual behavior:

java.lang.StringIndexOutOfBoundsException: String index out of range: 1

	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:709)
	at org.commonmark.ext.gfm.tables.internal.TableBlockParser.split(TableBlockParser.java:137)
	at org.commonmark.ext.gfm.tables.internal.TableBlockParser.parseInlines(TableBlockParser.java:80)
	at org.commonmark.internal.DocumentParser.processInlines(DocumentParser.java:475)
	at org.commonmark.internal.DocumentParser.finalizeAndProcess(DocumentParser.java:522)
	at org.commonmark.internal.DocumentParser.parse(DocumentParser.java:121)
	at org.commonmark.parser.Parser.parse(Parser.java:70)
	at org.commonmark.ext.gfm.tables.TablesTest.render(TablesTest.java:789)
	at org.commonmark.testutil.RenderingTestCase.assertRendering(RenderingTestCase.java:10)
	at org.commonmark.ext.gfm.tables.TablesTest.tableWithDanglingPipe(TablesTest.java:713)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

@jk1 jk1 added the bug label Mar 1, 2022
jk1 added a commit to jk1/commonmark-java that referenced this issue Mar 1, 2022
robinst added a commit that referenced this issue Oct 18, 2022
Fix GFM table parser to handle dangling pipe correctly (fixes #255)
@robinst
Copy link
Collaborator

robinst commented Oct 20, 2022

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

No branches or pull requests

2 participants