From 51047dc7b369b64355d97667b290ebd4b3539cc1 Mon Sep 17 00:00:00 2001
From: Maksim Sadym
Handle the result of fetching - request as a download.
Handle as a download the result of fetching request.
When a user agent is to handle a resource obtained from a fetch as a download, it - should provide the user with a way to save the resource for later use, if a resource is - successfully obtained. Otherwise, it should report any problems downloading the file to the - user.
+To handle as a download a resource:
+ +Let suggested filename be get suggested filename for + resource.
Provide the user with a way to save the resource for later use. If the user + agent needs a filename, it should use suggested filename. Report any problems + downloading the file to the user.
If the user agent needs a filename for a resource being handled as a download, it - should select one using the following algorithm.
+Return suggested filename.
To get suggested filename for resource:
This algorithm is intended to mitigate security dangers involved in downloading files from untrusted sites, and user agents are strongly urged to follow it.
-If the resource has a `Content-Disposition
`
+
If the resource has a `Content-Disposition
`
header, that header specifies the attachment
disposition type, and the
header includes filename information, then let filename have the value specified by
the header, and jump to the step labeled sanitize below. RFC6266
Let resource origin be the origin of the URL of the
- resource being downloaded, unless that URL's scheme
+ resource, unless that URL's scheme
component is data
, in which case let resource origin be
the same as the interface origin, if any.
If there is no interface origin, then let trusted - operation be true. Otherwise, let trusted operation be true if resource origin is the same origin as interface - origin, and false otherwise.
If there is no interface origin, then let trusted operation be true. + Otherwise, let trusted operation be true if resource origin is the + same origin as interface origin, and false otherwise.
If trusted operation is true and the resource has a ` If trusted operation is true and the resource has a `Content-Disposition
` header and that header includes
filename information, then let filename have the value specified by the header, and
jump to the step labeled sanitize below. RFC6266
If the resource has a `Content-Disposition
`
- header and that header specifies the attachment
disposition type, let
- filename have the value of proposed filename, and jump to the step labeled
- sanitize below. RFC6266
If the resource has a `Content-Disposition
` header and that header specifies
+ the attachment
disposition type, let filename have the value of
+ proposed filename, and jump to the step labeled sanitize below.
+ RFC6266
No proposed filename: If trusted operation is true, or if the user indicated a preference for having the resource in question downloaded, let - filename have a value derived from the URL of the resource in an - implementation-defined manner, and jump to the step labeled sanitize below.
If the algorithm reaches this step, then a download was begun from a different origin than
- the resource being downloaded, and the origin did not mark the file as suitable for
+ the resource, and the origin did not mark the file as suitable for
downloading, and the download was not initiated by the user. This could be because a download
attribute was used to trigger the download, or
- because the resource in question is not of a type that the user agent supports.
This could be dangerous, because, for instance, a hostile server could be trying to get a user to unknowingly download private information and then re-upload it to the hostile server, by tricking the user into thinking the data is from the hostile server.
-Thus, it is in the user's interests that the user be somehow notified that the resource in - question comes from quite a different source, and to prevent confusion, any suggested filename - from the potentially hostile interface origin should be ignored.
+Thus, it is in the user's interests that the user be somehow notified that the + resource comes from quite a different source, and to prevent confusion, any + suggested filename from the potentially hostile interface origin should be + ignored.
Let claimed type be the type given by the resource's Let claimed type be the type given by the resource's Content-Type metadata, if any is known. Let named
type be the type given by filename's extension, if any is known. For the purposes of this step, a
@@ -25885,9 +25895,10 @@ document.body.appendChild(wbr);
filename as the filename.
If claimed type and named type are the same type (i.e., the type - given by the resource's Content-Type metadata is consistent - with the type given by filename's extension), - then return filename as the filename.
If the claimed type is known, then alter filename to
@@ -25913,9 +25924,9 @@ document.body.appendChild(wbr);
following the last dot (".
") in the filename to determine the type of the
file, and from that the manner in which the file is to be opened or executed.
User agents should ignore any directory or path information provided by the resource itself,
- its URL, and any download
attribute, in
- deciding where to store the resulting file in the user's file system.
User agents should ignore any directory or path information provided by the resource
+ itself, its URL, and any download
+ attribute, in deciding where to store the resulting file in the user's file system.
Handle navigationParams's response as a download.
Let suggested filename be the result of handle as a download + navigationParams's response.
Invoke WebDriver BiDi download started with navigable and a
new WebDriver BiDi navigation status whose id is navigationId, status is "complete
", and complete", url is navigationParams's response's URL.
Otherwise, the document's type is such that the resource will not affect navigationParams's navigable, e.g., because the resource is to be handed to an external application or because it is an unknown type - that will be processed as a download. Hand-off to external software + that will be processed by handle as a download. Hand-off to external software given navigationParams's response, navigationParams's navigable, navigationParams's final sandboxing flag