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

Add "validate share data" algorithm #185

Merged
merged 38 commits into from
Aug 17, 2021
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dbbc9df
Add canShare() method
marcoscaceres Sep 18, 2020
a3a4319
add SecureContext and allowed to use check
marcoscaceres Sep 21, 2020
99cccb7
Add http+https checks to validation
marcoscaceres Sep 21, 2020
c60193b
Handle empty files sequence
marcoscaceres Sep 23, 2020
a1a8a8b
Update index.html
marcoscaceres Sep 23, 2020
e04fca8
Merge branch 'master' into canShare
marcoscaceres Sep 23, 2020
7dde1f3
Merge branch 'master' into canShare
marcoscaceres Sep 24, 2020
a42f0b7
Add "validate share data" algorithm
marcoscaceres Sep 23, 2020
84e8c3a
fixup
marcoscaceres Sep 28, 2020
bd53f07
Simplify call to validate share data
marcoscaceres Sep 28, 2020
e683d56
Apply suggestions from code review
marcoscaceres Oct 14, 2020
788a9e2
Merge branch 'master' into validate_data
marcoscaceres Oct 28, 2020
6c0a9f5
Add AU-specific type check, plus reject
marcoscaceres Oct 28, 2020
daa015a
Merge branch 'main' into validate_data
marcoscaceres Jun 17, 2021
6654681
Merge branch 'main' into validate_data
marcoscaceres Aug 8, 2021
1adf6dc
Merge branch 'main' into validate_data
marcoscaceres Aug 8, 2021
bae0c90
Merge branch 'main' into validate_data
marcoscaceres Aug 8, 2021
b494946
Fixup internal slot
marcoscaceres Aug 8, 2021
88865d6
Merge branch 'main' into validate_data
marcoscaceres Aug 9, 2021
f83e582
Merge branch 'main' into validate_data
marcoscaceres Aug 9, 2021
95d9909
Update index.html
marcoscaceres Aug 16, 2021
40618ca
Remove note about allowed to use in priv sec section
marcoscaceres Aug 16, 2021
32eaf09
Merge branch 'main' into validate_data
marcoscaceres Aug 16, 2021
1355ab6
Merge branch 'main' into validate_data
marcoscaceres Aug 16, 2021
abd6bcd
Fixup + remove link to issue 127
marcoscaceres Aug 16, 2021
28e5ad5
fixup typo
marcoscaceres Aug 16, 2021
d86d782
another typo
marcoscaceres Aug 16, 2021
e72fe88
Add missing {{DOMException}} in places
marcoscaceres Aug 16, 2021
f79f7c6
Merge branch 'main' into validate_data
marcoscaceres Aug 16, 2021
a978ab3
Merge branch 'main' into validate_data
marcoscaceres Aug 16, 2021
5b7071e
Remove null check, done elsewhere
marcoscaceres Aug 16, 2021
c03d6ab
Merge branch 'main' into validate_data
marcoscaceres Aug 16, 2021
c8c2525
Remove ref to secure-context
marcoscaceres Aug 16, 2021
b563520
Further fixup
marcoscaceres Aug 16, 2021
a612457
Merge branch 'main' into validate_data
marcoscaceres Aug 17, 2021
9d2f37b
Let UA decide what's a hostile URL
marcoscaceres Aug 17, 2021
5ca9b3a
Merge branch 'main' into validate_data
marcoscaceres Aug 17, 2021
892497f
Include issue 178
marcoscaceres Aug 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 64 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,32 +161,18 @@ <h4>
</li>
<li>[=Consume user activation=] of |window|.
</li>
<li>If none of |data|'s members {{ShareData/title}},
{{ShareData/text}}, or {{ShareData/url}} or {{ShareData/files}} are
present, return <a>a promise rejected with</a> a {{TypeError}}.
<li>Let |base:URL| be [=this=]'s <a>relevant settings object</a>'s
[=environment settings object/API base URL=].
</li>
<li>If |data|'s {{ShareData/files}} member is present:
<ol>
<li>If |data|'s {{ShareData/files}} member is empty, or if the
implementation does not support file sharing, return <a>a
promise rejected with</a> a {{TypeError}}, and abort these
steps.
</li>
</ol>
<li>If [=validate share data=] with |data| and |base| returns
false, then return [=a promise rejected with=] a {{TypeError}}.
</li>
<li>If |data|'s {{ShareData/url}} member is present:
<ol>
<li>Let |base:URL| be the [=this=] value's <a>relevant settings
object</a>'s [=environment settings object/api base URL=].
</li>
<li>Let |url:URL| be the result of running the <a>URL
parser</a> on |data|'s {{ShareData/url}} with |base|.
</li>
<li>If |url| is failure, return <a>a promise rejected with</a>
{{TypeError}}.
</li>
<li>If |url|'s [=URL/scheme=] is not "http" or "https", return
<a>a promise rejected with</a> {{TypeError}}.
<li>Assert: |url| is {{URL}}.
</li>
<li>Set |data| to a copy of |data|, with its {{ShareData/url}}
member set to the result of running the <a>URL serializer</a>
Expand Down Expand Up @@ -271,6 +257,65 @@ <h4>
or bypassing the UI if there is only a single share target.
</div>
</section>
<section>
<h3>
Validate share data
</h3>
<p>
To <dfn>validate share data</dfn> with |data:ShareData| and
|base:URL|, run the following steps:
</p>
<ol class="algorithm">
<li>If none of |data|'s members {{ShareData/title}},
{{ShareData/text}}, or {{ShareData/url}} or {{ShareData/files}} are
present, return false.
</li>
<li>Let |titleTextOrUrl:boolean| be true if any of
{{ShareData/title}}, or {{ShareData/text}}, or {{ShareData/url}} is
present.
</li>
<li>If |data|'s {{ShareData/files}} member is present:
<ol>
<li>If |titleTextOrUrl| is false and |data|'s
{{ShareData/files}} member is empty, return false.
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
<p class="note">
This causes a `{ files: [] }` dictionary to be treated as
an empty dictionary. However, passing a dictionary like
`{text: "text", files: []}` is fine, as `files` is just
ignored.
</p>
</li>
<li>If the implementation does not support file sharing, return
false.
</li>
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
<li>If the user agent believes sharing any of the files in
`files` would result in a potentially hostile share, return
false.
</li>
</ol>
</li>
<li>If |data|'s {{ShareData/url}} member is present:
<ol>
<li>Let |url:URL| be the result of running the [=URL parser=]
on |data|'s {{ShareData/url}} member, with |base|, and no
encoding override.
</li>
<li>If |url| is failure, return false.
</li>
<li>
<p>
If |url| is a URL the user agent deems potentially hostile
(e.g., "file:") or wouldn't make sense to outside the scope
of the document (e.g., "blob:"), return false.
</p>
<aside class="issue" data-number="178"></aside>
</li>
</ol>
</li>
<li>Return true.
</li>
</ol>
</section>
</section>
<section data-dfn-for="ShareData">
<h3>
Expand Down