Skip to content

Commit

Permalink
postgres: Refuse to build unsafe JSON lists for contains in Postgres (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclay authored and flovilmart committed Jan 31, 2019
1 parent 7d409d8 commit 9b95ae9
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 9b95ae9

Please sign in to comment.