Skip to content

Commit fd3d0f8

Browse files
committed
Move partitioning checks into FileAPI
1 parent c97d7f9 commit fd3d0f8

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

index.bs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,15 +1512,25 @@ A [=blob URL store=] is a [=map=]
15121512
where [=map/keys=] are [=valid URL strings=]
15131513
and [=map/values=] are [=blob URL Entries=].
15141514

1515-
A <dfn export>blob URL entry</dfn> consists of
1516-
an <dfn export for="blob URL entry">object</dfn> (of type {{Blob}} or {{MediaSource}}),
1517-
and an <dfn export for="blob URL entry">environment</dfn> (an [=environment settings object=]).
1518-
15191515
[=map/Keys=] in the [=blob URL store=] (also known as <dfn lt="blob URL|object URL" export>blob URLs</dfn>)
15201516
are [=valid URL strings=] that when [=URL parser|parsed=]
15211517
result in a [=/URL=] with a [=url/scheme=] equal to "`blob`",
15221518
an [=empty host=], and a [=url/path=] consisting of one element itself also a [=valid URL string=].
15231519

1520+
A <dfn export>blob URL entry</dfn> is used to store an object of type {{Blob}} or {{MediaSource}}.
1521+
1522+
A [=blob URL entry=] has an <dfn export for="blob URL entry">environment</dfn> (an [=environment settings object=]).
1523+
1524+
<div algorithm="obtainBlobObject">
1525+
To <dfn export id=blob-url-obtain-object>obtain a blob object</dfn> given a [=blob URL entry=] |blobUrlEntry|, an [=environment=] |environment|, and an optional boolean |isNavigation| (default false):
1526+
1527+
1. Let |isAuthorized| be true.
1528+
1. If |isNavigation| is false, let |isAuthorized| be the result of [=checking for same-partition blob URL usage=] with |blobUrlEntry| and |environment|.
1529+
1. If |isAuthorized| is false, then return failure.
1530+
1. Return |blobUrlEntry|'s object.
1531+
1532+
</div>
1533+
15241534
<div algorithm="createBlobURL">
15251535
To <dfn id="unicodeBlobURL" lt="generate a new blob URL|generating a new blob URL">
15261536
generate a new blob URL</dfn>, run the following steps:
@@ -1595,6 +1605,22 @@ as the serialization of the origin of the environment that created the blob URL,
15951605
but for opaque origins the origin itself might be distinct. This difference isn't
15961606
observable though, since a revoked blob URL can't be resolved/fetched anymore anyway.
15971607

1608+
### Access restrictions on blob URLs ### {#partitioningOfBlobUrls}
1609+
1610+
<a>Blob URLs</a> can only be fetched from environments where the [=storage key=] matches that of
1611+
the environment where the <a>blob URL</a> was created. <a>blob URL</a> navigations are not subject
1612+
to this restriction.
1613+
1614+
<div algorithm="checkForSamePartitionBlobUrlUsage">
1615+
To <dfn export id=blob-url-partition-check>check for same-partition blob URL usage</dfn> given a [=blob URL entry=] |blobUrlEntry| and an [=environment=] |environment|:
1616+
1617+
1. Let |blobStorageKey| be the result of [=obtaining a storage key for non-storage purposes=] with |blobUrlEntry|'s [=blob URL entry/environment=].
1618+
1. Let |environmentStorageKey| be the result of [=obtaining a storage key for non-storage purposes=] with |environment|.
1619+
1. If |blobStorageKey| is not [=storage key/equal=] to |environmentStorageKey|, then return false.
1620+
1. Otherwise, return true.
1621+
1622+
</div>
1623+
15981624
<h4 id="lifeTime" dfn for="blob url" lt="lifetime|lifetime stipulation" export>Lifetime of blob URLs</h4>
15991625

16001626
This specification extends the [=unloading document cleanup steps=] with the following steps:
@@ -1633,12 +1659,12 @@ The <dfn method for=URL id="dfn-revokeObjectURL">revokeObjectURL(|url|)</dfn> st
16331659
1. Let |url record| be the result of [=URL parser|parsing=] |url|.
16341660
1. If |url record|'s [=url/scheme=] is not "`blob`", return.
16351661
1. Let |entry| be |url record|'s [=blob URL entry=].
1636-
1. Let |blobStorageKey| be the result of [=obtaining a storage key for non-storage purposes=] with |entry|'s [=blob URL entry/environment=].
1637-
1. Let |currentStorageKey| be the result of [=obtaining a storage key for non-storage purposes=] with the [=current settings object=].
1638-
1. If |blobStorageKey| is not [=storage key/equal=] to |currentStorageKey|, return.
1662+
1. If |entry| is null, return.
1663+
1. Let |isAuthorized| be the result of [=checking for same-partition blob URL usage=] with |entry| and the [=current settings object=].
1664+
1. If |isAuthorized| is false, return.
16391665
1. [=Remove an entry from the Blob URL Store=] for |url|.
16401666

1641-
Note: This means that rather than throwing some kind of error, attempting to revoke a URL that isn't registered or that was registered from an environment with a different storage key will silently fail.
1667+
Note: This means that rather than throwing some kind of error, attempting to revoke a URL that isn't registered or that was registered from an environment in a different storage partition will silently fail.
16421668
User agents might display a message on the error console if this happens.
16431669

16441670
Note: Attempts to dereference |url| after it has been revoked will result in a [=network error=].

0 commit comments

Comments
 (0)