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

A StringIndexOutOfBoundsException occurs in this library #70

Open
nonesong opened this issue Jan 11, 2024 · 0 comments
Open

A StringIndexOutOfBoundsException occurs in this library #70

nonesong opened this issue Jan 11, 2024 · 0 comments

Comments

@nonesong
Copy link

Hello, I have observed some issues with this library as follows.
Class com.github.h0tk3y.betterParse.lexer.TokenMatch.getText() does not perform a boundary checking of the parameters in the method subSequence(this.offset, this.offset + this.length).toString(), which cause ‘java.lang.StringIndexOutOfBoundsException’.

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 5, end 28, length 8
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4608)
at java.base/java.lang.String.substring(String.java:2711)
at java.base/java.lang.String.subSequence(String.java:2749)
at com.github.h0tk3y.betterParse.lexer.TokenMatch.getText(TokenMatch.kt:18)
at com.github.h0tk3y.betterParse.lexer.TokenMatch.toString(TokenMatch.kt:24)
at java.base/java.lang.String.valueOf(String.java:4222)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
at com.github.h0tk3y.betterParse.parser.UnparsedRemainder.toString(Parser.kt)

It suggests that the library can conduct a boundary checking of the parameter in the method subSequence to ensure this method can accept the suitable parameters and avoid the running code to stop throwing a StringIndexOutOfBoundsException.

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