Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

RegExp in $in inside query does not get passed to server properly. #170

Closed
Critical-Impact opened this issue Nov 14, 2019 · 2 comments
Closed

Comments

@Critical-Impact
Copy link

Steps to reproduce

This is between a client and server. The query being used is
{ query: { $skip: 0, subdomains: {$in: [new RegExp("^.*test.*$","i")] } } }

This is what the server receives, this appears to be what the client sends so the server is definitely not mangling the request.

{ query: { $skip: 0, subdomains: {$in: [{}] } } }

If I like at the websocket connection the data being sent from the client has the {}

I have been able to work around this by passing a string then using a hook on the server end to convert it back into a regular expression.

I am wondering if this is the expected behaviour?

I can provide more detailed examples if required though it'll take me a little while.

I would have tried slack first but it appears to be down.

Expected behavior

I suppose I'd expect it to either send the regexp as is, warn you that you've passed in an invalid value or convert it client side and then convert it back server side.

Actual behavior

It turns the RegExp into a {}

System configuration

Module versions
"@feathersjs/authentication": "^4.3.7",
"@feathersjs/authentication-local": "^4.3.7",
"@feathersjs/authentication-oauth": "^4.3.7",
"@feathersjs/configuration": "^4.3.7",
"@feathersjs/errors": "^4.3.7",
"@feathersjs/express": "^4.3.7",
"@feathersjs/feathers": "^4.3.7",
"@feathersjs/socketio": "^4.3.7",
"@feathersjs/transport-commons": "^4.3.7",
"feathers-authentication-hooks": "^1.0.1",
"feathers-hooks-common": "^4.20.7",
"feathers-mongodb": "^6.0.0",
"feathers-mongodb-fuzzy-search": "^1.1.1",
"feathers-permissions": "https://github.com/Critical-Impact/feathers-permissions.git#master",
"mongodb": "^3.3.3",

NodeJS version:
v10.16.0

Operating System:
Windows 10

Browser Version:
Firefox 70.0.1 (64-bit)

@daffl
Copy link
Member

daffl commented Nov 14, 2019

It is not possible to pass non-string or number types in queries from the client. It has to be converted back into a Regular expression on the server in a before hook.

@Critical-Impact
Copy link
Author

Easy, I had guessed that might be a possibility. I will do as suggested. Appreciate the quick response :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants