Prevent invalid column names (className and length) (#7053)

* Prevent invalid column names

* remove className as invalid

* remove className from beforeSave hook response

* improve tests
This commit is contained in:
Diamond Lewis
2020-12-09 12:19:15 -06:00
committed by GitHub
parent b398894341
commit ca1b78220f
6 changed files with 49 additions and 42 deletions

View File

@@ -564,7 +564,7 @@ class DatabaseController {
}
const rootFieldName = getRootFieldName(fieldName);
if (
!SchemaController.fieldNameIsValid(rootFieldName) &&
!SchemaController.fieldNameIsValid(rootFieldName, className) &&
!isSpecialUpdateKey(rootFieldName)
) {
throw new Parse.Error(
@@ -1213,7 +1213,7 @@ class DatabaseController {
throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, `Cannot sort by ${fieldName}`);
}
const rootFieldName = getRootFieldName(fieldName);
if (!SchemaController.fieldNameIsValid(rootFieldName)) {
if (!SchemaController.fieldNameIsValid(rootFieldName, className)) {
throw new Parse.Error(
Parse.Error.INVALID_KEY_NAME,
`Invalid field name: ${fieldName}.`