You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Samuel <sa...@gmail.com> on 2010/09/07 18:27:58 UTC

database names containing +

Hi,

couchdb is reporting an error if I try to create or delete a database
with a "+" in its name:

PUT /a+ HTTP/1.1
Content-Type:application/json
Content-Length:0
Host:localhost:5984

HTTP/1.1 400 Bad Request
Server: CouchDB/1.1.0a4875101-git (Erlang OTP/R14B)
Date: Tue, 07 Sep 2010 16:04:37 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 181
Cache-Control: must-revalidate

{"error":"illegal_database_name","reason":"Only lowercase characters
(a-z), digits (0-9), and any of the characters _, $, (, ), +, -, and /
are allowed. Must begin with a letter."}

Encoding it works, though:

PUT /a%2B HTTP/1.1
Content-Type:application/json
Content-Length:0
Host:localhost:5984

HTTP/1.1 201 Created
Server: CouchDB/1.1.0a4875101-git (Erlang OTP/R14B)
Location: http://localhost:5984/a%2B
Date: Tue, 07 Sep 2010 16:25:38 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 12
Cache-Control: must-revalidate

{"ok":true}

Is the + symbol special for some reason? Any other character seem to
work without encoding?

Cheers
-- 
Samuel

Re: database names containing +

Posted by Taras Puchko <ta...@gmail.com>.
Hi,

It looks like CouchDB has the same requirement for document ids. This
might pose a problem with clients that build URLs dynamically.

I've tried RESTEasy:
System.out.println(UriBuilder.fromPath("http://localhost/mydb").segment("a/b+c").build().toString());

It prints:
http://localhost/mydb/a%2Fb+c


Another problem I've found is that CouchDB doesn't allow matrix
parameters in a segment so _view/myview;p1=v1;p2=v2/myId doesn't work.


I personally have found [1] invaluable when trying to understand URL encoding.

[1] http://www.lunatech-research.com/archives/2009/02/03/what-every-web-developer-must-know-about-url-encoding

Cheers,
Taras

On Tue, Sep 7, 2010 at 8:29 PM, Samuel <sa...@gmail.com> wrote:
> I always get lost when trying to re-interpret the URI RFC, but I
> understood that it is reserved for queries, and in my case it is in a
> path:
>
>  Within a path segment, the characters
>     "/", ";", "=", and "?" are reserved.
>
> According to this, the only reserved character allowed for DB names is
> / that certainly should be encoded.
>
> It's not a big deal, I just wanted to avoid as much URL processing as
> possible and found strange that + required encoding and, for example
> $, didn't
>
> Cheers
> On 7 September 2010 18:52, Noah Slater <ns...@apache.org> wrote:
>>
>> On 7 Sep 2010, at 17:27, Samuel wrote:
>>
>>> Is the + symbol special for some reason? Any other character seem to
>>> work without encoding?
>>
>> It is a reserved URI character, so it needs to be encoded as a literal value.
>>
>
>
>
> --
> Samuel
>

Re: database names containing +

Posted by Samuel <sa...@gmail.com>.
I always get lost when trying to re-interpret the URI RFC, but I
understood that it is reserved for queries, and in my case it is in a
path:

  Within a path segment, the characters
     "/", ";", "=", and "?" are reserved.

According to this, the only reserved character allowed for DB names is
/ that certainly should be encoded.

It's not a big deal, I just wanted to avoid as much URL processing as
possible and found strange that + required encoding and, for example
$, didn't

Cheers
On 7 September 2010 18:52, Noah Slater <ns...@apache.org> wrote:
>
> On 7 Sep 2010, at 17:27, Samuel wrote:
>
>> Is the + symbol special for some reason? Any other character seem to
>> work without encoding?
>
> It is a reserved URI character, so it needs to be encoded as a literal value.
>



-- 
Samuel

Re: database names containing +

Posted by Noah Slater <ns...@apache.org>.
On 7 Sep 2010, at 17:27, Samuel wrote:

> Is the + symbol special for some reason? Any other character seem to
> work without encoding?

It is a reserved URI character, so it needs to be encoded as a literal value.