Skip to content

Commit

Permalink
Merge pull request plantuml#1705 from ouss1002/bug-custom-functions-name
Browse files Browse the repository at this point in the history
Prevent IndexOutOfBoundsException in equation rendering by checking non-empty 'texsymbol' strings
  • Loading branch information
arnaudroques authored Mar 8, 2024
2 parents a0be1ed + d85f962 commit 1188a05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private String[] AMTparseSexpr(String str) {
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 };
Expand Down Expand Up @@ -676,7 +676,7 @@ else if (symbol == AMquote)
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 };
Expand Down

0 comments on commit 1188a05

Please sign in to comment.