Closed georgelviv closed 5 years ago
This is not a bug, but just this module following the specification for the content-disposition header. To have an @
character in the filename, it needs to be contained within "
characters, i.e. a valid header would be attachment; filename="@.xlsx"
.
You can find more in section 4.1 of the specification where it defines the grammar of the header, namely:
content-disposition = "Content-Disposition" ":"
disposition-type *( ";" disposition-parm )
disposition-type = "inline" | "attachment" | disp-ext-type
; case-insensitive
disp-ext-type = token
disposition-parm = filename-parm | disp-ext-parm
filename-parm = "filename" "=" value
| "filename*" "=" ext-value
disp-ext-parm = token "=" value
| ext-token "=" ext-value
ext-token = <the characters in token, followed by "*">
Defined in [RFC2616]:
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
Defined in [RFC5987]:
ext-value = <ext-value, defined in [RFC5987], Section 3.2>
The filename parameter is defined above with the grammar filename-parm = "filename" "=" value
and value
is defined above with the grammar value = token | quoted-string
and without the "
it would match against the token
grammar, which is
token = 1*<any CHAR except CTLs or separators>
separators = "(" | ")" | "<" | ">" | "@"
| "," | ";" | ":" | "\" | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT
which defines the @
character as being an invalid charter to appear in the unquoted value.
Thank you!
BUG: I receive header with filename with
@
symbol.Steps to reproduce: 1) Run code:
ContentDisposition.parse("attachment; filename=@.xlsx");
Expected Results: Should works fine
Actual Results: will throw Error
invalid parameter format