JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 525 forks source link

Parser fails on } { sequence #203

Open tomaszkruzel opened 7 years ago

tomaszkruzel commented 7 years ago

After trying to call IconTextView.setText with text that contains { } in reversed order,i.e.: text}{ text}text{text

ParsingUtil fails with error:

java.lang.StringIndexOutOfBoundsException: length=37; regionStart=36; regionLength=-37 at java.lang.String.startEndAndLength(String.java:504) at java.lang.String.substring(String.java:1333) at com.joanzapata.iconify.internal.ParsingUtil.recursivePrepareSpannableIndexes(ParsingUtil.java:103) at com.joanzapata.iconify.internal.ParsingUtil.parse(ParsingUtil.java:37) at com.joanzapata.iconify.Iconify.compute(Iconify.java:59) at com.joanzapata.iconify.widget.IconTextView.setText(IconTextView.java:34)

I am aware that { } is a pattern. But I believe reversed order of } { could be detected by the parser to avoid the crash.

In my case this part of iconified text comes from user input, so I am forced to sanitize the text.