Decode destination header for doc copy#1072
Conversation
7223dd9 to
0cb99b4
Compare
74752d0 to
b8643cc
Compare
| end, | ||
| {TargetDocId, TargetRevs} = couch_httpd_db:parse_copy_destination_header(Req), | ||
| {TargetDocId0, TargetRevs} = couch_httpd_db:parse_copy_destination_header(Req), | ||
| TargetDocId = list_to_binary(mochiweb_util:unquote(TargetDocId0)), |
There was a problem hiding this comment.
I think the problem here is that the doc id isn't always escaped (that change is fairly recent).
There was a problem hiding this comment.
Thanks, Bob. According to statement from Garren in issue #977
Which means the API works although it doesn't follow 100% the Destination header's spec which states the header should contain an URI, hence its value should be encoded if it includes characters outside the valid range.
If spec implies that destination header for couchdb should be encoded, we need to decode here. If there is no escaped character in docid for target doc, calling mochiweb_util:unquote/1 will not change the content of docid.
|
There's several places where we url encode and url decode, and we've changed where we do that over multiple versions of couchdb. I'm struggling to see if we can call unquote unilaterally here. Do we need to care about this across versions or is it sufficient to be internally consistent? |
77126ba to
85880cf
Compare
|
https://tools.ietf.org/html/rfc4918#section-10.3 From above links, we know that |
|
My understanding is that it is not restricted to encode or un-encode URI. For with url encoding, it is safe from security's point of view. When discussing with Bob and Paul, Bob mentioned "we should encode the destination header value, and decode it wherever we might need to (if anywhere)". Here is one place we need to decode URI. |
0dc6b37 to
9f60d6d
Compare
9f60d6d to
2f5db85
Compare
2f5db85 to
51ac2f5
Compare
Overview
The Fauxton URL request to CouchDB encodes the user input and sets the Destination header with the encoded value of the new ID when sending the COPY request. This PR is aimed to make CouchDB to decode Destination header, and creates the ID without escaped values.
Testing recommendations
Related Issues or Pull Requests
issue #977
Checklist