Skip to content

Commit ea230bc

Browse files
arichivannevkantosart
authored
Revise port matching logic (#596)
* Revise port matching logic We need to ensure that: 1. We are consistently using strings 2. We handle cases where the default port isn't set 3. We handle the case where both ports are unset closes #591 * Update index.bs * Update index.bs * Update index.bs * Update index.bs * Update index.bs * Update index.bs * Update index.bs * Update index.bs Co-authored-by: Anne van Kesteren <[email protected]> * Update index.bs Co-authored-by: Anne van Kesteren <[email protected]> * Update index.bs * Update index.bs * Update index.bs * Update index.bs * Update index.bs Co-authored-by: Anne van Kesteren <[email protected]> * Update index.bs Co-authored-by: Anne van Kesteren <[email protected]> --------- Co-authored-by: Anne van Kesteren <[email protected]> Co-authored-by: Antonio Sartori <[email protected]>
1 parent e286b52 commit ea230bc

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

index.bs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3913,8 +3913,7 @@ this algorithm returns normally if compilation is allowed, and throws a
39133913
4. Let |port-part| be |expression|'s <a grammar>`port-part`</a> if present, and null
39143914
otherwise.
39153915

3916-
5. If |port-part| does not <a>`port-part` match</a> |url|'s [=url/port=] and |url|'s
3917-
[=url/scheme=], return "`Does Not Match`".
3916+
5. If |port-part| does not <a>`port-part` match</a> |url|, return "`Does Not Match`".
39183917

39193918
6. If |expression| contains a non-empty <a grammar>`path-part`</a>, and
39203919
|redirect count| is 0, then:
@@ -4026,27 +4025,26 @@ this algorithm returns normally if compilation is allowed, and throws a
40264025
`port-part` matching
40274026
</h5>
40284027

4029-
An <a>ASCII string</a> |port A| <dfn export>`port-part` matches</dfn> two other <a>ASCII
4030-
strings</a> |port B| and |scheme B| if a CSP source expression that contained the first as a
4031-
<a grammar>`port-part`</a> could potentially match a URL containing the latter as [=url/port=]
4032-
and [=url/scheme=]. For example, "80" <a>`port-part` matches</a> matches "80"/"http".
4028+
An <a>ASCII string</a> |input| <dfn export>`port-part` matches</dfn> [=/URL=] |url| if a CSP source expression that
4029+
contained the first as a <a grammar>`port-part`</a> could potentially match a URL containing the latter's [=url/port=]
4030+
and [=url/scheme=]. For example, "80" <a>`port-part` matches</a> matches http://example.com.
40334031

40344032
<ol class="algorithm">
4035-
1. If |port A| is the empty string:
4033+
1. Assert: |input| is the empty string, "*", or a sequence of <a>ASCII digits</a>.
40364034

4037-
1. If |port B| is the <a>default port</a> for |scheme B|, return "`Matches`". Otherwise,
4038-
return "`Does Not Match`".
4035+
2. If |input| is equal to "*", return "`Matches`".
40394036

4040-
2. If |port A| is equal to "*", return "`Matches`".
4037+
3. Let |normalizedInput| be null if |input| is the empty string; otherwise |input| interpreted as decimal number.
4038+
4039+
4. If |normalizedInput| equals |url|'s [=url/port=], return "`Matches`".
40414040

4042-
3. If |port A| is <a for="string" lt="is">identical to</a> |port B|, return "`Matches`".
4041+
5. If |url|'s [=url/port=] is null:
40434042

4044-
4. If |port B| is the empty string:
4043+
1. Let |defaultPort| be the <a>default port</a> for |url|'s [=url/scheme=].
40454044

4046-
1. If |port A| is the <a>default port</a> for |scheme B|, return "`Matches`". Otherwise,
4047-
return "`Does not Match`".
4045+
2. If |normalizedInput| equals |defaultPort|, return "`Matches`".
40484046

4049-
5. Return "`Does Not Match`".
4047+
6. Return "`Does Not Match`".
40504048
</ol>
40514049

40524050
<h5 id="match-paths" algorithm>

0 commit comments

Comments
 (0)