-
Notifications
You must be signed in to change notification settings - Fork 80
Description
When a filter target contains parens, e.g.:
collection.filter({foo: 'abc(def)'})`
The resulting URI does not have escape parens. This causes problems with RQL backends where unescaped parens have special meanings such as operator precedence and so forth. Clearly, the text of the filter target has to have its parens escaped.
Request._renderFilterParams uses encodeURIComponent() to encode the filter target. encodeURIComponent() specifically does not encode parens per spec.
According to RFC3986, parens are Reserved Characters, which may need to be encoded depending on the context. Clearly, in this context, the parens should be encoded.
A trivial fix that appears to work is to replace the parens when rendering the target in the final string as follows:
return [encodeURIComponent(args[0]) + '=' + (type === 'eq' ? '' : type + '=') + encodeURIComponent(target).replace(/\(/g, "%28").replace(/\)/g, "%29")];
It is unclear to me whether this is a complete solution, but it at least works for the simple case of equality filters.