Re: [w3c/clipboard-apis] Add `unsanitized` option to async clipboard API. (PR #197)

@sanketj requested changes on this pull request.



> @@ -542,6 +542,19 @@ url: https://w3c.github.io/permissions/#permissions-task-source; type: dfn;
    * Custom format [=string/starts with=] `"web "`("web" followed by U+0020 SPACE) prefix
     and suffix (after stripping out `"web "`) passes the [=parsing a MIME type=] check.
 
+ <h3 id="unsanitized-data-types-x"><dfn>Unsanitized data types</dfn></h3>
+
+  The implementation MAY recognize the native OS clipboard format description
+  for the following data types, to be able to populate the

What do you mean by "correct description for paste events"?

> @@ -542,6 +542,19 @@ url: https://w3c.github.io/permissions/#permissions-task-source; type: dfn;
    * Custom format [=string/starts with=] `"web "`("web" followed by U+0020 SPACE) prefix
     and suffix (after stripping out `"web "`) passes the [=parsing a MIME type=] check.
 
+ <h3 id="unsanitized-data-types-x"><dfn>Unsanitized data types</dfn></h3>
+
+  The implementation MAY recognize the native OS clipboard format description
+  for the following data types, to be able to populate the
+  {{ClipboardItem}} with the correct description for paste events, and
+  set the correct data format on the OS clipboard in response to copy and cut
+  events.
+
+   These data types must not be sanitized and should be exposed by UAs

Is it right to say "must not be sanitized"? We should only not sanitize if these types are passed as part of the unsanitized option.

> @@ -798,17 +816,25 @@ url: https://w3c.github.io/permissions/#permissions-task-source; type: dfn;
   {{Clipboard/read()}} returns a {{Promise}} to [=clipboard items=] object that represents contents of [=system clipboard data=].
   </p>
 
+  {{ClipboardUnsanitizedFormats/unsanitized}} is a [=sequence=] of {{DOMString}}s corresponding to the [=representation/mime type=] that are in the [=unsanitized data types=].

```suggestion
  {{ClipboardUnsanitizedFormats/unsanitized}} is a [=sequence=] of {{DOMString}}s corresponding to the [=representation/mime type=] that should be handled as [=unsanitized data types=].
```

> @@ -837,11 +863,23 @@ url: https://w3c.github.io/permissions/#permissions-task-source; type: dfn;
       
       1. Set |representation|'s [=representation/MIME type=] to |mimeType|.
 
+      1. Let |isUnsanitized| be |false|.

Does this step need to be done for each format (ie. inside the for each loop below)?

>        1. Set |representation|'s [=representation/data=] to |systemClipboardRepresentation|'s [=system clipboard representation/data=].
 
        Issue: It should be possible to read the data asynchronously from the system clipboard after the author calls getType, however, this set of steps implies that data will be provided at the time of read.
       
-      1. The user agent, MAY sanitize |representation|'s [=representation/data=], unless |representation|'s [=representation/MIME type=]'s essence is "image/png", which should remain unsanitized to preserve meta data.
+      1. The user agent, MUST NOT sanitize |representation|'s [=representation/data=], if it satisfies the below conditions:
+      
+       1. |representation|'s [=representation/MIME type=]'s [=MIME type/essence=] is "image/png", which should remain unsanitized to preserve meta data.

Should we include this condition in the definition of "unsanitized data types" above? Something like: Unsanitized data types are "image/png" and those that are passed by the user as part of the unsanitized option.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/pull/197#pullrequestreview-1730610785
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/pull/197/review/1730610785@github.com>

Received on Tuesday, 14 November 2023 19:51:25 UTC