Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow forward slashes in attachment names #1683

Closed
zgramana opened this issue Apr 7, 2016 · 1 comment · Fixed by #1722
Closed

Allow forward slashes in attachment names #1683

zgramana opened this issue Apr 7, 2016 · 1 comment · Fixed by #1722
Assignees
Milestone

Comments

@zgramana
Copy link
Contributor

zgramana commented Apr 7, 2016

Given an attachment with a forward slash in the name, SG will not handle the route correctly. Instead, the route matching should not be greedy with respect to /, and instead stop caring about / once it has a dbname,doc-id tuple.

For example, the following fail, but would be expected to work (as they do for local docs).
Given:

  1. db name = 'todomvc'
  2. doc id = 'app'
  3. attachment name = 'folder/todoEscape.js'

I expect this to return '201':

curl -X "PUT" "http://127.0.0.1:4984/todomvc/app/folder/todoEscape.js?rev=foo \
    -H "Content-Type: application/javascript" \
    -d ...

And I expect this command to return the .js file that I previously PUT.

curl http://127.0.0.1:4984/todomvc/app/folder/todoEscape.js
@ajres
Copy link
Contributor

ajres commented Apr 26, 2016

This feature is already supported, but with the following caveats.

When both file names and attachment names contain '/' characters, there is no obvious way to determine the boundary between the file name and attachment name.

SG handles this by requiring embedded slashes to be escaped using URL encoding ('%2F') in all requests.

e.g. the following steps work:

curl -X PUT http://localhost:4985/db/doca -H "Content-Type: application/json" -d '{"foo":"bar"}'

curl -vX PUT http://localhost:4985/db/doca/attachments%2F50k.png?rev=2-24bfd66d8c0b8a150e12deefd4a06edf --data-binary @50k.png -H "Content-Type: image/png"

curl -vX GET http://localhost:4985/db/doca/attachments%2F50k.png > /dev/null

Additional unit tests have been added to ensure this behaviour does not regress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants