Export to GitHub

couchdb4j - issue #7

Document IDs should be URLEncoded


Posted on Mar 17, 2008 by Grumpy Ox

What steps will reproduce the problem? 1. Open a session and get a database 2. saveDocument() or getDocument() a docId with a slash in it

What is the expected output? What do you see instead?

The operation fails and/or produces unintended consequences, e.g. saving a document with the _id "meta/post" resulted in the creation of "meta" instead.

What version of the product are you using? On what operating system?

SVN trunk; Linux; CouchDB 0.7.2

Comment #1

Posted on Apr 11, 2008 by Helpful Elephant

Is it valid to have slashes in CouchDB doc Ids?

Comment #2

Posted on Apr 12, 2008 by Grumpy Ox

According to http://wiki.apache.org/couchdb/HttpDocumentApi document names are not restricted at all, module multibyte incompatibilities. It works if slashes are URL-encoded to %2F.

Comment #3

Posted on Aug 22, 2008 by Helpful Elephant

I'm not sure if this is still a problem or not, but I added a java.net.URLEncoder.encode(url,'utf-8') around the document id.

I hope this fixes the problem... I know it's a bit late, but the current svn trunk should have the change.

Comment #4

Posted on Sep 4, 2008 by Helpful Wombat

This just seems to break things for me. For example, if I try to create a view document with id "_design/myview" in database "mydb", then it actually creates a new database called "mydb/_design/myview". Removing the call to java.net.URLEncoder.encode() fixes the problem.

Comment #5

Posted on Sep 16, 2008 by Happy Kangaroo

I agree with Alex, there needs to be a more selective use of the URL encoding. The way it is done in the trunk breaks creation of databases by quoting trailing slashes. This can be seen by just running the supplied test cases.

Status: Fixed

Labels:
Type-Defect Priority-Medium