jmte icon indicating copy to clipboard operation
jmte copied to clipboard

Template `${\ }` causes NullPointerException in Lexer.innerNextToken

Open kreiger opened this issue 11 months ago • 1 comments

With template ${\ } (escaped space), Lexer.innerNextToken throws NullPointerException

java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because "variableName" is null
	at com.floreysoft.jmte.token.Lexer.innerNextToken(Lexer.java:245)
	at com.floreysoft.jmte.token.Lexer.nextToken(Lexer.java:21)

This is because variableName is null at

if (variableName.contains(" ")) {
	return new InvalidToken();
}

... because Util.MINI_PARSER.greedyScan(completeDefaultString, "(", ")") return an empty List when completeDefaultString is "\ ".

kreiger avatar Mar 12 '24 22:03 kreiger

PR with test and fix: https://github.com/DJCordhose/jmte/pull/28

Would you please also consider making a 7.0.2 release? Thank you!

kreiger avatar Mar 12 '24 22:03 kreiger

Your PR has been merged and a new release will be published in the next days

mlaggner avatar Apr 23 '24 08:04 mlaggner