mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-28 07:46:28 +00:00
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
This commit is contained in:
parent
a0be1ed677
commit
d85f96256e
@ -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 };
|
||||||
|
Loading…
Reference in New Issue
Block a user