You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/03/23 23:43:30 UTC
[GitHub] [couchdb] jjrodrig opened a new issue #1988: PUT /db/doc & POST /db
perform different attachment name validation
jjrodrig opened a new issue #1988: PUT /db/doc & POST /db perform different attachment name validation
URL: https://github.com/apache/couchdb/issues/1988
[NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )
## Description
PUT & POST operations for creating documents in a database enforce different validation rules over the attachment names of the new document.
When a document is created with a PUT operation "_foo.txt" is not accepted as a valid attachment name. If the document is created by a POST operation the "_foo.txt" attachment name is accepted.
[NOTE]: # ( Describe the problem you're encountering. )
[TIP]: # ( Do NOT give us access or passwords to your actual CouchDB! )
## Steps to Reproduce
- Create a new document with an attachment with the name "_foo.txt" using PUT
```
curl -H 'Content-Type: application/json' -X PUT \
-d '{"_id": "bin_doc2", "_attachments": { "_foo.txt": { "content_type": "text/plain", "data":"VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="}}}' \
http://localhost:15984/test/bin_doc2
```
- An error is returned stating that _foo.txt is not allowed as attachment name as it starts by _
````
{"error":"bad_request","reason":"Attachment name '_foo.txt' starts with prohibited character '_'"}
````
- Create a new document with an attachment with the name "_foo.txt" using POST
```
curl -H 'Content-Type: application/json' -X POST \
-d '{"_id": "bin_doc2", "_attachments": { "_foo.txt": { "content_type": "text/plain", "data":"VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="}}}' \
http://localhost:15984/test
```
- Document is created
```
{"ok":true,"id":"bin_doc2","rev":"1-92cd355222a3c08e725e08ba14259e60"}
```
- Attachment with _ can be retrieved
```
> curl http://localhost:15984/test/bin_doc2/_foo.txt
> This is a base64 encoded text
```
- Attachment can not be deleted
```
> curl -X DELETE http://localhost:15984/test/bin_doc2/_foo.txt?rev=1-92cd355222a3c08e725e08ba14259e60
> {"error":"bad_request","reason":"Attachment name '_foo.txt' starts with prohibited character '_'"}
```
- Attachment can not be updated
```
< curl -H 'Content-Type: text/plain' -X PUT -d 'VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=' http://localhost:15984/test/bin_doc2/_foo.txt?rev=1-92cd355222a3c08e725e08ba14259e60
> {"error":"bad_request","reason":"Attachment name '_foo.txt' starts with prohibited character '_'"}
```
[NOTE]: # ( Include commands to reproduce, if possible. curl is preferred. )
## Expected Behaviour
PUT & POST should enforce the same validations rules over the document
[NOTE]: # ( Tell us what you expected to happen. )
## Your Environment
```
{
"couchdb": "Welcome",
"version": "2.3.0-8efe9b290",
"git_sha": "8efe9b290",
"uuid": "fake_uuid_for_dev",
"features": [
"partitioned",
"pluggable-storage-engines",
"scheduler"
],
"vendor": {
"name": "The Apache Software Foundation"
}
}
```
[TIP]: # ( Include as many relevant details about your environment as possible. )
[TIP]: # ( You can paste the output of curl http://YOUR-COUCHDB:5984/ here. )
* CouchDB Version used: Built from master (2.3.0-8efe9b290)
* Browser name and version:
* Operating System and version: MacOS 10.14.3
## Additional context
[TIP]: # ( Add any other context about the prbolem here. )
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services