garrensmith opened a new issue #977: COPY doc doesn't decode the destination 
header
URL: https://github.com/apache/couchdb/issues/977
 
 
   We have an issue when a user tries to clone/copy a doc in Fauxton and the 
new doc id has Unicode characters. 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. CouchDB does not decode this, and just 
creates the ID including escaped values literally.
   
   #Context
   Cloning/copying a document with a new ID that includes Unicode chars (e.g. 
xxx?xxx) fails because CouchDB takes the encoded value literally, creating a 
doc with ID xxx%E5%95%8Axxx instead of xxx?xxx. E.g.:
   curl 'https://antonio-cloudant.cloudant.com/appts1/original1' -X COPY -H 
'Content-Type: application/json' -H 'Destination: xxx%E5%95%8Axxx'
   
   Note that using xxx?xxx directly in curl works. The new doc will have ID 
xxx?xxx:
   curl 'https://antonio-cloudant.cloudant.com/appts1/original1' -X COPY -H 
'Content-Type: application/json' -H 'Destination: xxx?xxx'.
   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.
   
   CouchDB COPY doc: 
http://docs.couchdb.org/en/2.0.0/api/document/common.html#copy--db-docid
   
   ## Possible Solution
   From the Fauxton side we might bypass the COPY api and just create a new doc 
via the PUT request. But this doesn't solve the CouchDB issue. Ideally CouchDB 
needs to decode the destination header.
   
   ## Steps to Reproduce (for bugs)
   1. Go to a database in Fauxton
   2. Click on a document.
   3. Click on Clone Document
   4. Add a doc id like `this/is/an/example` or `xxx?xxx`
   5. Click on Clone document
   6. The newly created document will be incorrect as it will be the url 
encoded doc.
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to