Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request _renderFilterParams fails when filter target contains parens #203

Open
mbecroft opened this issue Mar 9, 2017 · 0 comments
Open
Milestone

Comments

@mbecroft
Copy link

mbecroft commented Mar 9, 2017

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.

mbecroft added a commit to mbecroft/dstore that referenced this issue Mar 9, 2017
sure if a complete solution, but appears to work at least for the eq
operator.
@dylans dylans added this to the 1.1.2 milestone Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants