-
Notifications
You must be signed in to change notification settings - Fork 69
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
Bug in StringUtils.startsWithIgnoringCaseAndWhitespaces() prevents writing out "J" #305
Comments
Hi @erik-alm, thank you for reporting this issue. Indeed, that method did not verify that the entire prefix got checked. I just pushed a fix and will release a hotfix version later today. |
I just released jte version 3.1.6, containing a fix for this issue. |
Great! It seems to work. Though "unsafe(Character)" is still broken. Here's how to make it break:
|
$unsafe has only implementations for String and Content, since usually it does not make sense to have unsafe for single characters. |
StringUtils.startsWithIgnoringCaseAndWhitespaces()
is implemented "backwards". Instead of trying to find the prefix in the string, it tries to find the string in the prefix. This causes this undesired behavior:It also means you cannot write a variable with the content "J" or "Ja" etc. when it's part of an "a href"-attribute like:
Trying to fix the problem using "unsafe", like so:
…seems to cause another bug (since "key" is a "Character"? — I had to convert it to a
String
to make it work):The text was updated successfully, but these errors were encountered: