Compare commits

...

2 Commits

Author SHA1 Message Date
PlantUML 1188a05a60
Merge pull request #1705 from ouss1002/bug-custom-functions-name
Prevent IndexOutOfBoundsException in equation rendering by checking non-empty 'texsymbol' strings
2024-03-08 19:10:32 +01:00
BOUDJENIBA Oussama d85f96256e
Prevent IndexOutOfBoundsException in equation rendering by checking non-empty 'texsymbol' strings
This commit introduces a check before accessing the first character of 'texsymbol' strings in equation rendering, preventing IndexOutOfBoundsException when custom functions names are used which can lead to an empty string. This change ensures that equations custom variables names ending with standard function strings are handled gracefully without errors
2024-03-04 09:58:29 +01:00
1 changed files with 2 additions and 2 deletions

View File

@ -602,7 +602,7 @@ public class ASCIIMathTeXImg {
case CONST:
str = AMremoveCharsAndBlanks(str, symbol.input.length());
String texsymbol = AMTgetTeXsymbol(symbol);
if (texsymbol.charAt(0) == '\\' || symbol.tag.equals("mo"))
if (texsymbol.isEmpty() || texsymbol.charAt(0) == '\\' || symbol.tag.equals("mo"))
return new String[] { texsymbol, str };
else {
return new String[] { "{" + texsymbol + "}", str };
@ -676,7 +676,7 @@ public class ASCIIMathTeXImg {
if (result[0] == null)
return new String[] { "{" + AMTgetTeXsymbol(symbol) + "}", str };
if (symbol.hasFlag("func")) { // functions hack
st = "" + str.charAt(0);
st = "" + (str.isEmpty() ? "" : str.charAt(0));
if (st.equals("^") || st.equals("_") || st.equals("/") || st.equals("|") || st.equals(",")
|| (symbol.input.length() == 1 && symbol.input.matches("\\w") && !st.equals("("))) {
return new String[] { "{" + AMTgetTeXsymbol(symbol) + "}", str };