diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java index 8caf83e1a43..1978dd84565 100644 --- a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java +++ b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java @@ -196,6 +196,9 @@ public class JavascriptCompiler { wasIdentifierPart = false; } } + // limit maximum length, theoretically 65536 is allowed in constant pool (in UTF-8 format). + if (sb.length() > 1204) sb.setLength(1024); + // remove trailing underscores for (int i = sb.length() - 1; i >= 0; i--) { if (sb.charAt(i) == '_') { sb.setLength(i);