aspnet / HttpAbstractions

[Archived] HTTP abstractions such as HttpRequest, HttpResponse, and HttpContext, as well as common web utilities. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
382 stars 193 forks source link

Invalid Content Disposition Header #973

Closed Tratcher closed 6 years ago

Tratcher commented 6 years ago

From @Petermarcu on November 27, 2017 5:1

@StefanoD opened this here: https://github.com/dotnet/core/issues/1106

According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition the parameters of the content disposition header must be quoted. Instead APS.Net Core sends them without quote:

attachment; filename=latest_bin.txt; filename*=UTF-8''latest_bin.txt

I'm using .Net Core 2.0

Copied from original issue: aspnet/Home#2288

Tratcher commented 6 years ago

What API are you using to send the file? an MVC FileResult?

StefanoD commented 6 years ago
// GET: api/values
[HttpGet]
public async Task<IActionResult> Get()
{
        // ...
    var memory = new MemoryStream();
    using (var stream = new FileStream(path, FileMode.Open))
    {
        await stream.CopyToAsync(memory);
    }
    memory.Position = 0;

    return File(memory, "application/octet-stream", lastetUpdate.Name);
}
Tratcher commented 6 years ago

(Unrelated) Why isn't that just?

    return PhysicalFile(path, "application/octet-stream", lastetUpdate.Name);
Tratcher commented 6 years ago

See https://tools.ietf.org/html/rfc6266#section-4.1. filename may either be a token or a quoted string. filename*'s format does not use quotes.

 filename-parm       = "filename" "=" value
                     | "filename*" "=" ext-value
 token         = <token, defined in [RFC2616], Section 2.2>
 quoted-string = <quoted-string, defined in [RFC2616], Section 2.2>
 value         = <value, defined in [RFC2616], Section 3.6>
               ; token | quoted-string
 ext-value     = charset  "'" [ language ] "'" value-chars
               ; like RFC 2231's <extended-initial-value>
               ; (see [RFC2231], Section 7)
StefanoD commented 6 years ago

Ok, thx. Then in this case this is not a bug? Sorry for the noise!

StefanoD commented 6 years ago

Qt 4.8 had issues to parse this, This is why I came to this conclusion and the mozilla reference, of course.

aspnet-hello commented 6 years ago

This issue was moved to aspnet/Home#2677