@@ -349,38 +349,33 @@ spec: SHA2; urlPrefix: http://csrc.nist.gov/publications/fips/fips180-4/fips-180
349
349
350
350
### Parse |metadata| ### {#parse-metadata}
351
351
352
- This algorithm accepts a string, and returns either `no metadata`, or a set of
353
- valid hash expressions whose hash functions are understood by
354
- the user agent.
352
+ This algorithm accepts a string, and returns a set of hash expressions whose
353
+ hash functions are understood by the user agent.
355
354
356
355
1. Let |result| be the empty set.
357
- 2. Let |empty| be equal to `true`.
358
- 3. For each |item| returned by <a lt="strictly split">splitting |metadata|
359
- on spaces</a> :
360
- 1. Set |empty| to `false`.
361
- 2. Let |option-expression| be the empty string.
362
- 3. Let |tokenlist| be the result of <a lt="strictly split">splitting
363
- |item| on U+003F (?)</a> .
364
- 4. Let |hash-expression| be the |tokenlist|[0] .
365
- 5. If |tokenlist|[1] exists, let |option-expression| be the
366
- |tokenlist|[1] .
367
- 6. Let |base64-value| be the empty string.
368
- 7. Let |tokenlist| be the result of <a lt="strictly split">splitting
369
- |hash-expression| on U+002D (-)</a> .
370
- 8. Let |algorithm| be the |tokenlist|[0] .
371
- 9. If |tokenlist|[1] exists, set |base64-value| be the |tokenlist|[1] .
372
- 10. If |algorithm| is not a hash function recognized by the user agent,
356
+ 2. For each |item| returned by <a lt="strictly split">splitting</a>
357
+ |metadata| on spaces:
358
+ 1. Let |hash-with-opt-token-list| be the result of
359
+ <a lt="strictly split">splitting</a> |item| on U+003F (?).
360
+ 2. Let |hash-expression| be the |hash-with-opt-token-list|[0] .
361
+ 3. Let |base64-value| be the empty string.
362
+ 4. Let |hash-expr-token-list| be the result of
363
+ <a lt="strictly split">splitting</a> |hash-expression| on U+002D (-).
364
+ 5. Let |algorithm| be the |hash-expr-token-list|[0] .
365
+ 6. If |hash-expr-token-list|[1] <a for=list>exists</a> , set
366
+ |base64-value| be the |hash-expr-token-list|[1] .
367
+ 7. If |algorithm| is not a hash function recognized by the user agent,
373
368
[=continue=] the next |item|.
374
- 11. Let |metadata| be a map with its keys initialized as follows:
375
- : "`alg`"
376
- :: |algorithm|
377
- : "`val`"
378
- :: |base64-value|
379
- : "`opt`"
380
- :: |option-expression|
381
- 12. Append |metadata| to |result|.
382
- 4. Return `no metadata` if |empty| is `true`, otherwise return
383
- |result|.
369
+ 8. Let |metadata| be the ordered map «["alg" → |algorithm|,
370
+ "val" → |base64-value|]».
371
+
372
+ Note: Since no `options` are not defined(see the
373
+ [[#integrity-metadata-description]] ), corresponding entry is not set in
374
+ |metadata|. If `options` are defined in a future version of the spec,
375
+ |hash-with-opt-token-list| [1] can be utilized as `options`.
376
+
377
+ 9. <a for=list>Append</a> |metadata| to |result|.
378
+ 3. Return |result|.
384
379
385
380
### Get the strongest metadata from |set| ### {#get-the-strongest-metadata}
386
381
@@ -405,11 +400,10 @@ spec: SHA2; urlPrefix: http://csrc.nist.gov/publications/fips/fips180-4/fips-180
405
400
406
401
1. Let |parsedMetadata| be the result of
407
402
<a href="#parse-metadata">parsing |metadataList|</a> .
408
- 2. If |parsedMetadata| is `no metadata`, return `true`.
409
- 3. If |parsedMetadata| is the empty set, return `true`.
410
- 4. Let |metadata| be the result of <a href="#get-the-strongest-metadata">
403
+ 2. If |parsedMetadata| is the empty set, return `true`.
404
+ 3. Let |metadata| be the result of <a href="#get-the-strongest-metadata">
411
405
getting the strongest metadata from |parsedMetadata|</a> .
412
- 5 . For each |item| in |metadata|:
406
+ 4 . For each |item| in |metadata|:
413
407
1. Let |algorithm| be the |alg| component of
414
408
|item|.
415
409
2. Let |expectedValue| be the |val| component of
@@ -419,7 +413,7 @@ spec: SHA2; urlPrefix: http://csrc.nist.gov/publications/fips/fips180-4/fips-180
419
413
</a> .
420
414
4. If |actualValue| is a case-sensitive match for
421
415
|expectedValue|, return `true`.
422
- 7 . Return `false`.
416
+ 5 . Return `false`.
423
417
424
418
This algorithm allows the user agent to accept multiple, valid strong hash
425
419
functions. For example, a developer might write a `script` element such as:
0 commit comments