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

[COPY] No error generated when destination file name is too long. #54

Open
vishwas-trivedi opened this issue Oct 15, 2019 · 4 comments
Open

Comments

@vishwas-trivedi
Copy link

vishwas-trivedi commented Oct 15, 2019

Problem Description

NWebDAV return 207 (Multi-Status) status code when trying to copy a file where destination file name is too long(320 chars).
In case of IIS if you you specify a destination file name greater than 256 characters, it returns 404 error status.

I've check the source code and found following code in CopyHandler, please have a look :

// Copy collection
await CopyAsync(sourceItem, destinationCollection, destination.Name, overwrite, depth, httpContext, destination.CollectionUri, errors).ConfigureAwait(false);

// Check if there are any errors
if (errors.HasItems)
{
    // Obtain the status document
    var xDocument = new XDocument(errors.GetXmlMultiStatus());

    // Stream the document
    await response.SendResponseAsync(DavStatusCode.MultiStatus, xDocument).ConfigureAwait(false);
}
else
{
    // Set the response
    response.SetStatus(DavStatusCode.Ok);
}

Reproduction Procedure

Try to copy a file where destination file name is greater than 256 characters.

Question

Is this intended behaviors or is it a bug?

@vishwas-trivedi vishwas-trivedi changed the title [COPY] No error generated when file name is too long. [COPY] No error generated when destination file name is too long. Oct 15, 2019
@ramondeklein
Copy link
Owner

I don't think HTTP code 400 (bad request) is the correct code here. The definition for bad request is

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

Source: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1

There is nothing wrong with the syntax, because it depends on the target whether or not the file is correct. On some Unix filesystems, this filename would be perfectly fine. The WebDAV specification doesn't specify a result code for this operation (link). I guess status code 422 (unprocessable entity) might be most appriopriate (possibly wrapped inside a multi-status response).

@ramondeklein
Copy link
Owner

Could you add the actual response body that is generated by the 207 (multi-status) return code?

@vishwas-trivedi
Copy link
Author

@ramondeklein
Sorry my bad, error code returned from IIS is 404 not 400.
I've updated my query accordingly. Please check again.

Could you add the actual response body that is generated by the 207 (multi-status) return code?

Following is the actual XML response that I'm getting from NWebDAV :

<?xml version="1.0"?>
<multistatus xmlns="DAV:">
	<response>
		<href>https://192.168.81.55:5003/WebDAV1/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.txt</href>
		<status>HTTP/1.1 500 Internal Server Error</status>
	</response>
</multistatus>

Could you please take a look?

@ramondeklein
Copy link
Owner

Error-code 500 (internal server error) is never a good idea. I'll take a look, but it might take a few days. I don't have much time at the moment :-(

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