JavaDocImpl.comment() throws on a javadoc containing a literal {n}
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with JavaDocImpl.comment() in maddi-cst-impl/src/main/java/io/codelaser/maddi/cst/impl/element/JavaDocImpl.java and trace how inline tag placeholders are stored and expanded. Reproduce with the {0}={1} example containing {@code key}; done means literal sequences remain unchanged, parser placeholders expand correctly, and an out-of-range index does not throw.
Written by the indexing model from the issue text.
Description
JavaDocImpl.comment() expands {n} in the stored text as a placeholder for inline tag n. Literal text of that form in the javadoc itself gets the same treatment. When n is not a valid tag index, comment() throws.
Where: maddi-cst-impl/src/main/java/io/codelaser/maddi/cst/impl/element/JavaDocImpl.java, comment():
Pattern p = Pattern.compile("\\{(\\d+)}");
Matcher m = p.matcher(super.comment());
while (m.find()) {
int tagIndex = Integer.parseInt(m.group(1));
Tag tag = tags.get(tagIndex); // IndexOutOfBoundsException
...
Seen as:
java.lang.IndexOutOfBoundsException: Index: 1 Size: 1
at java.base/java.util.ImmutableCollections$List12.get(ImmutableCollections.java:611)
at io.codelaser.maddi.cst.impl.element.JavaDocImpl.comment(JavaDocImpl.java:189)
This happened while parsing an open-source project (nacos) and calling comment() on each type's comments.
Minimal shape: a javadoc that contains a MessageFormat-style pattern and at least one inline tag, for example:
/**
* Formats {@code key} as "{0}={1}".
*/
The stored text holds {0} for {@code key}, so tag 0 exists. The literal {0} and {1} are then taken as placeholders too. {1} is out of range and throws. {0} is silently replaced by the wrong tag.
Expected: comment() returns the javadoc text as written. Literal {n} sequences are kept, and only the parser's own placeholders are expanded.
Possible fixes:
- Escape literal
{(or{n}) when the placeholders are created, and unescape incomment(). - Use a placeholder form that cannot occur in source text, such as one with a private-use character.
Either way, out-of-range indices should not throw.
Workaround for callers: commentWithPlaceholders() returns the stored text without expansion. That is enough for checks that only look for words in the comment.
- Dominant language
- Java
- Stars
- 1
- Forks
- 1
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CodeLaser/maddi
-
build/ci good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
CodeLaser/maddi#165 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 40/100
CodeLaser/maddi#164 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
C# printer: a self-bounded interface's wildcard interface and companion class share a name (CS0102)Openfront-end:csharp
Difficulty 3/5 1-2 days Newbie friendliness 64/100
CodeLaser/maddi#160 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
2026 Error Report
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
triplea-game/triplea#15096 ·
Maintainers usually reply within 1 day
-
[Bug][API] Switching workflow versions leaves schedules onlinePossibly taken @zhuangchong claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/dolphinscheduler#18731 ·
Maintainers usually reply within 1 day
-
Implement JDBC Domain Enums (`SqlCategory`, `SqlExecutionStatus`, `SqlExecutionType`) in Core ModuleOpencore-module enhancement good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
sdlc-pro/spring-lens#531 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/rocketmq-dashboard#7340 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Low-Drag-MC/LDLib2#78 ·