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

Crash: link to reference is nested in image when format is JSON #816

Closed
rhysd opened this issue Dec 12, 2017 · 8 comments
Closed

Crash: link to reference is nested in image when format is JSON #816

rhysd opened this issue Dec 12, 2017 · 8 comments
Assignees

Comments

@rhysd
Copy link

rhysd commented Dec 12, 2017

How to repro

[![foo](foo)][bar]

[bar]: bar

Save above doc as tmp.md and run redpen -r json tmp.md

Log

[2017-12-12 13:15:45.717][INFO ] cc.redpen.Main - Configuration file: /usr/local/Cellar/redpen/1.10.0/libexec/conf/redpen-conf-en.xml
[2017-12-12 13:15:45.723][INFO ] cc.redpen.config.ConfigurationLoader - Loading config from specified config file: "/usr/local/Cellar/redpen/1.10.0/libexec/conf/redpen-conf-en.xml"
[2017-12-12 13:15:45.734][INFO ] cc.redpen.config.ConfigurationLoader - Succeeded to load configuration file
[2017-12-12 13:15:45.734][INFO ] cc.redpen.config.ConfigurationLoader - Language is set to "en"
[2017-12-12 13:15:45.734][WARN ] cc.redpen.config.ConfigurationLoader - No variant configuration...
[2017-12-12 13:15:45.786][INFO ] cc.redpen.config.ConfigurationLoader - No "symbols" block found in the configuration
[2017-12-12 13:15:45.789][INFO ] cc.redpen.config.SymbolTable - Default symbol settings are loaded
[2017-12-12 13:15:45.792][INFO ] cc.redpen.parser.SentenceExtractor - "[., ?, !]" are added as a end of sentence characters
[2017-12-12 13:15:45.792][INFO ] cc.redpen.parser.SentenceExtractor - "[', "]" are added as a right quotation characters
[2017-12-12 13:15:46.101][WARN ] cc.redpen.parser.markdown.ToFileContentSerializer - Failed to add parent for a Section
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.elementData(ArrayList.java:418)
	at java.util.ArrayList.get(ArrayList.java:431)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:412)
	at org.pegdown.ast.RefLinkNode.accept(RefLinkNode.java:33)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visitChildren(ToFileContentSerializer.java:74)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:452)
	at org.pegdown.ast.SuperNode.accept(SuperNode.java:43)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visitChildren(ToFileContentSerializer.java:74)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:300)
	at org.pegdown.ast.ParaNode.accept(ParaNode.java:35)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visitChildren(ToFileContentSerializer.java:74)
	at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:315)
	at org.pegdown.ast.RootNode.accept(RootNode.java:51)
	at cc.redpen.parser.markdown.ToFileContentSerializer.toFileContent(ToFileContentSerializer.java:90)
	at cc.redpen.parser.MarkdownParser.parse(MarkdownParser.java:79)
	at cc.redpen.parser.BaseDocumentParser.parse(BaseDocumentParser.java:58)
	at cc.redpen.RedPen.parse(RedPen.java:131)
	at cc.redpen.Main.getDocuments(Main.java:221)
	at cc.redpen.Main.run(Main.java:196)
	at cc.redpen.Main.main(Main.java:60)

Environment

OS

macOS 10.12

redpen

v1.10.0 (installed via brew install)

Java

java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
@rhysd rhysd changed the title Crashes at link to reference is nested in image when format is JSON Crash: link to reference is nested in image when format is JSON Dec 12, 2017
@takahi-i takahi-i self-assigned this Dec 12, 2017
@takahi-i
Copy link
Member

takahi-i commented Dec 12, 2017

Hello @rhysd. Thank you very much for the detailed report on the crash 🙏 I will fix this issue.

@rhysd
Copy link
Author

rhysd commented Dec 12, 2017

I encountered this when writing a CI badge as following:

[![Mac and Linux Build Status][]][Travis CI]

<!-- snip... -->

[Mac and Linux Build Status]: https://travis-ci.org/rhysd/github-clone-all.svg?branch=master
[Travis CI]: https://travis-ci.org/rhysd/github-clone-all

And this does not occur with v1.9.0

@takahi-i
Copy link
Member

takahi-i commented Dec 13, 2017

I succeeded to reproduce the problem in my environments thanks to your report 🙏

➜  redpen git:(master) redpen -r json ~/tmp/foo.md
[2017-12-13 23:31:47.920][INFO ] cc.redpen.Main - Configuration file: /opt/brew/Cellar/redpen/1.10.0/libexec/conf/redpen-conf-en.xml
[2017-12-13 23:31:47.926][INFO ] cc.redpen.config.ConfigurationLoader - Loading config from specified config file: "/opt/brew/Cellar/redpen/1.10.0/libexec/conf/redpen-conf-en.xml"
[2017-12-13 23:31:47.945][INFO ] cc.redpen.config.ConfigurationLoader - Succeeded to load configuration file
[2017-12-13 23:31:47.945][INFO ] cc.redpen.config.ConfigurationLoader - Language is set to "en"
[2017-12-13 23:31:47.945][WARN ] cc.redpen.config.ConfigurationLoader - No variant configuration...
[2017-12-13 23:31:47.948][INFO ] cc.redpen.config.ConfigurationLoader - No "symbols" block found in the configuration
[2017-12-13 23:31:47.952][INFO ] cc.redpen.config.SymbolTable - Default symbol settings are loaded
[2017-12-13 23:31:47.959][INFO ] cc.redpen.parser.SentenceExtractor - "[., ?, !]" are added as a end of sentence characters
[2017-12-13 23:31:47.960][INFO ] cc.redpen.parser.SentenceExtractor - "[', "]" are added as a right quotation characters
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.parboiled.transform.AsmUtils (file:/opt/brew/Cellar/redpen/1.10.0/libexec/lib/parboiled-java-1.1.7.jar) to method java.lang.ClassLoader.findLoadedClass(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.parboiled.transform.AsmUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 0
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
        at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
        at java.base/java.util.Objects.checkIndex(Objects.java:372)
        at java.base/java.util.ArrayList.get(ArrayList.java:440)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:412)
        at org.pegdown.ast.RefLinkNode.accept(RefLinkNode.java:33)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visitChildren(ToFileContentSerializer.java:74)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:452)
        at org.pegdown.ast.SuperNode.accept(SuperNode.java:43)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visitChildren(ToFileContentSerializer.java:74)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:300)
        at org.pegdown.ast.ParaNode.accept(ParaNode.java:35)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visitChildren(ToFileContentSerializer.java:74)
        at cc.redpen.parser.markdown.ToFileContentSerializer.visit(ToFileContentSerializer.java:315)
        at org.pegdown.ast.RootNode.accept(RootNode.java:51)
        at cc.redpen.parser.markdown.ToFileContentSerializer.toFileContent(ToFileContentSerializer.java:90)
        at cc.redpen.parser.MarkdownParser.parse(MarkdownParser.java:79)
        at cc.redpen.parser.BaseDocumentParser.parse(BaseDocumentParser.java:58)
        at cc.redpen.RedPen.parse(RedPen.java:131)
        at cc.redpen.Main.getDocuments(Main.java:221)
        at cc.redpen.Main.run(Main.java:196)
        at cc.redpen.Main.main(Main.java:60)

@takahi-i
Copy link
Member

Very sorry for making you wait. I made the hot fix for this problem in #818 Hopefully this fix work for your environment.

@takahi-i
Copy link
Member

Hello @rhysd, I fix this issue since I confirmed the hotfix in #818 works. Please reopen this issue or create another one when you face the same problem.

@takahi-i
Copy link
Member

I will release the new version of RedPen containing this hotfix soon.

@takahi-i
Copy link
Member

I made the release containing the hotfix https://github.com/redpen-cc/redpen/releases/tag/redpen-1.10.1. The release is also applied to Homebrew at pr Homebrew/homebrew-core#21759.

@rhysd
Copy link
Author

rhysd commented Dec 15, 2017

After upgrading redpen via Homebrew, it backs to work fine now. Thank you for your quick fix 👍

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

2 participants