Skip to content

Commit

Permalink
Fix port-part matches algorithm for a null port input (#435)
Browse files Browse the repository at this point in the history
The algorithm was expecting a non-null possibly-empty string while being called with null or a non-empty string. Now the algorithm correctly handles a null or non-empty input string.
  • Loading branch information
antosart authored Dec 17, 2024
1 parent 19c98a2 commit 398a20e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4153,16 +4153,19 @@ Content-Type: application/reports+json
`port-part` matching
</h5>

An <a>ASCII string</a> |input| <dfn export>`port-part` matches</dfn> [=/URL=] |url| if a CSP source expression that
contained the first as a <a grammar>`port-part`</a> could potentially match a URL containing the latter's [=url/port=]
and [=url/scheme=]. For example, "80" <a>`port-part` matches</a> matches http://example.com.
An <a>ASCII string</a> or null |input| <dfn export>`port-part` matches</dfn>
[=/URL=] |url| if a CSP source expression that contained the first as a <a
grammar>`port-part`</a> could potentially match a URL containing the latter's
[=url/port=] and [=url/scheme=]. For example, "80" <a>`port-part` matches</a>
matches http://example.com.

<ol class="algorithm">
1. Assert: |input| is the empty string, "*", or a sequence of <a>ASCII digits</a>.
1. Assert: |input| is null, "*", or a sequence of one or more <a>ASCII digits</a>.

2. If |input| is equal to "*", return "`Matches`".

3. Let |normalizedInput| be null if |input| is the empty string; otherwise |input| interpreted as decimal number.
3. Let |normalizedInput| be null if |input| null; otherwise |input|
interpreted as decimal number.

4. If |normalizedInput| equals |url|'s [=url/port=], return "`Matches`".

Expand Down

0 comments on commit 398a20e

Please sign in to comment.