mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 23:29:28 -05:00
fix(dynamodb): refuse a keyword after a dot in a PartiQL path (#7685)
* fix(dynamodb): refuse a keyword after a dot in a PartiQL path * test(dynamodb): give the path dot test its own order
This commit is contained in:
1 parent
a489144c5a
commit
dba4a4fc52
3 files changed
+56
-4
No files matched your search
@@ -735,6 +735,8 @@ public class DynamoDbPartiQLParser {
|
||||
requireSimplePathStart();
|
||||
String table = expectTableName();
|
||||
if (peek().type() == TType.DOT) {
|
||||
advance();
|
||||
expectDotComponent();
|
||||
throw validationEx("FROM clause may only contain a single table name");
|
||||
}
|
||||
if (peek().type() != TType.VALUE) {
|
||||
@@ -841,7 +843,7 @@ public class DynamoDbPartiQLParser {
|
||||
components.add(expectIdent());
|
||||
while (peek().type() == TType.DOT) {
|
||||
advance();
|
||||
components.add(expectIdent());
|
||||
components.add(expectDotComponent());
|
||||
}
|
||||
if (components.contains("")) {
|
||||
fromClauseError = EMPTY_PATH_COMPONENT;
|
||||
@@ -883,8 +885,11 @@ public class DynamoDbPartiQLParser {
|
||||
}
|
||||
|
||||
private boolean isAliasName(Token token) {
|
||||
return token.type() == TType.IDENT && !isStar(token)
|
||||
&& !(isBareWord(token) && KEYWORDS.contains(token.value().toLowerCase(Locale.ROOT)));
|
||||
return token.type() == TType.IDENT && !isStar(token) && !isKeyword(token);
|
||||
}
|
||||
|
||||
private boolean isKeyword(Token token) {
|
||||
return isBareWord(token) && KEYWORDS.contains(token.value().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// DynamoDB never reads one of these words as a name.
|
||||
@@ -1476,7 +1481,7 @@ public class DynamoDbPartiQLParser {
|
||||
switch (peek().type()) {
|
||||
case DOT -> {
|
||||
advance();
|
||||
segments.add(new Seg.Name(expectIdent()));
|
||||
segments.add(new Seg.Name(expectDotComponent()));
|
||||
}
|
||||
case LBRACKET -> {
|
||||
advance();
|
||||
@@ -1735,6 +1740,14 @@ public class DynamoDbPartiQLParser {
|
||||
return t.value();
|
||||
}
|
||||
|
||||
private String expectDotComponent() {
|
||||
Token t = advance();
|
||||
if (t.type() != TType.IDENT || isKeyword(t)) {
|
||||
throw validationEx(NOT_WELL_FORMED + "Invalid path dot component");
|
||||
}
|
||||
return t.value();
|
||||
}
|
||||
|
||||
private String expectStringOrIdent() {
|
||||
Token t = peek();
|
||||
if (t.type() == TType.STRING || t.type() == TType.IDENT) { advance(); return t.value(); }
|
||||
|
||||
Reference in new issue
Block a user