[ 
https://issues.apache.org/jira/browse/COUCHDB-2748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14653321#comment-14653321
 ] 

Robert Kowalski commented on COUCHDB-2748:
------------------------------------------

[~rnewson] 

> You can't say `%` right before `3A` without it appearing to be the encoding 
> for a `:`

I can, as it is considered as a gen-delimiter in this part of the url. `:`, 
belongs to to the group of gen-delims, according to 
https://tools.ietf.org/html/rfc3986#section-2.2. The gen-delims belong to the 
reserved characters. As it is used as a delimiter and should not be encoded, I 
think the browser's window.encodeURI behaves right:

{code}
window.encodeURI("http://foo.bar/percent%double:colon";)
{code}

In this area of the url `:` is usually used to note the port. That means %3A 
must be %3A

But it seems it is encoded anyway.


[~eiri] 

that sounds good in case of my last example and as I demoed it works for this 
case. But why does the following happens then? (see also examples before which 
are the actual bug report):

{code}
curl -X PUT http://localhost:5984/testrainyday/BANANA%253A21%25 -d '{}'
{code}

CouchDB returns: 

{code}
{"_id":"BANANA%3A21%","_rev":"1-967a00dff5e02add41819138abb3284d"}
{code}

Based on the response (btw: I also get that by reading from all_docs) I want to 
use it in my program:

{code}
curl http://localhost:5984/testrainyday/BANANA%3A21%
{code}

CouchDB says:

{code}
{"error":"not_found","reason":"missing"}
{code}
 
Result: Clients They get a different id as response to doc creation (and from 
all_docs) which they can't use to receive the document. 



> encoding problems with reserved chars
> -------------------------------------
>
>                 Key: COUCHDB-2748
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2748
>             Project: CouchDB
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: Database Core
>            Reporter: Robert Kowalski
>
> Let's create a database!
> {noformat}
> curl -X PUT http://localhost:5984/testrainyday
> {noformat}
> I get:  {{{"ok":true}}}
> Let's create a document called BANANA%253A21%25
> {noformat}
> curl -X PUT http://localhost:5984/testrainyday/BANANA%253A21%25 -d '{}'
> {noformat}
> CouchDB returns:
> {noformat}
> {"_id":"BANANA%3A21%","_rev":"1-967a00dff5e02add41819138abb3284d"}
> {noformat}
> (note the changed id - it misses the 25)
> lets use the id from the response to retrieve the doc:
> {noformat}
> curl http://localhost:5984/testrainyday/BANANA%3A21%
> {noformat}
> i get:
> {noformat}
> {"error":"not_found","reason":"missing"}
> {noformat}
> :(
> New try:
> curl http://localhost:5984/testrainyday/_all_docs
> returns:
> {noformat}
> {"total_rows":1,"offset":0,"rows":[
> {"id":"BANANA%3A21%","key":"BANANA%3A21%","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}
> ]}
> {noformat}
> I get BANANA%3A21% as id again, but when I want to curl it or use in my JS 
> application, I get `{"error":"not_found","reason":"missing"}`
> I noticed that it works for these two ids:
> curl -X PUT http://localhost:5984/testrainyday/BANANA%25 -d '{}'
> {noformat}
> {"ok":true,"id":"BANANA%","rev":"1-967a00dff5e02add41819138abb3284d"}
> {noformat}
> In this last case it works magically for both ids:
> {noformat}
> (17:54:11) [robert@tequila-work] ~ $ curl -X PUT 
> http://localhost:5984/testrainyday/BANANA%25 -d '{}'
> {"ok":true,"id":"BANANA%","rev":"1-967a00dff5e02add41819138abb3284d"}
> (17:55:45) [robert@tequila-work] ~ $ curl 
> http://localhost:5984/testrainyday/BANANA%25
> {"_id":"BANANA%","_rev":"1-967a00dff5e02add41819138abb3284d"}
> (17:55:57) [robert@tequila-work] ~ $ curl 
> http://localhost:5984/testrainyday/BANANA%
> {"_id":"BANANA%","_rev":"1-967a00dff5e02add41819138abb3284d"}
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to