-
Notifications
You must be signed in to change notification settings - Fork 164
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
Nano does not escape partition ID's #283
Comments
swansontec
added a commit
to swansontec/couchdb-nano
that referenced
this issue
Nov 18, 2021
This is a fix for apache#283. As discussed in that issue, this is probably a breaking change, and may need to wait for the next major version bump. All the other API's in Nano escape their path components (database names, design documents, views, etc.), but for some reason these partitioned ones do not.
swansontec
added a commit
to swansontec/couchdb-nano
that referenced
this issue
Nov 18, 2021
This fixes issue apache#283. However, this is a breaking change, for reasons descibed in that bug report.
swansontec
added a commit
to swansontec/couchdb-nano
that referenced
this issue
Nov 18, 2021
This is a breaking change, for reasons descibed in that bug report.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
When a partition ID includes special characters, such as '/' or '+', Nano should escape those using
encodeURIComponent
, just as it does already for document ID's, design document names, database names, and so forth.Current Behavior
Nano just concatenates the partition ID into the URI without escaping, which is dangerous:
couchdb-nano/lib/nano.js
Line 1050 in 2d4bd71
Possible Solution
Incorporate
encodeURIComponent
into the following methods:partitionInfo
partitionedList
partitionedFind
partitionedSearch
partitionedView
partitionedListAsStream
partitionedFindAsStream
partitionedSearchAsStream
partitionedViewAsStream
Steps to Reproduce (for bugs)
Any partitioned call involving special characters, such as a base64-encoded string, will randomly fail if the encoding produces special characters:
Context
We are temporarily working around this by doing the
encodeURIcomponent
in our app, before passing the partition ID to Nano. This allows our queries to succeed for now, since we convert characters like '+' to '%2b' before passing to Nano.This implies that fixing this bug would be a breaking change, since presumably other people have run into the same issue and have adopted the same workaround. If the client app calls
encodeURIcomponent
, and then Nano itself callsencodeURIcomponent
again, a character like '+' would become '%2b' in the client code, and then '%252b' in Nano, which is wrong.So, while Nano should address this eventually, it may be necessary to wait for a v10 breaking release.
Your Environment
The text was updated successfully, but these errors were encountered: