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

incorrect MOVE results in deletion #118

Open
FND opened this issue Nov 9, 2014 · 1 comment
Open

incorrect MOVE results in deletion #118

FND opened this issue Nov 9, 2014 · 1 comment

Comments

@FND
Copy link
Contributor

FND commented Nov 9, 2014

MOVEing a resource to itself results in the corresponding file being deleted:

$ echo lipsum > foo

$ curl -v -X MOVE -H "Destination: http://127.0.0.1:8000/foo" "http://127.0.0.1:8000/foo"
< HTTP/1.1 500 Internal Server Error
...
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml">
    <a:exception>Error: ENOENT, rename '.../foo'</a:exception>
    <a:message>ENOENT, rename '.../foo'</a:message>
<a:file></a:file>
<a:line></a:line>
<a:jsdav-version>0.3.2</a:jsdav-version>
</d:error>

$ ls foo
ls: foo: No such file or directory

Similarly, MOVEing a nonexistent resource to an existing resource deletes the latter:

$ echo lipsum > foo

$ curl -v -X MOVE -H "Destination: http://127.0.0.1:8000/foo" "http://127.0.0.1:8000/bar"
< HTTP/1.1 500 Internal Server Error
...
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml">
    <a:exception>Error: ENOENT, rename '.../bar'</a:exception>
    <a:message>ENOENT, rename '.../bar'</a:message>
<a:file></a:file>
<a:line></a:line>
<a:jsdav-version>0.3.2</a:jsdav-version>
</d:error>

$ ls foo
ls: foo: No such file or directory

That seems undesirable as it leads to unexpected data loss.


This is how I start my jsDAV server:

var jsDAV = require("jsDAV/lib/jsdav");
var locks = require("jsDAV/lib/DAV/plugins/locks/fs");
var path = require("path");

var root = __dirname

jsDAV.debugMode = true;
jsDAV.createServer({ node: root }, 8000);
@tranminhtam
Copy link

tranminhtam commented May 8, 2017

It seems validations missing caught special cases
You can refer on lib/DAV/handler.js, then find "this.getCopyAndMoveInfo = function(cbcopymove) {"
to add more validation

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

No branches or pull requests

2 participants