Skip to content

Commit

Permalink
Refuse to build unsafe JSON lists for contains in Postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclay committed Jan 31, 2019
1 parent 7e48b7a commit 89fecb7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ const buildWhereClause = ({ schema, query, index }): WhereClause => {
name = transformDotFieldToComponents(fieldName).join('->');
fieldValue.$in.forEach(listElem => {
if (typeof listElem === 'string') {
if (listElem.includes('"') || listElem.includes("'")) {
throw new Parse.Error(
Parse.Error.INVALID_JSON,
'bad $in value; Strings with quotes cannot yet be safely escaped'
);
}
inPatterns.push(`"${listElem}"`);
} else {
inPatterns.push(`${listElem}`);
Expand Down

0 comments on commit 89fecb7

Please sign in to comment.