Skip to content

Commit 60473ef

Browse files
Re-assert invalid chars
1 parent 897efad commit 60473ef

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/IdentifierBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ abstract class IdentifierBuilder extends AbstractBuilder {
3434

3535
private static final String BLANK_INDEX_ERROR_MESSAGE = "Blank index specified in index pattern";
3636

37+
private static final String INVALID_ESQL_CHARS = Strings.INVALID_FILENAME_CHARS.replace("'*',", "");
38+
3739
@Override
3840
public String visitIdentifier(IdentifierContext ctx) {
3941
return ctx == null ? null : unquoteIdentifier(ctx.QUOTED_IDENTIFIER(), ctx.UNQUOTED_IDENTIFIER());
@@ -311,8 +313,7 @@ private static void resolveAndValidateIndex(String index, EsqlBaseParser.IndexPa
311313
* mislead the user by mentioning this char in the error message.
312314
*/
313315
if (e.getMessage().contains("must not contain the following characters")) {
314-
var updatedInvalidChars = Strings.INVALID_FILENAME_CHARS.replace("'*',", "");
315-
throwInvalidIndexNameException(index, "must not contain the following characters " + updatedInvalidChars, ctx);
316+
throwInvalidIndexNameException(index, "must not contain the following characters " + INVALID_ESQL_CHARS, ctx);
316317
}
317318

318319
throw new ParsingException(e, source(ctx), e.getMessage());

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3233,7 +3233,12 @@ public void testInvalidPatternsWithIntermittentQuotes() {
32333233
var invalidIndexName = "foo" + randomInvalidChar + "bar";
32343234
var remoteIndexWithInvalidChar = quote(randomIdentifier() + ":" + invalidIndexName);
32353235
var query = "FROM " + randomIndex + "," + remoteIndexWithInvalidChar;
3236-
expectError(query, "Invalid index name [" + invalidIndexName + "], must not contain the following characters");
3236+
expectError(
3237+
query,
3238+
"Invalid index name ["
3239+
+ invalidIndexName
3240+
+ "], must not contain the following characters [' ','\"',',','/','<','>','?','\\','|']"
3241+
);
32373242
}
32383243

32393244
// Colon outside a quoted string should result in an ANTLR error: a comma is expected.

0 commit comments

Comments
 (0)