1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-28 15:56:31 +00:00

Merge pull request #1705 from ouss1002/bug-custom-functions-name

Prevent IndexOutOfBoundsException in equation rendering by checking non-empty 'texsymbol' strings
This commit is contained in:
PlantUML 2024-03-08 19:10:32 +01:00 committed by GitHub
commit 1188a05a60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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