目標
URL 標準は、次のように取り~~組むことにより,~URLを全部的に相互運用可能にすることを目指す: ◎ The URL standard takes the following approach towards making URLs fully interoperable:
- RFC 3986 と RFC 3987 を現今の実装に揃わせて、その過程の中でそれらを過去のものにする。 (例えば、空白類, 他の “合法でない” ~cp, ~queryの符号化法, 同等性, 正準化, などの概念は、どれも~~完全には共有-もしくは定義されていない。) ~URLの構文解析-法は~HTMLの構文解析-法と同程度に確定的になる必要がある。 `RFC3986$r `RFC3987$r ◎ Align RFC 3986 and RFC 3987 with contemporary implementations and obsolete them in the process. (E.g., spaces, other "illegal" code points, query encoding, equality, canonicalization, are all concepts not entirely shared, or defined.) URL parsing needs to become as solid as HTML parsing. [RFC3986] [RFC3987]
- 語~URLを標準~化する。 URI と IRI は混同され易い。 実施においては,どちらに対しても同じ~algoが利用されるので、それらを区別する利点は無い。 ~Webの検索結果 でも~URLの方が優位にある。 ◎ Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone. URL also easily wins the search result popularity contest.
- URI [sic] の生成元 `RFC6454$r に取って代わる。 ◎ Supplanting Origin of a URI [sic]. [RFC6454]
- ~URLの既存の~JS~APIにおける全部的な詳細を定義し、より扱い易くなる様に~~機能を強化する。 また、~HTML要素を通さずに~URLを操作できるようにする( ~JS~worker環境からも有用にする)ため, `URL$I ~objを新たに追加する。 ◎ Define URL’s existing JavaScript API in full detail and add enhancements to make it easier to work with. Add a new URL object as well for URL manipulation without usage of HTML elements. (Useful for JavaScript worker environments.)
- [ 構文解析器, 直列化器, ~API ]の組み合わせにおける冪等性を保証する。 例えば、構文解析してから直列化する演算を重ねて適用しても, 1 回だけ適用した結果(失敗でないとする)と同じになること。 同様に、~APIを通して操作した結果(失敗でないとする)に対し,それを直列化してから構文解析した結果は、何回~適用しようが同じになること。 ◎ Ensure the combination of parser, serializer, and API guarantee idempotence. For example, a non-failure result of a parse-then-serialize operation will not change with any further parse-then-serialize operations applied to it. Similarly, manipulating a non-failure result through the API will not change from applying any number of serialize-then-parse operations to it.
注記: 編集者たちがこの~~主題に関しより多くを学ぶに連れ、目標となる視野は~~拡がるかもしれない。 ◎ As the editors learn more about the subject matter the goals might increase in scope somewhat.
【この訳に固有の表記規約】
この訳の,~algoや定義の記述に利用されている各種記号( ~LET, 此れ, ε, ~INCBY, { … }, ~IF, ~THROW, 等々 )の意味や定義の詳細は、~SYMBOL_DEF_REFを~~参照されたし。
- 記号 ~INCBY, ~DECBY は,~stream/配列~内の位置を指す~pointerの増減操作に特に用いられる。
- 集合の表記( { … } )は、ほとんどが~cpの集合または~byte値の集合に用いられる。
- 入子にされた集合については、和集合をとることを意味する。 例えば,~cpの集合 %S, ~cp %t に対する { %S, %t } は、 %S と { %t } の和集合を意味する。
加えて、次の記法も用いる:
- %s ~APPEND %a ~APPEND %b ~APPEND …
- 左辺の[ 文字列/~byte列 ] %s の末尾に後続の[ 文字列/~byte列 ] %a, %b, … を示された順に付加する演算を表す。 式として用いられた場合、結果の %s が式の値になる。
- `失敗^i (原文では “`failure^i” )
- この仕様にて定義される種々の~algoにおいて,通常~期待されている値を返せないときに返される,~~特別な値(当の処理に失敗したことを意味する)。
1. 基盤
この仕様は Infra Standard `INFRA$r に依存する。 ◎ This specification depends on the Infra Standard. [INFRA]
この仕様に利用される一部の用語は、次の各種 標準/仕様にて定義される:
- DOM Standard `DOM$r
- Encoding Standard `ENCODING$r
- File API `FILEAPI$r
- HTML Standard `HTML$r
- Media Source Extensions `MEDIA-SOURCE$r
- Unicode IDNA Compatibility Processing `UTS46$r
- Web IDL `WEBIDL$r
`整数を直列化する@ ときは、所与の ( 整数 %N ) に対し, %N を 10 進数で表現する最短の文字列を返す。 ◎ To serialize an integer, represent it as the shortest possible decimal number.
1.1. 書式
`検証~error@ とは、入力と妥当な入力との間の不一致を意味する。 ~UA,とりわけ適合性~検査器には、どこかへそれを報告することが奨励される。 ◎ A validation error indicates a mismatch between input and valid input. User agents, especially conformance checkers, are encouraged to report them somewhere.
注記: `検証~error$は、構文解析器を終了させるものではない。 構文解析器の終了は、常に,明示的にそう記される — ~RET 文などにより。 ◎ A validation error does not mean that the parser terminates. Termination of a parser is always stated explicitly, e.g., through a return statement.
`検証~error$を通達するのは有用になる — ~errorの取扱いは直感的でないこともあり、旧来の~UAは 正しい~errorの取扱いを実装しないかもしれず、他の開発者にとっては 何を意図して書出されたか明瞭でないかもしれないので。 ◎ It is useful to signal validation errors as error-handling can be non-intuitive, legacy user agents might not implement correct error-handling, and the intent of what is written might be unclear to other developers.
1.2. 構文解析器
`EOF@i とは、[ 文字列~stream / ~cp~stream ]の終端を表す,仮想の~cpである†。 ◎ The EOF code point is a conceptual code point that signifies the end of a string or code point stream.
【 “End Of File” — この訳では、原文の “EOF ~cp” を単に “EOF” と略記する。 】【† すなわち、自身以外のどの~cpにも等しくない 】
記号 `C@V, `C1@V, `C2@V は、(処理中の文字列~内の文字~位置を指す) %~pointer 変数を利用する構文解析器の中で用いられ,順に[ %~pointer 変数が指している~cp, その次の~cp, 次の次の~cp ]を参照する。 %~pointer 変数が文字列の外を指している場合の `C$V は, `EOF$i になり、 `C1$V, `C2$V についても同様になる。 ◎ Within a parser algorithm that uses a pointer variable, c references the code point the pointer variable points to. ◎ Within a string-based parser algorithm that uses a pointer variable, remaining references the substring after pointer in the string being processed.
例えば、処理中の`文字列$が `http://example.com^l で, %~pointer が `o^l を指しているなら、[ `C$V, `C1$V, `C2$V ]は、順に[ ❝o, ❝m, `EOF$i ]になる。 ◎ If "mailto:username@example" is a string being processed and pointer points to @, c is U+0040 (@) and remaining is "example".
【 `C1$V, `C2$V は、原文の %remaining に代えて,この訳に導入した記号である — %remaining は %~pointer より後の( `C1$V 以降の)部分を成す文字列を表すが、それを利用しているどの箇所も,実際には `C1$V, `C2$V しか利用していないので。 】【 `C$V は,原文では小文字 “c” であるが、日本語の字の大きさとの兼ね合いにより,この訳では大文字で記すことにする。 】
1.3. ~percent-符号化された~byte
【 “~percent-” は、原文の接頭語 “percent-” の(この訳による)略記であり,文字 `%^l に関わることを表す。 】
`~percent-符号化された~byte@ とは、[ ❝%, `~ASCII~hex数字$, `~ASCII~hex数字$ ]の並びが成す文字列である。 `~percent-符号化された~byte$を~byte列に変換した結果に `~BOMも失敗-もそのままに~UTF-8復号する$を適用した結果が `失敗^i になることはない筈である。 ◎ A percent-encoded byte is U+0025 (%), followed by two ASCII hex digits. Sequences of percent-encoded bytes, after conversion to bytes, should not cause UTF-8 decode without BOM or fail to return failure.
`~byteを文字列に~percent-符号化する@ ときは、所与の ( 1 個の~byte %~byte ) に対し,次に与える`~percent-符号化された~byte$を返す ⇒ ❝% ~APPEND [ %~byte を表現する 2 個の`~ASCII~hex数字(大文字)$ ] ◎ To percent encode a byte into a percent-encoded byte, return a string consisting of U+0025 (%), followed by two ASCII upper hex digits representing byte.
`~byte列を~byte列に~percent-復号する@ ときは、所与の ( `~byte列$ %入力 ) に対し,次を走らす: ◎ To percent decode a byte sequence input, run these steps:
警告: [[ `~ASCII~byte$の以外の~byte ]が含まれ得るような %入力 ]に対する `~BOMはそのままに~UTF-8復号する$以外の利用は,保安的でないこともあるので、推奨されない。 ◎ Using anything but UTF-8 decode without BOM when the input contains bytes that are not ASCII bytes might be insecure and is not recommended.
- %出力 ~LET 空`~byte列$ ◎ Let output be an empty byte sequence.
- %L ~LET %入力 の`長さ$byte ◎ ↓
- %N ~LET 1 ◎ ↓
-
~WHILE[ %N ~LTE %L ]:
- %~byte ~LET %入力 の %N 個目の~byte
- %N ~INCBY 1
-
~IF[ %~byte ~EQ ❛% ]~AND[ %N ~PLUS 1 ~LTE %L ]:
- %~byte列 ~LET %入力 の[ %N 個目, %N ~PLUS 1 個目 ]の~byteが成す~byte列
-
~IF[ %~byte列 を成すどの~byte %b も[ %b ~IN { ❛0 〜 ❛9, ❛A 〜 ❛F, ❛a 〜 ❛f } ]を満たす ]:
- %~hex文字列 ~LET `~BOMはそのままに~UTF-8復号する$( %~byte列 )
- %~byte ~SET [ %~hex文字列 を~hexadecimal数として解釈した結果の数 ]を値とする~byte
- %N ~INCBY 2
- %出力 ~APPEND %~byte
- ~RET %出力 ◎ Return output.
`文字列を~byte列に~percent-復号する@ ときは、所与の ( 文字列 %入力 ) に対し,次の結果を返す ⇒ `~byte列を~byte列に~percent-復号する$( `~UTF-8符号化する$( %入力 ) ) ◎ To string percent decode a string input, run these steps: • Let bytes be the UTF-8 encoding of input. • Return the percent decoding of bytes.
【 次に挙げる各種 ~cpの集合は、`~UTF-8~percent-符号化する$ときに利用される: 】
- `~C0制御文字~percent-符号化-集合@ は、次に挙げる~cpの集合である ⇒# `~C0制御文字$, `007F^U DELETE 〜 `10FFFF^U ◎ The C0 control percent-encode set are the C0 controls and all code points greater than U+007E (~).
- `素片~percent-符号化-集合@ は、次に挙げる~cpの集合である ⇒# `~C0制御文字~percent-符号化-集合$, `0020^U, ❝", `003C^U `<^smb, `003E^U `>^smb, ❝` ◎ The fragment percent-encode set is the C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+003C (<), U+003E (>), and U+0060 (`).
- `~path~percent-符号化-集合@ は、次に挙げる~cpの集合である ⇒# `素片~percent-符号化-集合$, ❝#, ❝?, ❝}, ❝{ ◎ The path percent-encode set is the fragment percent-encode set and U+0023 (#), U+003F (?), U+007B ({), and U+007D (}).
- `~userinfo~percent-符号化-集合@ は、次に挙げる~cpの集合である ⇒# `~path~percent-符号化-集合$, ❝/, ❝:, ❝;, ❝=, ❝@, ❝[, ❝\, ❝], ❝^, ❝| ◎ The userinfo percent-encode set is the path percent-encode set and U+002F (/), U+003A (:), U+003B (;), U+003D (=), U+0040 (@), U+005B ([), U+005C (\), U+005D (]), U+005E (^), and U+007C (|).
`~UTF-8~percent-符号化する@ ときは、所与の ( ~cpの集合 %~percent-符号化-集合, 1 個の~cp %~cp ) に対し,次を走らす: ◎ To UTF-8 percent encode a codePoint, using a percentEncodeSet, run these steps:
- ~IF[ %~cp ~NIN %~percent-符号化-集合 ] ⇒ ~RET %~cp ◎ If codePoint is not in percentEncodeSet, then return codePoint.
- %~byte列 ~LET `~UTF-8符号化する$( %~cp ) ◎ Let bytes be the result of running UTF-8 encode on codePoint.
- %結果 ~LET 空~文字列 ◎ ↓
- %~byte列 内の ~EACH( %~byte ) に対し ⇒ %結果 ~APPEND `~byteを文字列に~percent-符号化する$( %~byte ) ◎ Percent encode each byte in bytes, and then\
- ~RET %結果 ◎ return the results concatenated, in the same order.
2. 保安~上の考慮点
`~URL$の保安は、その環境の役務である。 `~URL$を,周りに向けて描画する/渡す, あるいは 周りのそれを解釈するときには、注意すること。 ◎ The security of a URL is a function of its environment. Care is to be taken when rendering, interpreting, and passing URLs around.
新たな`~URL$を描画したり,あてがうときは、 “なりすまし( `spoofing^en )” について考慮する必要がある。 `~host$/`~URL$ による攻撃は、誰かを誤認させる可能性がある。 具体例として、 1/l/I, m/rn/rri, 0/O, а/a は,どれも酷似するものになり得る†。 `202A^U LEFT-TO-RIGHT EMBEDDING 等々のような,より~~問題になる不可視の††~cpすらある。 `UTR36$r ◎ When rendering and allocating new URLs "spoofing" needs to be considered. An attack whereby one host or URL can be confused for another. For instance, consider how 1/l/I, m/rn/rri, 0/O, and а/a can all appear eerily similar. Or worse, consider how U+202A LEFT-TO-RIGHT EMBEDDING and similar code points are invisible. [UTR36]
【 “描画( `rendering^en )” の原義には、音声化なども含まれる — その場合、発音が似るものに対し,同様のことが該当することになる。 】【† 一般的には見かけがかなり異なる文字でも、例えば,その場の環境にて可用な~fontに依存して酷似するかもしれない。 】【 非 英語話者にとっては、綴りや字形が異なっていても発音が似るがため,錯覚し易いものもあるかもしれない — 例えば “correction” と “collection” 。 】【†† 空間すら占めない。 】【 参考: IDN FAQ 】
主体 %A から主体 %B へ`~URL$が渡されるときは、いずれの側も,何が起きるか注意深く考慮する必要がある。 %A は、意に反して~dataを漏洩するはめになり得る。 %B は、自身が予期していない入力を受取って利用者に害する動作をとる可能性がある。 特に、 %B は,決して %A を信用するべきでない — 渡される`~URL$は,常に信用できる源に~~由来するとは限らないので。 ◎ When passing a URL from party A to B, both need to carefully consider what is happening. A might end up leaking data it does not want to leak. B might receive input it did not expect and take an action that harms the user. In particular, B should never trust A, as at some point URLs from A can come from untrusted sources.
3. ~host(~domainと~IP~address)
高次の~levelからは、[ `~host$, `妥当な~host$sT, `~host構文解析器$, `~host直列化器$ ]は,次のように関係する: ◎ At a high level, a host, valid host string, host parser, and host serializer relate as follows:
- `~host構文解析器$は、任意の~~入力~文字列に対し[ `失敗^i, または `~host$ ]を返す。 ◎ The host parser takes an arbitrary string and returns either failure or a host.
- `~host$は、記憶域内の表現と捉えることもできる。 ◎ A host can be seen as the in-memory representation.
- `妥当な~host$sTは、`~host構文解析器$に与えたときに,`検証~error$や `失敗^i を誘発しない — すなわち、[ 適合する/妥当である ]と見なされる — ような入力を定義する。 ◎ A valid host string defines what input would not trigger a validation error or failure when given to the host parser. I.e., input that would be considered conforming or valid.
- `~host直列化器$は、~~入力の`~host$に対し,文字列を返す。 (その文字列をさらに`~host構文解析器$にかけた結果は、元の`~host$と`同等$hostになる。) ◎ The host serializer takes a host and returns a string. (If that string is then parsed, the result will equal the host that was serialized.)
3.1. ~host表現
`~host@ は、[ `~domain$, `~IPv4~address$, `~IPv6~address$, `不透明な~host$, `空~host$ ]のいずれかである。 `~host$は,概して~network~addressとして~~機能するが、~network~addressが必要とされない所では,`~URL$内で 不透明な識別子として利用されることもある。 ◎ A host is a domain, an IPv4 address, an IPv6 address, an opaque host, or an empty host. Typically a host serves as a network address, but it is sometimes used as opaque identifier in URLs where a network address is not necessary.
注記: 下の各 段落~内で参照されている RFC は、参考目的に限られる。 それらは、`~host$の書式, 構文解析-法, 直列化には何ら波及しない。 以下の節にて他が言明されない限り。 ◎ The RFCs referenced in the paragraphs below are for informative purposes only. They have no influence on host writing, parsing, and serialization. Unless stated otherwise in the sections that follow.
`~domain@ とは、~networkの中の~realmを識別するものである。 `RFC1034$r ◎ A domain identifies a realm within a network. [RFC1034]
2 つの~domain `example.com^l と `example.com.^l は、等価ではなく,概して別物に扱われる。 ◎ The example.com and example.com. domains are not equivalent and typically treated as distinct.
`~IPv4~address@ は、~network~addressを識別する 32-bit 無符号~整数である。 `RFC791$r ◎ An IPv4 address is a 32-bit unsigned integer that identifies a network address. [RFC791]
`~IPv6~address@ は,~network~addressを識別する 128-bit 無符号~整数であり、この標準~の目的においては, 8 個の[ `~IPv6~piece@ と称される, 16-bit 無符号~整数 ]からなる`~list$として表現される。 `RFC4291$r ◎ An IPv6 address is a 128-bit unsigned integer that identifies a network address. For the purposes of this standard it is represented as a list of eight 16-bit unsigned integers, also known as IPv6 pieces. [RFC4291]
注記:
<zone_id>
の~supportは、
意図的に除かれている。
◎
Support for <zone_id> is intentionally omitted.
`不透明な~host@ は、[ 更なる処理に利用され得る~data ]を保持する,空でない`~ASCII文字列$である ◎ An opaque host is a non-empty ASCII string holding data that can be used for further processing.
`空~host@ は、空~文字列である。 ◎ An empty host is the empty string.
3.2. ~hostのその他諸々
次に挙げる~cpは `禁止~host~cp@ とされる ⇒# `0000^U NULL, `0009^U TAB, `000A^U LF, `000D^U CR, `0020^U SPACE, ❝#, ❝%, ❝/, ❝:, ❝?, ❝@, ❝[, ❝\, ❝] ◎ A forbidden host code point is U+0000 NULL, U+0009 TAB, U+000A LF, U+000D CR, U+0020 SPACE, U+0023 (#), U+0025 (%), U+002F (/), U+003A (:), U+003F (?), U+0040 (@), U+005B ([), U+005C (\), or U+005D (]).
`~host$の `公共接尾辞@ ( `public suffix^en )は、`~host$内の,~PublicSuffixList `PSL$r に含まれる部位である。 所与の %~host の`公共接尾辞$を得るときは、次を走らす: ◎ A host’s public suffix is the portion of a host which is included on the Public Suffix List. To obtain host’s public suffix, run these steps: [PSL]
- ~IF[ %~host は`~domain$でない ] ⇒ ~RET ~NULL ◎ If host is not a domain, then return null.
- ~RET [ `~PublicSuffixListにより定義される~algo$ `PSL$r ]を, %~host に対し実行して得られる`公共接尾辞$ ◎ Return the public suffix obtained by executing the algorithm defined by the Public Suffix List on host. [PSL].
`~host$の `登録-可能な~domain@ ( `registrable domain^en )は、最も特定的な公共接尾辞により — および,その直前に~domain~labelがあれば それも込みで — 形成される`~domain$である。 所与の %~host の`登録-可能な~domain$を得るときは、次を走らす: ◎ A host’s registrable domain is a domain formed by the most specific public suffix, along with the domain label immediately preceeding it, if any. To obtain host’s registrable domain, run these steps:
- ~IF[ %~host の`公共接尾辞$ ~EQ ~NULL ]~OR[ ( %~host の`公共接尾辞$, %~host ) は`同等$hostである ] ⇒ ~RET ~NULL ◎ If host’s public suffix is null or host’s public suffix equals host, then return null.
- ~RET [ `~PublicSuffixListにより定義される~algo$ `PSL$r ]を, %~host に対し実行して得られる`登録-可能な~domain$ ◎ Return the registrable domain obtained by executing the algorithm defined by the Public Suffix List on host. [PSL]
入力~host ◎ Host input | 公共接尾辞 ◎ Public suffix | 登録-可能な~domain ◎ Registrable domain |
---|---|---|
`com^c | `com^c | null |
`example.com^c | `com^c | `example.com^c |
`www.example.com^c | `com^c | `example.com^c |
`sub.www.example.com^c | `com^c | `example.com^c |
`EXAMPLE.COM^c | `com^c | `example.com^c |
`github.io^c | `github.io^c | null |
`whatwg.github.io^c | `github.io^c | `whatwg.github.io^c |
`إختبار^c | `xn-kgbechtv^c | null |
`example.إختبار^c | `xn-kgbechtv^c | `example.xn-kgbechtv^c |
`sub.example.إختبار^c | `xn-kgbechtv^c | `example.xn-kgbechtv^c |
2 つの`~host$ ( %A, %B ) は、次の言明のいずれかを満たすならば、互いに `同じ~site@ とされる: ◎ Two hosts, A and B are said to be same site with each other if either of the following statements are true:
- [ ( %A, %B ) は`同等$hostである ]~AND[ %A の`登録-可能な~domain$ ~NEQ ~NULL ] ◎ A equals B and A’s registrable domain is non-null.
- %A の`登録-可能な~domain$ ~EQ %B の`登録-可能な~domain$ ~NEQ ~NULL ◎ A’s registrable domain is B’s registrable domain and is non-null.
`suffix.example^c は`公共接尾辞$で, `example.com^c はそうでないと見做すならば: ◎ Assuming that suffix.example is a public suffix and that example.com is not:
- 次に挙げるものは、どれも,互いに(および, それぞれ自身とも)`同じ~site$になる ⇒# `example.com^c, `sub.example.com^c, `other.example.com^c, `sub.sub.example.com^c, `sub.other.example.com^c ◎終 — どれも,`登録-可能な~domain$は `example.com^c になるので。 ◎ example.com, sub.example.com, other.example.com, sub.sub.example.com, and sub.other.example.com are all same site with each other (and themselves), as their registrable domains are example.com.
- 次に挙げるものは、どれも,互いに(および, それぞれ自身とも)`同じ~site$になる ⇒# `registrable.suffix.example^c, `sub.registrable.suffix.example^c, `other.registrable.suffix.example^c, `sub.sub.registrable.suffix.example^c, `sub.other.registrable.suffix.example^c ◎終 — どれも,`登録-可能な~domain$は `registrable.suffix.example^c になるので。 ◎ registrable.suffix.example, sub.registrable.suffix.example, other.registrable.suffix.example, sub.sub.registrable.suffix.example, and sub.other.registrable.suffix.example are all same site with each other (and themselves), as their registrable domains are registrable.suffix.example.
- 次に挙げる 2 つは、互いに`同じ~site$でない ⇒# `example.com^c, `registrable.suffix.example^c ◎終 — `登録-可能な~domain$が相違するので ◎ example.com and registrable.suffix.example are not same site with each other, as their registrable domains differ.
- `suffix.example^c は、自身と`同じ~site$でない — それは`公共接尾辞$であり,`登録-可能な~domain$は ~NULL になるので。 ◎ suffix.example is not same site with suffix.example, as it is a public suffix, and therefore has a null registrable domain.
仕様は、[ “`公共接尾辞$” / “`登録-可能な~domain$” / “`同じ~site$” ]に依存するのを避けるべきである。 公共接尾辞~listは,~clientごとに分岐するので、それに依拠して,堅固な保安~境界を供することはできない。 この助言を無視する仕様は、[[ 2 つの`~host$は`同じ~site$かどうか ]に基づいて下される裁定の中に,~URLの~schemeは組入れるべきとされるか ]について,注意深く考慮することが奨励される。 ~HTMLの`同じ生成元~domain$の概念は、実施において これが考慮された適度な例である。 ◎ Specifications should avoid depending on "public suffix", "registrable domain", and "same site". The public suffix list will diverge from client to client, and cannot be relied-upon to provide a hard security boundary. Specifications which ignore this advice are encouraged to carefully consider whether URLs' schemes ought to be incorporated into any decision made based upon whether or not two hosts are same site. HTML’s same origin-domain concept is a reasonable example of this consideration in practice.
3.3. IDNA
`~domainを~ASCII化する@ ときは、所与の (`~domain$ %~domain, 真偽値 %beStrict (省略時は ~F)) に対し,次を走らす: ◎ The domain to ASCII algorithm, given a domain domain and optionally a boolean beStrict, runs these steps: ◎ If beStrict is not given, set it to false.
- %結果 ~LET 次を与える下で, `Unicode ToASCII$AO を走らせた結果 ⇒# `domain_name^i ~SET %~domain, `UseSTD3ASCIIRules^i ~SET %beStrict, `CheckHyphens^i ~SET ~F, `CheckBidi^i ~SET ~T, `CheckJoiners^i ~SET ~T, `Transitional_Processing^i ~SET ~F, `VerifyDnsLength^i ~SET %beStrict ◎ Let result be the result of running Unicode ToASCII with domain_name set to domain, UseSTD3ASCIIRules set to beStrict, CheckHyphens set to false, CheckBidi set to true, CheckJoiners set to true, Transitional_Processing set to false, and VerifyDnsLength set to beStrict.
- ~IF[ %結果 ~EQ `失敗^i ] ⇒# `検証~error$; ~RET `失敗^i ◎ If result is a failure value, validation error, return failure.
- ~RET %結果 ◎ Return result.
`~domainを~Unicode化する@ ときは、所与の`~domain$ %~domain に対し,次を走らす: ◎ The domain to Unicode algorithm, given a domain domain, runs these steps:
- %結果 ~LET 次を与える下で, `Unicode ToUnicode$AO を走らせた結果 ⇒# `domain_name^i ~SET %~domain, `CheckHyphens^i ~SET ~F, `CheckBidi^i ~SET ~T, `CheckJoiners^i ~SET ~T, `UseSTD3ASCIIRules^i ~SET ~F, `Transitional_Processing^i ~SET ~F ◎ Let result be the result of running Unicode ToUnicode with domain_name set to domain, CheckHyphens set to false, CheckBidi set to true, CheckJoiners set to true, UseSTD3ASCIIRules set to false, and Transitional_Processing set to false.
- ~IF[ %結果 に何らかの~errorがある ] ⇒ `検証~error$ ◎ Signify validation errors for any returned errors, and then\
- ~RET %結果 ◎ return result.
3.4. ~hostの書式
`妥当な~host@sT は、次のいずれかで~MUST:
- `妥当な~domain$sT
- `妥当な~IPv4~address$sT
-
次の並び:
- ❝[
- `妥当な~IPv6~address$sT
- ❝]
次の手続きが `成功^i を返すような %~domain は、 `妥当な~domain@ であるとされる: ◎ A domain is a valid domain if these steps return success:
- %結果 ~LET `~domainを~ASCII化する$( %~domain, ~T ) ◎ Let result be the result of running domain to ASCII with domain and true.
- ~IF[ %結果 ~EQ `失敗^i ] ⇒ ~RET `失敗^i ◎ If result is failure, then return failure.
- %結果 ~SET 次を与える下で, `Unicode ToUnicode$AO を走らせた結果 ⇒# `domain_name^i ~SET %結果, `CheckHyphens^i ~SET ~F, `CheckBidi^i ~SET ~T, `CheckJoiners^i ~SET ~T, `UseSTD3ASCIIRules^i ~SET ~T, `Transitional_Processing^i ~SET ~F ◎ Set result to the result of running Unicode ToUnicode with domain_name set to result, CheckHyphens set to false, CheckBidi set to true, CheckJoiners set to true, UseSTD3ASCIIRules set to true, and Transitional_Processing set to false.
- ~IF[ %結果 に何らかの~errorがある ] ⇒ ~RET `失敗^i ◎ If result contains any errors, return failure.
- ~RET `成功^i ◎ Return success.
課題: 理想的には、`妥当な~domain$を成す~cpの並びを通して定義したい所 — モグラ叩きのように定義するのではなく: bug 25334 ◎ Ideally we define this in terms of a sequence of code points that make up a valid domain rather than through a whack-a-mole: bug 25334.
`妥当な~domain@sT は、`妥当な~domain$を与える文字列で~MUST。 ◎ A valid domain string must be a string that is a valid domain.
`妥当な~IPv4~address@sT は、 4 個の[ 0 〜 255 の 10 進数を表現する[ 3 個までの`~ASCII数字$からなる並び ]]を, ❝. で区切った並びで~MUST。 ◎ A valid IPv4-address string must be four sequences of up to three ASCII digits per sequence, each representing a decimal number no greater than 255, and separated from each other by U+002E (.).
`妥当な~IPv6~address@sT は、 IP Version 6 Addressing Architecture の Text Representation of Addresses ( “~addressの~text表現” )章にて定義される。 `RFC4291$r ◎ A valid IPv6-address string is defined in the "Text Representation of Addresses" chapter of IP Version 6 Addressing Architecture. [RFC4291]
`妥当な不透明な~host@sT は、次のいずれかで~MUST: ◎ A valid opaque-host string must be\
- 1 個以上の`~URL単位$からなる並び ◎ one or more URL units or:\
-
次の並び:
- ❝[
- `妥当な~IPv6~address$sT
- ❝]
注記: これは、`妥当な~host$sTの定義の一部ではない — それには、文脈を判別することが要求されるので。 ◎ This is not part of the definition of valid host string as it requires context to be distinguished.
3.5. ~hostの構文解析-法
`~host構文解析器@ は、所与の ( 文字列 %入力, 真偽値 %特別でない (省略時は ~F ) ) に対し,次を走らす: ◎ The host parser takes a string input with an optional boolean isNotSpecial, and then runs these steps: • If isNotSpecial is not given, then set isNotSpecial to false.
-
~IF[ %入力 の先頭 ~EQ ❝[ ]: ◎ If input starts with U+005B ([), then:
- ~IF[ %入力 の末尾 ~NEQ ❝] ] ⇒# `検証~error$; ~RET `失敗^i ◎ If input does not end with U+005D (]), validation error, return failure.
- ~RET `~IPv6構文解析器$( %入力 から先頭の ❝[ と末尾の ❝] を除去した結果 ) ◎ Return the result of IPv6 parsing input with its leading U+005B ([) and trailing U+005D (]) removed.
- ~IF[ %特別でない ~EQ ~T ] ⇒ ~RET `不透明な~host構文解析器$( %入力 ) ◎ If isNotSpecial is true, then return the result of opaque-host parsing input.
-
%~domain ~LET `~BOMはそのままに~UTF-8復号する$( `文字列を~byte列に~percent-復号する$( %入力 ) ) ◎ Let domain be the result of running UTF-8 decode without BOM on the string percent decoding of input.
注記: 別法として、`~BOMも失敗-もそのままに~UTF-8復号する$を利用した上で, `失敗^i 時には早々に ~RET することもできる — `~domainを~ASCII化する$のは `FFFD^U REPLACEMENT CHARACTER に対し失敗するので。 ◎ Alternatively UTF-8 decode without BOM or fail can be used, coupled with an early return for failure, as domain to ASCII fails on U+FFFD REPLACEMENT CHARACTER.
- %~ASCII~domain ~LET `~domainを~ASCII化する$( %~domain ) ◎ Let asciiDomain be the result of running domain to ASCII on domain.
- ~IF[ %~ASCII~domain ~EQ `失敗^i ] ⇒# `検証~error$; ~RET `失敗^i ◎ If asciiDomain is failure, validation error, return failure.
- ~IF[ %~ASCII~domain 内に`禁止~host~cp$がある ] ⇒# `検証~error$; ~RET `失敗^i ◎ If asciiDomain contains a forbidden host code point, validation error, return failure.
- %ipv4~host ~LET `~IPv4構文解析器$( %~ASCII~domain ) ◎ Let ipv4Host be the result of IPv4 parsing asciiDomain.
- ~IF[ %ipv4~host ~EQ `失敗^i ] ⇒ ~RET `失敗^i ◎ ↓
- ~IF[ %ipv4~host は`~IPv4~address$である ] ⇒ ~RET %ipv4~host ◎ If ipv4Host is an IPv4 address or failure, return ipv4Host.
- ~RET %~ASCII~domain ◎ Return asciiDomain.
`~IPv4番号~構文解析器@ は、所与の ( 文字列 %入力 ) に対し,次を走らす: ◎ The IPv4 number parser takes a string input and a validationErrorFlag pointer, and then runs these steps:
-
%検証~error ~LET `無し^i
【 和訳固有の既存の記号で表記する都合により、特にこの変数(原文 %validationErrorFlag )に関して,この~algoには入出力の表記法に手を加えている。 】
- %R ~LET 10 ◎ Let R be 10.
-
~IF[ %入力 の長さ ~GTE 2 ]~AND[ %入力 の先頭の~cp ~EQ ❝0 ]:
- %検証~error ~SET `有り^i
- %入力 から先頭の~cpを除去する
- %R ~SET 8
-
~IF[ %入力 の先頭の~cp ~IN { ❝x, ❝X } ]:
- %入力 から先頭の~cpを除去する
- %R ~SET 16
-
~IF[ %入力 ~EQ 空~文字列 ] ⇒ ~RET ( 0, %検証~error )
【 `0x^l / `0X^l が入力されたときも,ここに該当することになる。 】
◎ If input is the empty string, then return zero. - ~IF[ %入力 内に基数 %R の数字でない~cpがある ] ⇒ ~RET ( `失敗^i, `有り^i ) ◎ If input contains a code point that is not a radix-R digit, then return failure.
- %結果 ~LET %入力 を(`~ASCII~hex数字$が値 0 〜 15 の数字に対応付けられた)基数 %R による表記と見なした下で,整数 値として解釈した結果 ◎ Return the mathematical integer value that is represented by input in radix-R notation, using ASCII hex digits for digits with values 0 through 15.
- ~RET ( %結果, %検証~error )
【 `0xAB.012.0X12.12^l の様な~host名も IPv4 ~addressと見なされ、 `0xAB^l, `0X12^l は 16 進数, `012^l は 8 進数, `12^l は 10 進数 として解釈されることになる。 】
`~IPv4構文解析器@ は、所与の ( 文字列 %入力 ) に対し,次を走らす: ◎ The IPv4 parser takes a string input and then runs these steps:
- %検証~error~flag ~LET ~OFF ◎ Let validationErrorFlag be unset.
- %~~成分~list ~LET %入力 を ❝. で分割した結果 ◎ Let parts be input split on U+002E (.).
-
~IF[ %~~成分~list 内の最後の~item ~EQ 空~文字列 ]: ◎ If the last item in parts is the empty string, then:
- %検証~error~flag ~SET ~ON ◎ Set validationErrorFlag.
-
~IF[ %~~成分~list の~item数 ~GT 1 ] ⇒ %~~成分~list から最後の~itemを除去する
【 %入力 の末尾に余計な ❝. があっても受容されることになる。 】
◎ If parts has more than one item, then remove the last item from parts.
- ~IF[ %~~成分~list の~item数 ~GT 4 ] ⇒ ~RET %入力 【結果は`~IPv4~address$ではない。】 ◎ If parts has more than four items, return input.
- %数~list ~LET 空~list ◎ Let numbers be the empty list.
-
%~~成分~list 内の ~EACH( %~~成分 ) に対し: ◎ For each part in parts:
-
~IF[ %~~成分 ~EQ 空~文字列 ] ⇒ ~RET %入力 ◎ If part is the empty string, return input.
`0..0x300^l は`~domain$であって,`~IPv4~address$ではない。 ◎ 0..0x300 is a domain, not an IPv4 address.
- ( %n, %検証~error ) ~LET `~IPv4番号~構文解析器$( %~~成分 ) ◎ Let n be the result of parsing part using validationErrorFlag.
- ~IF[ %n ~EQ `失敗^i ] ⇒ ~RET %入力 ◎ If n is failure, return input.
- %数~list に %n を付加する ◎ Append n to numbers.
- ~IF[ %検証~error ~EQ `有り^i ] ⇒ %検証~error~flag ~SET ~ON ◎ ↑↑↑
-
- ~IF[ %検証~error~flag ~EQ ~ON ] ⇒ `検証~error$ ◎ If validationErrorFlag is set, validation error.
- ~IF[ %数~list 内の ある~item ~GT 255 ] ⇒ `検証~error$ ◎ If any item in numbers is greater than 255, validation error.
- ~IF[ %数~list 内の最後でない ある~item ~GT 255 ] ⇒ ~RET `失敗^i ◎ If any but the last item in numbers is greater than 255, return failure.
- ~IF[ %数~list の最後の~item† ~GTE ( 256 の ( 5 − ( %数~list の~item数 ) ) 乗 ) ] ⇒# `検証~error$; ~RET `失敗^i ◎ If the last item in numbers is greater than or equal to 256(5 − the number of items in numbers), validation error, return failure.
- %ipv4 ~LET %数~list の最後の~item ◎ Let ipv4 be the last item in numbers.
- %数~list から最後の~itemを除去する†† ◎ Remove the last item from numbers.
- %counter ~LET 0 ◎ Let counter be zero.
-
%数~list 内の ~EACH( %n ) に対し: ◎ For each n in numbers:
- %ipv4 ~INCBY ( %n × ( 256 の (3 − %counter) 乗 ) ) ◎ Increment ipv4 by n × 256(3 − counter).
- %counter ~INCBY 1 ◎ Increment counter by 1.
- ~RET %ipv4 ◎ Return ipv4.
【† 最後の~itemだけ特別扱い: 例えば `100.100.25600^l と `100.100.100.0^l は等価になり, `0xFFFFFFFF^l と `255.255.255.255^l は等価になることになる。 】【†† ここでも、( %数~list の項~数が 4 に満たない場合は)最後の~itemだけ特別扱い: 例えば `100.100^l は, `100.0.0.100^l と等価になる。 】
`~IPv6構文解析器@ は、所与の ( 文字列 %入力 ) に対し,次を走らす: ◎ The IPv6 parser takes a string input and then runs these steps:
- %~address ~LET `~IPv6~piece$がすべて 0 にされた,新たな`~IPv6~address$ ◎ Let address be a new IPv6 address whose IPv6 pieces are all 0.
- %~piece~index ~LET 0 ◎ Let pieceIndex be 0.
- %圧縮- ~LET ~NULL ◎ Let compress be null.
- %~pointer ~LET 0 ( %入力 内を指す~pointer, 初期~時は最初の~cpを指す) ◎ Let pointer be a pointer into input, initially 0 (pointing to the first code point).
-
~IF[ `C$V ~EQ ❝: ]: ◎ If c is U+003A (:), then:
- ~IF[ `C1$V ~NEQ ❝: ] ⇒# `検証~error$; ~RET `失敗^i ◎ If remaining does not start with U+003A (:), validation error, return failure.
- %~pointer ~INCBY 2 ◎ Increase pointer by 2.
- %~piece~index ~INCBY 1; %圧縮- ~SET %~piece~index ◎ Increase pieceIndex by 1 and then set compress to pieceIndex.
-
~WHILE [ `C$V ~NEQ `EOF$i ]: ◎ While c is not the EOF code point:
- ~IF[ %~piece~index ~EQ 8 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If pieceIndex is 8, validation error, return failure.
-
~IF[ `C$V ~EQ ❝: ]: ◎ If c is U+003A (:), then:
- ~IF[ %圧縮- ~NEQ ~NULL ] ⇒# `検証~error$; ~RET `失敗^i ◎ If compress is non-null, validation error, return failure.
- %~pointer ~INCBY 1 ◎ ↓
- %~piece~index ~INCBY 1 ◎ Increase pointer and pieceIndex by 1,\
- %圧縮- ~SET %~piece~index ◎ set compress to pieceIndex,\
- ~CONTINUE ◎ and then continue.
- ( %値, %長さ ) ~LET ( 0, 0 ) ◎ Let value and length be 0.
- ~WHILE [ %長さ ~LT 4 ]~AND[ `C$V ~IN `~ASCII~hex数字$ ] ⇒# %値 ~SET %値 ~MUL `10^X ~PLUS [ `C$V を~hexadecimal数として解釈した値 ]; %~pointer ~INCBY 1; %長さ ~INCBY 1 ◎ While length is less than 4 and c is an ASCII hex digit, set value to value × 0x10 + c interpreted as hexadecimal number, and increase pointer and length by 1.
-
~IF[ `C$V ~EQ ❝. ]: ◎ If c is U+002E (.), then:
- ~IF[ %長さ ~EQ 0 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If length is 0, validation error, return failure.
- %~pointer ~DECBY %長さ ◎ Decrease pointer by length.
- ~IF[ %~piece~index ~GT 6 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If pieceIndex is greater than 6, validation error, return failure.
- %ipv4個数 ~LET 0 ◎ Let numbersSeen be 0.
-
~WHILE [ `C$V ~NEQ `EOF$i ]: ◎ While c is not the EOF code point:
- %ipv4片 ~LET ~NULL ◎ Let ipv4Piece be null.
-
~IF[ %ipv4個数 ~GT 0 ]: ◎ If numbersSeen is greater than 0, then:
- ~IF[ `C$V ~EQ ❝. ]~AND[ %ipv4個数 ~LT 4 ] ⇒ %~pointer ~INCBY 1 ◎ If c is a U+002E (.) and numbersSeen is less than 4, then increase pointer by 1.
- ~ELSE ⇒# `検証~error$; ~RET `失敗^i ◎ Otherwise, validation error, return failure.
- ~IF[ `C$V ~NIN `~ASCII数字$ ] ⇒# `検証~error$; ~RET `失敗^i ◎ If c is not an ASCII digit, validation error, return failure.
-
~WHILE [ `C$V ~IN `~ASCII数字$ ]: ◎ While c is an ASCII digit:
- ~IF[ %ipv4片 ~EQ 0 ] ⇒# `検証~error$; ~RET `失敗^i ◎ Let number be c interpreted as decimal number. ◎ If ipv4Piece is null, then set ipv4Piece to number. ◎ Otherwise, if ipv4Piece is 0, validation error, return failure.
- ~IF[ %ipv4片 ~EQ ~NULL ] ⇒ %ipv4片 ~SET 0 ◎ ↑
- %ipv4片 ~SET %ipv4片 ~MUL 10 + [ `C$V を 10 進数として解釈した値 ] ◎ Otherwise, set ipv4Piece to ipv4Piece × 10 + number.
- ~IF[ %ipv4片 ~GT 255 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If ipv4Piece is greater than 255, validation error, return failure.
- %~pointer ~INCBY 1 ◎ Increase pointer by 1.
- %~address[ %~piece~index ] ~SET %~address[ %~piece~index ] ~MUL `100^X ~PLUS %ipv4片 ◎ Set address[pieceIndex] to address[pieceIndex] × 0x100 + ipv4Piece.
- %ipv4個数 ~INCBY 1 ◎ Increase numbersSeen by 1.
- ~IF[ %ipv4個数 ~IN { 2, 4 } ] ⇒ %~piece~index ~INCBY 1 ◎ If numbersSeen is 2 or 4, then increase pieceIndex by 1.
- ~IF[ %ipv4個数 ~NEQ 4 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If numbersSeen is not 4, validation error, return failure.
- ~BREAK ◎ Break.
-
~ELIF[ `C$V ~EQ ❝: ]: ◎ Otherwise, if c is U+003A (:):
- %~pointer ~INCBY 1 ◎ Increase pointer by 1.
- ~IF[ `C$V ~EQ `EOF$i ] ⇒# `検証~error$; ~RET `失敗^i ◎ If c is the EOF code point, validation error, return failure.
- ~ELIF[ `C$V ~NEQ `EOF$i ] ⇒# `検証~error$; ~RET `失敗^i ◎ Otherwise, if c is not the EOF code point, validation error, return failure.
- %~address[ %~piece~index ] ~SET %値 ◎ Set address[pieceIndex] to value.
- %~piece~index ~INCBY 1 ◎ Increase pieceIndex by 1.
-
~IF[ %圧縮- ~NEQ ~NULL ]: ◎ If compress is non-null, then:
- %swaps ~LET %~piece~index ~MINUS %圧縮- ◎ Let swaps be pieceIndex − compress.
- %~piece~index ~SET 7 ◎ Set pieceIndex to 7.
- ~WHILE [ %~piece~index ~NEQ 0 ]~AND[ %swaps ~GT 0 ] ⇒# %~address[ %~piece~index ] と %~address[ %圧縮- ~PLUS %swaps ~MINUS 1 ] の値を交換する; %~piece~index ~DECBY 1; %swaps ~DECBY 1 ◎ While pieceIndex is not 0 and swaps is greater than 0, swap address[pieceIndex] with address[compress + swaps − 1], and then decrease both pieceIndex and swaps by 1.
- ~ELIF[ %圧縮- ~EQ ~NULL ]~AND[ %~piece~index ~NEQ 8 ] ⇒# `検証~error$; ~RET `失敗^i ◎ Otherwise, if compress is null and pieceIndex is not 8, validation error, return failure.
- ~RET %~address ◎ Return address.
`不透明な~host構文解析器@ は、所与の ( %入力 ) に対し,次を走らす: ◎ The opaque-host parser takes a string input, and then runs these steps:
- ~IF[ %入力 内に `%^l 以外の`禁止~host~cp$がある ] ⇒# `検証~error$; ~RET `失敗^i ◎ If input contains a forbidden host code point excluding U+0025 (%), validation error, return failure.
- %出力 ~LET 空~文字列 ◎ Let output be the empty string.
- %入力 内の ~EACH( ~cp %~cp ) に対し ⇒ %出力 ~APPEND `~UTF-8~percent-符号化する$( `~C0制御文字~percent-符号化-集合$, %~cp ) ◎ For each code point in input, UTF-8 percent encode it using the C0 control percent-encode set, and append the result to output.
- ~RET %出力 ◎ Return output.
3.6. ~hostの直列化-法
`~hostを直列化する@ ときは、所与の ( `~host$ %~host ) に対し, %~host の種別に応じて 次で与えられる結果を返す: ◎ The host serializer takes a host host and then runs these steps:
- `~IPv4~address$
- `~IPv4直列化器$( %~host ) ◎ If host is an IPv4 address, return the result of running the IPv4 serializer on host.
- `~IPv6~address$
- ❝[ ~APPEND `~IPv6直列化器$( %~host ) ~APPEND ❝] ◎ Otherwise, if host is an IPv6 address, return U+005B ([), followed by the result of running the IPv6 serializer on host, followed by U+005D (]).
- `~domain$
- `不透明な~host$
- `空~host$
- %~host ◎ Otherwise, host is a domain, opaque host, or empty host, return host.
`~IPv4直列化器@ は、所与の ( `~IPv4~address$ %~address ) に対し,次を走らす: ◎ The IPv4 serializer takes an IPv4 address address and then runs these steps:
- %出力 ~LET 空~文字列 ◎ Let output be the empty string.
- %n ~LET %~address ◎ Let n be the value of address.
-
~EACH( %i ~IN { 1 〜 4 } ) に対し,昇順に: ◎ For each i in the range 1 to 4, inclusive:
- %出力 ~SET `整数を直列化する$( %n を 256 で割った余り ) ~APPEND %出力 ◎ Prepend n % 256, serialized, to output.
- ~IF[ %i ~NEQ 4 ] ⇒ ❝. を %出力 の先頭に~~挿入する ◎ If i is not 4, then prepend U+002E (.) to output.
- %n ~SET floor( %n ÷ 256 ) ◎ Set n to floor(n / 256).
- ~RET %出力 ◎ Return output.
`~IPv6直列化器@ は、所与の ( `~IPv6~address$ %~address ) に対し,次を走らす: ◎ The IPv6 serializer takes an IPv6 address address and then runs these steps:
- %出力 ~LET 空~文字列 ◎ Let output be the empty string.
- %圧縮- ~LET ε ◎ ↓
-
~IF[ %~address の中に,[ 2 個以上~連続する,値 0 をとる`~IPv6~piece$からなる並び ]がある ] ⇒ %圧縮- ~SET [[ そのような並びのうち,最長である並び ]のうち,最初に来る並び ]の中の,最初の`~IPv6~piece$を指す~index
例えば `0:f:0:0:f:f:0:0^l に対しては、 2 個目の 0 を指すことになる。
◎ Let compress be an index to the first IPv6 piece in the first longest sequences of address’s IPv6 pieces that are 0. ◎ In 0:f:0:0:f:f:0:0 it would point to the second 0. ◎ If there is no sequence of address’s IPv6 pieces that are 0 that is longer than 1, then set compress to null. - %~ignore0 ~LET ~F ◎ Let ignore0 be false.
-
~EACH( 整数 %~piece~index ~IN { 0 〜 7 } ) に対し,昇順に: ◎ For each pieceIndex in the range 0 to 7, inclusive:
- ~IF[ %~ignore0 ~EQ ~T ]~AND[ %~address[ %~piece~index ] ~EQ 0 ] ⇒ ~CONTINUE ◎ If ignore0 is true and address[pieceIndex] is 0, then continue.
- %~ignore0 ~SET ~F ◎ Otherwise, if ignore0 is true, set ignore0 to false.
-
~IF[ %圧縮- ~NEQ ε ]~AND[ %圧縮- ~EQ %~piece~index ]: ◎ If compress is pieceIndex, then:
- %出力 ~APPEND [ %~piece~index ~EQ 0 ならば `::^l / ~ELSE_ `:^l ] ◎ Let separator be "::" if pieceIndex is 0, and U+003A (:) otherwise. ◎ Append separator to output.
- %~ignore0 ~SET ~T ◎ Set ignore0 to true and continue.
- ~CONTINUE ◎ ↑
- %出力 ~APPEND [ %~address[ %~piece~index ] を小文字~hexadecimal数で表現する最短の文字列 ] ◎ Append address[pieceIndex], represented as the shortest possible lowercase hexadecimal number, to output.
- ~IF[ %~piece~index ~NEQ 7 ] ⇒ %出力 ~APPEND ❝: ◎ If pieceIndex is not 7, then append U+003A (:) to output.
- ~RET %出力 ◎ Return output.
注記: この~algoは A Recommendation for IPv6 Address Text Representation (~IPv6~addressの推奨~表記)への準拠を要求する。 `RFC5952$r 【参考:~IPv6~address表記の柔軟性が起こす問題と RFC5952 の解説】 ◎ This algorithm requires the recommendation from A Recommendation for IPv6 Address Text Representation. [RFC5952]
3.7. ~hostの等価性
2 つの`~host$[ %A, %B ]が `同等@host かどうか決定するときは ⇒ [[ %A ~EQ %B ]ならば ~T / ~ELSE_ ~F ]を返す。 ◎ To determine whether a host A equals B, return true if A is B, and false otherwise.
課題: 証明書の比較には、[ ~domainの尾部の~dotは無視する ]ような,~hostの等価性の検査が要求される。 しかしながら、それらの~hostには,ここでは施行されない~DNS長さなどの 他の種々の側面0も施行される — ~URLはそれらを施行しないので。 これら 2 つを近づけるような, あるいは 統一化~modelとして何か良い示唆があれば,issue を file されたし。 ◎ Certificate comparison requires a host equivalence check that ignores the trailing dot of a domain (if any). However, those hosts have also various other facets enforced, such as DNS length, that are not enforced here, as URLs do not enforce them. If anyone has a good suggestion for how to bring these two closer together, or what a good unified model would be, please file an issue.
4. ~URL
高次の~levelからは、[ `~URL~record$, `妥当な~URL$sT, `~URL構文解析器$, `~URL直列化器$ ]は,次のように関係する: ◎ At a high level, a URL, valid URL string, URL parser, and URL serializer relate as follows:
- `~URL構文解析器$は、任意の~~入力~文字列に対し,[ `失敗^i, または `~URL~record$ ]を返す。 ◎ The URL parser takes an arbitrary string and returns either failure or a URL.
- `~URL~record$は、記憶域内の表現と捉えることもできる。 ◎ A URL can be seen as the in-memory representation.
- `妥当な~URL$sTは、`~URL構文解析器$に与えたときに,`検証~error$や `失敗^i を誘発しない — すなわち、[ 適合する/妥当である ]と見なされる — ような入力を定義する。 ◎ A valid URL string defines what input would not trigger a validation error or failure when given to the URL parser. I.e., input that would be considered conforming or valid.
- `~URL直列化器$は、~~入力の`~URL~record$に対し,文字列を返す。 (その文字列をさらに`~URL構文解析器$にかけた結果は、元の`~URL~record$と`同等$になる。) ◎ The URL serializer takes a URL and returns a string. (If that string is then parsed, the result will equal the URL that was serialized.)
入力~URL◎ Input | 基底~URL◎ Base | 妥当?◎ Valid | 出力~URL◎ Output |
---|---|---|---|
`https:example.org^c | ❌ | `https://example.org/^c | |
`https://////example.com///^c | ❌ | `https://example.com///^c | |
`https://example.com/././foo^c | ✅ | `https://example.com/foo^c | |
`hello:world^c | `https://example.com/^c | ✅ | `hello:world^c |
`https:example.org^c | `https://example.com/^c | ❌ | `https://example.com/example.org^c |
`\example\..\demo/.\^c | `https://example.com/^c | ❌ | `https://example.com/demo/^c |
`example^c | `https://example.com/demo^c | ✅ | `https://example.com/example^c |
`file:///C|/demo^c | ❌ | `file:///C:/demo^c | |
`..^c | `file:///C:/demo^c | ✅ | `file:///C:/^c |
`file://loc%61lhost/^c | ✅ | `file:///^c | |
`https://user:password~atexample.org/^c | ❌ | `https://user:password~atexample.org/^c | |
`https://example.org/foo bar^c | ❌ | `https://example.org/foo%20bar^c | |
`https://EXAMPLE.com/../x^c | ✅ | `https://example.com/x^c | |
`https://ex ample.org/^c | ❌ | `失敗^i | |
`example^c | ❌† | `失敗^i | |
`https://example.com:demo^c | ❌ | `失敗^i | |
`http://[www.example.com]/^c | ❌ | `失敗^i |
簡潔にするため、ここでの[ 基底/出力 ]`~URL$は,`~URL直列化器$にかけた結果で表現されている。 ◎ The base and output URL are represented in serialized form for brevity.
† — 基底~URLを欠くことに因り妥当でない。4.1. ~URL表現
`~URL@ とは、統一的†な識別子である。 `妥当な~URL$sTと区別するため、`~URL~record$とも称される††。 ◎ A URL is a universal identifier. To disambiguate from a valid URL string it can also be referred to as a URL record.
【† “universal” — (資源を一意的に識別するために,)~~普遍的に/広く~~一般から/広範の応用に渡って/共通して 利用し得るような 】【†† 以下に定義される`~URL$の各種 構成子は、この,内部表現による~URL(~URLを意図して与えられた文字列を構文解析して得られる`~URL~record$)の各種~成分を表す。 】
`~URL$は、次の成分からなる:
- `~scheme@url(初期~値:空~文字列)
- `~URL$の種別を識別する`~ASCII文字列$であって、`~URL構文解析器$にかけた後の,`~URL$の更なる分岐処理に利用し得るもの。 ◎ A URL’s scheme is an ASCII string that identifies the type of URL and can be used to dispatch a URL for further processing after parsing. It is initially the empty string.
- `~username@url(初期~値:空~文字列)
- ~usernameを識別する`~ASCII文字列$。 ◎ A URL’s username is an ASCII string identifying a username. It is initially the empty string.
- `~password@url(初期~値:空~文字列 )
- ~passwordを識別する`~ASCII文字列$。 ◎ A URL’s password is an ASCII string identifying a password. It is initially the empty string.
- `~host@url(初期~値: ~NULL )
- ~NULL, または `~host$。 ◎ A URL’s host is null or a host. It is initially null.
-
注記: `~URL$に許容される[ `~scheme$url, `~host$url ]の組み合わせを次の表に挙げる。 ◎ The following table lists allowed URL’s scheme / host combinations.
`~scheme$url `~host$url `~domain$ `~IPv4~address$ `~IPv6~address$ `不透明な~host$ `空~host$ ~NULL `file^l 以外の`特別~scheme$ ✅ ✅ ✅ ❌ ❌ ❌ `file^l ✅ ✅ ✅ ❌ ✅ ✅ 非`特別~scheme$ ❌ ❌ ✅ ✅ ✅ ✅ - `~port@url(初期~値: ~NULL )
- ~NULL, または ~networking~portを識別する 16-bit 非負~整数。 ◎ A URL’s port is either null or a 16-bit unsigned integer that identifies a networking port. It is initially null.
- `~path@url(初期~値:空)
- ~dataを保持している[ 0 個以上の`~ASCII文字列$からなる`~list$ ]であり、通例的には,資源の所在を階層的に識別するものになる。 ◎ A URL’s path is a list of zero or more ASCII strings holding data, usually identifying a location in hierarchical form. It is initially empty.
- 注記: `~URL$が`特別$である場合、その`~path$urlは,常に`空$でない ◎ A special URL always has a non-empty path.
- `~query@url(初期~値: ~NULL )
- ~NULL, または ~dataを保持している`~ASCII文字列$。 ◎ A URL’s query is either null or an ASCII string holding data. It is initially null.
- `素片@url(初期~値: ~NULL )
- ~NULL, または`~ASCII文字列$。 非~NULLは、[ `~URL$の他の成分から識別される資源 ]に対する更なる処理に利用され得る~dataを,保持する。 ◎ A URL’s fragment is either null or an ASCII string holding data that can be used for further processing on the resource the URL’s other components identify. It is initially null.
`~URL$には、次のものも結付けられる: ◎ ↓
- `~cannot-be-a-base-URL~flag@(初期~値: ~OFF )
- ~flag値 ◎ A URL also has an associated cannot-be-a-base-URL flag. It is initially unset.
- `~obj@url(初期~値: ~NULL )
- ~NULL, または 次のいずれかの~obj ⇒ `Blob$I `FILEAPI$r / `MediaSource$I `MEDIA-SOURCE$r ◎ A URL also has an associated object that is null, a Blob object, or a MediaSource object. It is initially null. [FILEAPI] [MEDIA-SOURCE]
- 注記: 現時点では,これは主に `blob^l `~URL$を~supportするためにあるが、他のものも追加され得るので,単に “~obj” と称する。 ◎ At this point this is used primarily to support "blob" URLs, but others can be added going forward, hence "object".
4.2. ~URLのその他諸々
`特別~scheme@ とは、次の表の 1 列目に挙げられている`~scheme$urlである。 `特別~scheme$の `既定~port@ とは、表の同じ行の 2 列目に示されている`~port$urlである。 ◎ A special scheme is a scheme listed in the first column of the following table. A default port is a special scheme’s optional corresponding port and is listed in the second column on the same row.
`~scheme$url | `~port$url |
---|---|
`ftp^l | 21 |
`file^l | (未定義) |
`gopher^l | 70 |
`http^l | 80 |
`https^l | 443 |
`ws^l | 80 |
`wss^l | 443 |
`~scheme$urlが`特別~scheme$であるような`~URL$は, `特別@ であるという。 `特別でない?@( %~URL ) は、所与の %~URL に対し[ %~URL は`特別$でないならば ~T / ~ELSE_ ~F ]を返す。 【原文では “特別でない” が “特別である” の否定として定義されているが、表記上の都合により,この訳ではこのように表現する(否定は、単に`特別$でないと記す。】 ◎ A URL is special if its scheme is a special scheme. A URL is not special if its scheme is not a special scheme.
`~URL$が `資格証明情報を含む@ とは、その[ `~username$url, `~password$url ]のいずれかは空~文字列でないことを意味する。 ◎ A URL includes credentials if its username or password is not the empty string.
【(参考) HTTP ~protocolの下では、~target~URL内での直接的な[ ~password/~username ]の利用は保安~上の問題から許容されない(参照: RFC7230 の Appendix A, 2.7.1 節の userinfo の記述 )。 】
次のいずれかを満たす`~URL~record$は、 `~username/~password/~portを持てない@ とされる:
- `~host$url ~IN { ~NULL, 空~文字列 }
- `~cannot-be-a-base-URL~flag$ ~EQ ~ON
- `~scheme$url ~EQ `file^l
`~URL$は `基底~URL@ であるものと指名されることもある。 ◎ A URL can be designated as base URL.
注記: `基底~URL$は、`~URL構文解析器$において,`相対~URL$sTも入力にとり得るときに有用になる。 ◎ A base URL is useful for the URL parser when the input might be a relative-URL string.
`~drive_letter@ とは、次を満たす 2 個の~cp並び[ %L1, %L2 ]である:
- %L1 ~IN `~ASCII英字$
- %L2 ~IN { ❝:, ❝| }
`正規化-済み~drive_letter@ とは、`~drive_letter$のうち,[ 2 個目の~cp ~EQ ❝: ]なるものである。 ◎ A normalized Windows drive letter is a Windows drive letter of which the second code point is U+003A (:).
注記: ~URLの書式 節により、適合するのは`正規化-済み~drive_letter$に限られる。 ◎ As per the URL writing section, only a normalized Windows drive letter is conforming.
3 個の[ ~cp, または `EOF$i ]からなる並び[ %C0, %C1, %C2 ]は、次をすべて満たすならば `~drive_letterから開始されて@ いるとされる: ◎ A string starts with a Windows drive letter if all of the following are true:
- 並び[ %C0, %C1 ]は、`~drive_letter$である(特に,いずれも `EOF$i でない) ◎ its length is greater than or equal to 2 ◎ its first two code points are a Windows drive letter
- %C2 ~IN { `EOF$i, ❝/, ❝\, ❝?, ❝# } ◎ its length is 2 or its third code point is U+002F (/), U+005C (\), U+003F (?), or U+0023 (#).
並びが成す文字列 | ~drive_letterから開始されている? |
---|---|
"`c:^c" | ✅ |
"`c:/^c" | ✅ |
"`c:a^c" | ❌ |
%url の `~pathを短縮する@ ときは、次を走らす: ◎ To shorten a url’s path:
- %path ~LET %url の`~path$url ◎ Let path be url’s path.
- ~IF[ %path は`空$である ] ⇒ ~RET ◎ If path is empty, then return.
- ~IF[ %url の`~scheme$url ~EQ `file^l ]~AND[ %path の`~size$ ~EQ 1 ]~AND[ %path[0] は`正規化-済み~drive_letter$である ] ⇒ ~RET ◎ If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
- %path から最後の~itemを`除去する$ ◎ Remove path’s last item.
4.3. ~URLの書式
`妥当な~URL@sT は、[ `素片~付き相対~URL$sT, `素片~付き絶対~URL$sT ]のいずれかで~MUST。
以下において,“省略可” と記された部分は省略できる/され得ることを意味する(すなわち, 0 個, または 1 個)。
◎ A valid URL string must be either a relative-URL-with-fragment string or an absolute-URL-with-fragment string.`素片~付き絶対~URL@sT は、次の並びで~MUST:
- `絶対~URL$sT
- 次の並び(省略可):
- ❝#
- `~URL素片$sT
`絶対~URL@sT は、次の並びで~MUST: ◎ An absolute-URL string must be one of the following
-
次のいずれか:
-
次の並び:
- `~URL~scheme$sTであって,[ `file^l 以外の`特別~scheme$ ]に`~ASCII大小無視$で合致するもの
- ❝:
- `~scheme相対~特別~URL$sT
-
次の並び:
- `~URL~scheme$sTであって,`特別~scheme$に`~ASCII大小無視$で合致しないもの
- ❝:
- `相対~URL$sT
-
次の並び:
- `~URL~scheme$sTであって, `file^l に`~ASCII大小無視$で合致するもの
- ❝:
- `~scheme相対~file~URL$sT
-
-
次の並び(省略可):
- ❝?
- `~URL~query$sT
`~URL~scheme@sT は、次の並びで~MUST:
- 1 個の`~ASCII英字$
- 0 個以上の { `~ASCII英数字$, ❝+, ❝-, ❝. } からなる並び
`~URL~scheme$sT は、 IANA URI [sic] Schemes ~registryに登録されるべきである。 `IANA-URI-SCHEMES$r `RFC7595$r
◎ A URL-scheme string must be one ASCII alpha, followed by zero or more of ASCII alphanumeric, U+002B (+), U+002D (-), and U+002E (.). Schemes should be registered in the IANA URI [sic] Schemes registry. [IANA-URI-SCHEMES] [RFC7595]`素片~付き相対~URL@sT は、次の並びで~MUST:
- `相対~URL$sT
- 次の並び(省略可):
- ❝#
- `~URL素片$sT
`相対~URL@sT は、次の並びで~MUST: ◎ A relative-URL string must be one of the following,\
-
`基底~URL$の`~scheme$urlに応じて: ◎ switching on base URL’s scheme:
- `file^l 以外の`特別~scheme$ならば,次のいずれか: ◎ A special scheme that is not "file"
- `~scheme相対~特別~URL$sT ◎ a scheme-relative-special-URL string
- `~path絶対~URL$sT ◎ a path-absolute-URL string
- `~path相対 ~schemeなし~URL$sT ◎ a path-relative-scheme-less-URL string
- `file^l ならば,次のいずれか: ◎ "file"
- `~scheme相対~file~URL$sT ◎ a scheme-relative-file-URL string
- `~path絶対~URL$sT — ただし、[ `基底~URL$の`~host$urlは`空~host$である ]場合に限る ◎ a path-absolute-URL string if base URL’s host is an empty host
- `~path絶対 非 Windows file ~URL$sT — ただし、[ `基底~URL$の`~host$urlは`空~host$でない ]場合に限る ◎ a path-absolute-non-Windows-file-URL string if base URL’s host is not an empty host
- `~path相対 ~schemeなし~URL$sT ◎ a path-relative-scheme-less-URL string
- 他の場合,次のいずれか: ◎ Otherwise
- `~scheme相対~URL$sT ◎ a scheme-relative-URL string
- `~path絶対~URL$sT ◎ a path-absolute-URL string
- `~path相対 ~schemeなし~URL$sT ◎ a path-relative-scheme-less-URL string
-
次の並び(省略可):
- ❝?
- `~URL~query$sT
注記: `相対~URL$sTを`~URL構文解析器$にかけるときは、非~NULLの`基底~URL$が必要とされる。 ◎ A non-null base URL is necessary when parsing a relative-URL string.
`~scheme相対~特別~URL@sT は、次の並びで~MUST
- `//^l
- `妥当な~host$sT
-
次の並び(省略可):
- ❝:
- `~URL~port$sT
- `~path絶対~URL$sT(省略可)
`~URL~port@sT は、[ 0 個以上の`~ASCII数字$からなる並び ]で~MUST。 ◎ A URL-port string must be zero or more ASCII digits.
`~scheme相対~URL@sT は、次の並びで~MUST
- `//^l
- `不透明な~host&~port$sT
- `~path絶対~URL$sT(省略可)
`不透明な~host&~port@sT は、[ 空~文字列, または次の並び ]で~MUST:
- `妥当な不透明な~host$sT
-
次の並び(省略可):
- ❝:
- `~URL~port$sT
`~scheme相対~file~URL@sT は、次の並びで~MUST:
- `//^l
- 次のいずれか:
- `~path絶対~URL$sT
- 次の並び:
- `妥当な~host$sT
- `~path絶対 非 Windows file ~URL$sT(省略可)
`~path絶対~URL@sT は、次の並びで~MUST:
- ❝/
- `~path相対~URL$sT
`~path絶対 非 Windows file ~URL@sT は、次をいずれも満たす文字列で~MUST:
- `~path絶対~URL$sTである
- 次の並びから開始されていない:
- ❝/
- `~drive_letter$
- ❝/
`~path相対~URL@sT は、次をいずれも満たす文字列で~MUST:
- ❝/ で区切られた[ 0 個以上の`~URL~path区分$sT ]からなる
- ❝/ から開始されていない
`~path相対 ~schemeなし~URL@sT は、次をいずれも満たす文字列で~MUST:
- `~path相対~URL$sTである
- 次の並びから開始されていない:
- `~URL~scheme$sT
- ❝:
`~URL~path区分@sT は、[ 0 個以上の[ ❝/, ❝? を除く`~URL単位$ ]からなる並び ]で~MUST。 ◎ A URL-path-segment string must be one of the following
`~URL~path区分$sTのうち,次のものは、構文解析-時に~~特別に扱われる: ◎ zero or more URL units, excluding U+002F (/) and U+003F (?), that together are not a single-dot path segment or a double-dot path segment. ◎ a single-dot path segment ◎ a double-dot path segment.
-
`単dot~path区分@ は、次のいずれかで~MUST:
- ❝.
- `~ASCII大小無視$で `%2e^l に合致するもの
- `二重dot~path区分@ は、[ 2 個の`単dot~path区分$(同じでなくてもよい)からなる並び ]で~MUST。 ◎ A double-dot path segment must be ".." or an ASCII case-insensitive match for ".%2e", "%2e.", or "%2e%2e".
`~URL~query@sT は、[ 0 個以上の`~URL単位$からなる並び ]で~MUST。 ◎ A URL-query string must be zero or more URL units.
`~URL素片@sT は、[ 0 個以上の`~URL単位$からなる並び ]で~MUST。 ◎ A URL-fragment string must be zero or more URL units.
次に挙げる`~cp$が `~URL~cp@ である:
- `~ASCII英数字$
- ❝!, ❝$, `0026^U `&^smb, ❝', ❝(, ❝), ❝*, ❝+, ❝,, ❝-, ❝., ❝/, ❝:, ❝;, ❝=, ❝?, ❝@, ❝_, ❝~
- `00A0^U 〜 `10FFFD^U — ただし、`~surrogate$, `非文字$は除外する。
注記: `0080^U DELETE 以上の~cpは、`~URL構文解析器$により`~percent-符号化された~byte$に変換されることになる。 ◎ Code points greater than U+007F DELETE will be converted to percent-encoded bytes by the URL parser.
注記: ~HTMLにおいては、文書の符号化法が旧来のものである場合,`~URL~query$sT内の `0080^U 以上の~cpは、文書の符号化法を用いて`~percent-符号化された~byte$に変換される。 これは、ある文書で働く~URLが 異なる文書~符号化法を利用する文書に複製されるときに,問題になり得る。 この問題は、あらゆる箇所に~UTF-8符号化法を用いれば~~解消する。 ◎ In HTML, when the document encoding is a legacy encoding, code points in the URL-query string that are higher than U+007F DELETE will be converted to percent-encoded bytes using the document’s encoding. This can cause problems if a URL that works in one document is copied to another document that uses a different document encoding. Using the UTF-8 encoding everywhere solves this problem.
例えば、次の~HTML文書を考える: ◎ For example, consider this HTML document:
<!doctype html> <meta charset="windows-1252"> <a href="?smörgåsbord">Test</a>
文書~符号化法は windows-1252 なので、 ~linkの `~URL$の`~query$urlは `sm%F6rg%E5sbord^l になる。 文書~符号化法が UTF-8 であった場合、それは `sm%C3%B6rg%C3%A5sbord^l になる。 ◎ Since the document encoding is windows-1252, the link’s URL’s query will be "sm%F6rg%E5sbord". If the document encoding had been UTF-8, it would instead be "sm%C3%B6rg%C3%A5sbord".
次のものが `~URL単位@ である ⇒ `~URL~cp$, `~percent-符号化された~byte$ 【従って,`~URL単位$がなす集合は文字列の集合になる。】 ◎ The URL units are URL code points and percent-encoded bytes.
注記: `~percent-符号化された~byte$は、~cpのうち[ `~URL~cp$でない, あるいは 書出せるものから除外されている ]ものを符号化するときに,利用され得る/できる。 ◎ Percent-encoded bytes can be used to encode code points that are not URL code points or are excluded from being written.
注記: `妥当な~URL$sTの中で,`~URL~record$の[ `~username$url, `~password$url ]を表す仕方は無い。 ◎ There is no way to express a username or password of a URL record within a valid URL string.
4.4. ~URLの構文解析-法
`~URL構文解析器@ は、所与の ⇒# 文字列 %入力, `基底~URL$ %基底 (省略時は ε ), `符号化法$ %上書符号化法 (省略時は ε ) ◎終 に対し,次を走らす: ◎ The URL parser takes a string input, with an optional base URL base and an optional encoding encoding override, and then runs these steps:
注記: 非~web~browser実装は、`基本~URL構文解析器$のみ実装すれば~~十分である。 ◎ Non-web-browser implementations only need to implement the basic URL parser.
- %url ~LET 次を与える下で, %入力 を`基本~URL構文解析器$にかけた結果 ⇒ ( `基底~URL$ %基底 , `符号化法$ %上書符号化法 ) ◎ Let url be the result of running the basic URL parser on input with base, and encoding override as provided.
- ~IF[ %url ~EQ `失敗^i ] ⇒ ~RET `失敗^i ◎ If url is failure, return failure.
- ~IF[ %url の`~scheme$url ~NEQ `blob^l ] ⇒ ~RET %url ◎ If url’s scheme is not "blob", return url.
- ~IF[ `~Blob~URL~store$ `FILEAPI$r 内に[ %url の`~path$url[0] ]に対応する~entryは在る ] ⇒ %url の`~obj$url ~SET その~entry ◎ If url’s path is empty or url’s path[0] is not in the Blob URL Store, then return url. [FILEAPI] ◎ Set url’s object to the entry in the Blob URL Store corresponding to url’s path[0].
- ~RET %url ◎ Return url.
所与の文字列 %入力 を `基本~URL構文解析器@ にかけるときは、所与の ⇒# `基底~URL$ %基底 (省略時は ε ), `符号化法$ %上書符号化法 (省略時は ε ), `~URL$と上書stateの組 ( %url, %上書state ) (省略時は ( ε, ε ) ) ◎終 に対し,次を走らす: ◎ The basic URL parser takes a string input, optionally with a base URL base, optionally with an encoding encoding override, optionally with a URL url and a state override state override, and then runs these steps:
注記:
- 引数 %上書符号化法 は、~HTMLにのみ関連する,旧来の概念である。 `HTML$r
-
引数 組
( %url, %上書state )
が利用されるのは、種々の~APIに限られる。
`基本~URL構文解析器$は、この引数 組が:
- 渡されなかった場合は、`~URL$または `失敗^i を返す。
- 渡された場合は、渡された %url を改変した上で 何も返さずに終了することもある。 【あるいは `失敗^i を返す。 `失敗^i を返しつつ,渡された %url も改変することはあり得るか?】
-
~IF[ %url ~EQ ε ]: ◎ If url is not given:
- %url ~SET 新たな`~URL$ ◎ Set url to a new URL.
- ~IF[ %入力 の[ 先頭または末尾 ]の文字 ~IN `~C0制御文字や~space$ ] ⇒ `検証~error$ ◎ If input contains any leading or trailing C0 control or space, validation error.
- %入力 から[[ 頭部と尾部 ]の,`~C0制御文字や~space$からなる並び ]を除去する ◎ Remove any leading and trailing C0 control or space from input.
- ~IF[ %入力 内に`~ASCII~tabや~ASCII改行文字$がある ] ⇒ `検証~error$ ◎ If input contains any ASCII tab or newline, validation error.
- %入力 からすべての`~ASCII~tabや~ASCII改行文字$を除去する ◎ Remove all ASCII tab or newline from input.
- %state ~LET [ %上書state ~NEQ ε ならば %上書state / ~ELSE_ `~scheme開始-$st ] ◎ Let state be state override if given, or scheme start state otherwise.
- ~IF[ %基底 ~EQ ε ] ⇒ %基底 ~SET ~NULL ◎ If base is not given, set it to null.
- %符号化法 ~LET `~UTF-8$ ◎ Let encoding be UTF-8.
- ~IF[ %上書符号化法 ~NEQ ε ] ⇒ %符号化法 ~SET `符号化法から出力~符号化法を取得する$( %上書符号化法 ) ◎ If encoding override is given, set encoding to the result of getting an output encoding from encoding override.
- %~buffer ~LET 空~文字列 ◎ Let buffer be the empty string.
- ( %~atmark~flag, %~brackets~flag, %~password~token出現~flag ) ~LET ( ~OFF, ~OFF, ~OFF ) ◎ Let the @ flag, [] flag, and passwordTokenSeenFlag be unset.
- %~pointer ~LET 0 ( %入力 内の最初の~cpを指す~pointer) ◎ Let pointer be a pointer to first code point in input.
-
~WHILE 無条件
- 下に与える状態機械を走らす
- ~IF[ `C$V ~EQ `EOF$i ] ⇒ ~BREAK
- %~pointer ~INCBY 1
-
~IF[ %上書state ~EQ ε ] ⇒ ~RET %url
【 構文解析に失敗した場合、この段には到達しない。 】【 この段は,原文では状態機械の末尾に置かれているが、見通しを良くするため,ここに移動している。 】
◎ ↓↓
状態機械は、 %state に応じて,以下における対応する段を走らす — この状態機械の中では: ◎ ↑↑
- “~RET” は、上の~algo自身を終了させるとする。
-
`~URL単位かどうか検証する@ ときは、 `C$V に応じて次を走らすとする†:
- `~URL~cp$ ⇒ 何もしない
- ❝% ⇒ ~IF[ `C1$V ~NIN `~ASCII~hex数字$ ]~OR[ `C2$V ~NIN `~ASCII~hex数字$ ] ⇒ `検証~error$
- その他 ⇒ `検証~error$
【† この定義は、共通する記述を集約するために,この訳にて追加したもの。 】【 この状態機械は、現在の `state^i からは常に,自身または自身より後に示されている `state^i へ遷移するように、整列して記されている。 】
- `~scheme開始-@st
-
- ~IF[ `C$V ~IN `~ASCII英字$ ] ⇒# %~buffer ~APPEND `~ASCII小文字~化する$( `C$V ); %state ~SET `~scheme$st ◎ If c is an ASCII alpha, append c, lowercased, to buffer, and set state to scheme state.
- ~ELIF[ %上書state ~EQ ε ] ⇒# %~pointer ~DECBY 1; %state ~SET `~schemeなし$st ◎ Otherwise, if state override is not given, set state to no scheme state, and decrease pointer by one.
-
~ELSE ⇒# `検証~error$; ~RET `失敗^i ◎ Otherwise, validation error, return failure.
この `失敗^i の指示は、 `Location$I ~objの `~protocol0$m 属性から排他的に利用される。 ◎ This indication of failure is used exclusively by Location object’s protocol attribute.
- `~scheme@st
-
- ~IF[ `C$V ~IN { `~ASCII英数字$, ❝+, ❝-, ❝. } ] ⇒ %~buffer ~APPEND `~ASCII小文字~化する$( `C$V ) ◎ If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.), append c, lowercased, to buffer.
-
~ELIF[ `C$V ~EQ ❝: ]: ◎ Otherwise, if c is U+003A (:), then:
-
~IF[ %上書state ~NEQ ε ]~AND[ 次のいずれかが満たされる ]…: ◎ If state override is given, then:
- [ %url の`~scheme$url, %~buffer ]のうち,片方だけが`特別~scheme$である ◎ If url’s scheme is a special scheme and buffer is not a special scheme, then return. ◎ If url’s scheme is not a special scheme and buffer is a special scheme, then return.
- [[ %url は`資格証明情報を含む$ ]~OR[ %url の`~port$url ~NEQ ~NULL ]]~AND[ %~buffer ~EQ `file^l ] ◎ If url includes credentials or has a non-null port, and buffer is "file", then return.
- [ %url の`~scheme$url ~EQ `file^l ]~AND[ %url の`~host$urlは[ `空~host$または~NULL ]である ] ◎ If url’s scheme is "file" and its host is an empty host or null, then return.
…ならば ⇒ ~RET ◎ ↑
- %url の`~scheme$url ~SET %~buffer ◎ Set url’s scheme to buffer.
-
~IF[ %上書state ~NEQ ε ]: ◎ If state override is given, then:
- ~IF[ %url の`~port$url ~EQ %url の`~scheme$urlの`既定~port$ ] ⇒ %url の`~port$url ~SET ~NULL ◎ If url’s port is url’s scheme’s default port, then set url’s port to null.
- ~RET ◎ Return.
- %~buffer ~SET 空~文字列 ◎ Set buffer to the empty string.
-
~IF[ %url の`~scheme$url ~EQ `file^l ]: ◎ If url’s scheme is "file", then:
- ~IF[ `C1$V ~NEQ `/^l ]~OR[ `C2$V ~NEQ `/^l ] ⇒ `検証~error$ ◎ If remaining does not start with "//", validation error.
- %state ~SET `~file$st ◎ Set state to file state.
-
~ELIF[ %url は`特別$である ]~AND[ %基底 ~NEQ ~NULL ]~AND[ %基底 の`~scheme$url ~EQ %url の`~scheme$url ] ⇒ %state ~SET `特別 相対/権限$st ◎ Otherwise, if url is special, base is non-null, and base’s scheme is equal to url’s scheme, set state to special relative or authority state.
注記: これは、`~cannot-be-a-base-URL~flag$は ~OFF にされていることを意味する。 ◎ This means that base’s cannot-be-a-base-URL flag is unset.
- ~ELIF[ %url は`特別$である ] ⇒ %state ~SET `特別 権限~slash$st ◎ Otherwise, if url is special, set state to special authority slashes state.
- ~ELIF[ `C1$V ~EQ ❝/ ] ⇒# %~pointer ~INCBY 1; %state ~SET `~path/権限$st ◎ Otherwise, if remaining starts with an U+002F (/), set state to path or authority state and increase pointer by one.
- ~ELSE ⇒# %url の`~cannot-be-a-base-URL~flag$ ~SET ~ON; %url の`~path$urlに空~文字列を`付加する$; %state ~SET `~cannot-be-a-base-URL~path$st ◎ Otherwise, set url’s cannot-be-a-base-URL flag, append an empty string to url’s path, and set state to cannot-be-a-base-URL path state.
-
- ~ELIF[ %上書state ~EQ ε ] ⇒# %~buffer ~SET 空~文字列; %~pointer ~SET −1 (%入力 の最初の~cpから、やり直す); %state ~SET `~schemeなし$st; ◎ Otherwise, if state override is not given, set buffer to the empty string, state to no scheme state, and start over (from the first code point in input).
-
~ELSE ⇒# `検証~error$; ~RET `失敗^i ◎ Otherwise, validation error, return failure.
この `失敗^i の指示は、 `Location$I ~objの `~protocol0$m 属性から排他的に利用される。 更には、この~stateの早期における非 `失敗^i による終了は、その属性を定義するための意図的な相違である。 ◎ This indication of failure is used exclusively by Location object’s protocol attribute. Furthermore, the non-failure termination earlier in this state is an intentional difference for defining that attribute.
- `~schemeなし@st
-
- ~IF[ %基底 ~EQ ~NULL ]~OR[[ %基底 の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ]~AND[ `C$V ~NEQ ❝# ]] ⇒# `検証~error$; ~RET `失敗^i ◎ If base is null, or base’s cannot-be-a-base-URL flag is set and c is not U+0023 (#), validation error, return failure.
-
~ELIF[ %基底 の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ]~AND[ `C$V ~EQ ❝# ]:
- %url の ⇒# `~scheme$url ~SET %基底 の`~scheme$url; `~path$url ~SET %基底 の`~path$urlの複製; `~query$url ~SET %基底 の`~query$url; `素片$url ~SET 空~文字列; `~cannot-be-a-base-URL~flag$ ~SET ~ON
- %state ~SET `素片$st
- ~ELIF[ %基底 の`~scheme$url ~NEQ `file^l ] ⇒# %~pointer ~DECBY 1; %state ~SET `相対$st ◎ Otherwise, if base’s scheme is not "file", set state to relative state and decrease pointer by one.
- ~ELSE ⇒# %~pointer ~DECBY 1; %state ~SET `~file$st ◎ Otherwise, set state to file state and decrease pointer by one.
- `特別 相対/権限@st
-
- ~IF[ `C$V ~EQ ❝/ ]~AND[ `C1$V ~EQ ❝/ ] ⇒# %~pointer ~INCBY 1; %state ~SET `特別 権限~slash無視$st ◎ If c is U+002F (/) and remaining starts with U+002F (/), then set state to special authority ignore slashes state and increase pointer by one.
- ~ELSE ⇒# `検証~error$; %~pointer ~DECBY 1; %state ~SET `相対$st ◎ Otherwise, validation error, set state to relative state and decrease pointer by one.
- `~path/権限@st
-
- ~IF[ `C$V ~EQ ❝/ ] ⇒ %state ~SET `権限$st ◎ If c is U+002F (/), then set state to authority state.
- ~ELSE ⇒# %~pointer ~DECBY 1; %state ~SET `~path$st ◎ Otherwise, set state to path state, and decrease pointer by one.
- `相対@st
-
- %url の`~scheme$url ~SET %基底 の`~scheme$url
- ~IF[ %url は`特別$である ]~AND[ `C$V ~EQ ❝\ ] ⇒# `検証~error$; %state ~SET `相対~slash$st
- ~ELIF[ `C$V ~EQ ❝/ ] ⇒ %state ~SET `相対~slash$st
-
~ELSE:
- %url の ⇒# `~username$url ~SET %基底 の`~username$url; `~password$url ~SET %基底 の`~password$url; `~host$url ~SET %基底 の`~host$url; `~port$url ~SET %基底 の`~port$url; `~path$url ~SET %基底 の`~path$urlの複製
-
`C$V に応じて:
- `EOF$i ⇒ %url の`~query$url ~SET %基底 の`~query$url
- ❝? ⇒# %url の`~query$url ~SET 空~文字列; %state ~SET `~query$st
- ❝# ⇒# %url の`~query$url ~SET %基底 の`~query$url; %url の`素片$url ~SET 空~文字列; %state ~SET `素片$st
-
~OTHER:
- ~IF[ %url の`~path$urlは空でない ] ⇒ %url の`~path$urlから最後の~itemを`除去する$
- %~pointer ~DECBY 1
- %state ~SET `~path$st
【 この段では、原文の記述を論理的に集約している。 】
◎ Set url’s scheme to base’s scheme, and then, switching on c: The EOF code point • Set url’s username to base’s username, url’s password to base’s password, url’s host to base’s host, url’s port to base’s port, url’s path to a copy of base’s path, and url’s query to base’s query. U+002F (/) • Set state to relative slash state. U+003F (?) • Set url’s username to base’s username, url’s password to base’s password, url’s host to base’s host, url’s port to base’s port, url’s path to a copy of base’s path, url’s query to the empty string, and state to query state. U+0023 (#) • Set url’s username to base’s username, url’s password to base’s password, url’s host to base’s host, url’s port to base’s port, url’s path to a copy of base’s path, url’s query to base’s query, url’s fragment to the empty string, and state to fragment state. Otherwise • If url is special and c is U+005C (\), validation error, set state to relative slash state. • Otherwise, run these steps: •• Set url’s username to base’s username, url’s password to base’s password, url’s host to base’s host, url’s port to base’s port, url’s path to a copy of base’s path, and then remove url’s path’s last item, if any. •• Set state to path state, and decrease pointer by one. - `相対~slash@st
-
-
~IF[ %url は`特別$である ]~AND[ `C$V ~IN { ❝/, ❝\ } ]: ◎ If url is special and c is U+002F (/) or U+005C (\), then:
- ~IF[ `C$V ~EQ ❝\ ] ⇒ `検証~error$ ◎ If c is U+005C (\), validation error.
- %state ~SET `特別 権限~slash無視$st ◎ Set state to special authority ignore slashes state.
- ~ELIF[ `C$V ~EQ ❝/ ] ⇒ %state ~SET `権限$st ◎ Otherwise, if c is U+002F (/), then set state to authority state.
-
~ELSE:
- %url の ⇒# `~username$url ~SET %基底 の`~username$url; `~password$url ~SET %基底 の`~password$url; `~host$url ~SET %基底 の`~host$url; `~port$url ~SET %基底 の`~port$url
- %~pointer ~DECBY 1
- %state ~SET `~path$st
-
- `特別 権限~slash@st
-
- ~IF[ `C$V ~EQ ❝/ ]~AND[ `C1$V ~EQ ❝/ ] ⇒ %~pointer ~INCBY 1 ◎ If c is U+002F (/) and remaining starts with U+002F (/), then set state to special authority ignore slashes state and increase pointer by one.
- ~ELSE ⇒# `検証~error$; %~pointer ~DECBY 1 ◎ Otherwise, validation error, set state to special authority ignore slashes state, and decrease pointer by one.
- %state ~SET `特別 権限~slash無視$st ◎ ↑
- `特別 権限~slash無視@st
-
- ~IF[ `C$V ~NIN { ❝/, ❝\ } ] ⇒# %~pointer ~DECBY 1; %state ~SET `権限$st ◎ If c is neither U+002F (/) nor U+005C (\), then set state to authority state, and decrease pointer by one.
- ~ELSE ⇒ `検証~error$ ◎ Otherwise, validation error.
- `権限@st
-
-
~IF[ `C$V ~EQ ❝@ ]: ◎ If c is U+0040 (@), then:
- `検証~error$ ◎ Validation error.
- ~IF[ %~atmark~flag ~EQ ~ON ] ⇒ %~buffer の先頭に `%40^l を~~挿入する ◎ If the @ flag is set, prepend "%40" to buffer.
- %~atmark~flag ~SET ~ON ◎ Set the @ flag.
-
%~buffer 内の ~EACH( %~cp ) に対し: ◎ For each codePoint in buffer:
- ~IF[ %~cp ~EQ ❝: ]~AND[ %~password~token出現~flag ~EQ ~OFF ] ⇒# %~password~token出現~flag ~SET ~ON; ~CONTINUE ◎ If codePoint is U+003A (:) and passwordTokenSeenFlag is unset, then set passwordTokenSeenFlag and continue.
- %符号化-済み~cp ~LET `~UTF-8~percent-符号化する$( `~userinfo~percent-符号化-集合$, %~cp ) ◎ Let encodedCodePoints be the result of running UTF-8 percent encode codePoint using the userinfo percent-encode set.
- ~IF[ %~password~token出現~flag ~EQ ~ON ] ⇒ %url の`~password$url ~APPEND %符号化-済み~cp ◎ If passwordTokenSeenFlag is set, then append encodedCodePoints to url’s password.
- ~ELSE ⇒ %url の`~username$url ~APPEND %符号化-済み~cp ◎ Otherwise, append encodedCodePoints to url’s username.
- %~buffer ~SET 空~文字列 ◎ Set buffer to the empty string.
-
~ELIF[ 次のいずれかが満たされる ]…: ◎ Otherwise, if one of the following is true
- `C$V ~IN { `EOF$i, ❝/, ❝?, ❝# } ◎ c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
- [ %url は`特別$である ]~AND[ `C$V ~EQ ❝\ ] ◎ url is special and c is U+005C (\)
…ならば: ◎ then:
- ~IF[ %~atmark~flag ~EQ ~ON ]~AND[ %~buffer ~EQ 空~文字列 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If @ flag is set and buffer is the empty string, validation error, return failure.
- %~pointer ~DECBY %~buffer に含まれる~cpの個数 ~PLUS 1 ◎ Decrease pointer by the number of code points in buffer plus one,\
- %~buffer ~SET 空~文字列 ◎ set buffer to the empty string, and\
- %state ~SET `~host$st ◎ set state to host state.
- ~ELSE ⇒ %~buffer ~APPEND `C$V ◎ Otherwise, append c to buffer.
-
- `~host@st
- `~hostname@st
-
- ~IF[ %上書state ~NEQ ε ]~AND[ %url の`~scheme$url ~EQ `file^l ] ⇒# %~pointer ~DECBY 1; %state ~SET `~file~host$st ◎ If state override is given and url’s scheme is "file", then decrease pointer by one and set state to file host state.
-
~ELIF[ `C$V ~EQ ❝: ]~AND[ %~brackets~flag ~EQ ~OFF ]: ◎ Otherwise, if c is U+003A (:) and the [] flag is unset, then:
- ~IF[ %~buffer ~EQ 空~文字列 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If buffer is the empty string, validation error, return failure.
- %~host ~LET `~host構文解析器$( %~buffer, `特別でない?$( %url ) ) ◎ Let host be the result of host parsing buffer with url is not special.
- ~IF[ %~host ~EQ `失敗^i ] ⇒ ~RET `失敗^i ◎ If host is failure, then return failure.
- %url の`~host$url ~SET %~host ◎ Set url’s host to host, buffer to the empty string, and state to port state.
- ~IF[ %上書state ~EQ `~hostname$st ] ⇒ ~RET ◎ If state override is given and state override is hostname state, then return.
- %~buffer ~SET 空~文字列 ◎ ↑
- %state ~SET `~port$st ◎ ↑
-
~ELIF[ 次のいずれかが満たされる ]…: ◎ Otherwise, if one of the following is true
- `C$V ~IN { `EOF$i, ❝/, ❝?, ❝# } ◎ c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
- [ %url は`特別$である ]~AND[ `C$V ~EQ ❝\ ] ◎ url is special and c is U+005C (\)
…ならば: ◎ then decrease pointer by one, and then:
- %~pointer ~DECBY 1 ◎ ↑
- ~IF[ %url は`特別$である ]~AND[ %~buffer ~EQ 空~文字列 ] ⇒# `検証~error$; ~RET `失敗^i ◎ If url is special and buffer is the empty string, validation error, return failure.
- ~ELIF[ %上書state ~NEQ ε ]~AND[ %~buffer ~EQ 空~文字列 ]~AND[[ %url は`資格証明情報を含む$ ]~OR[ %url の`~port$url ~NEQ ~NULL ]] ⇒# `検証~error$; ~RET ◎ Otherwise, if state override is given, buffer is the empty string, and either url includes credentials or url’s port is non-null, validation error, return.
- %~host ~LET `~host構文解析器$( %~buffer, `特別でない?$( %url ) ) ◎ Let host be the result of host parsing buffer with url is not special.
- ~IF[ %~host ~EQ `失敗^i ] ⇒ ~RET `失敗^i ◎ If host is failure, then return failure.
- %url の`~host$url ~SET %~host ◎ Set url’s host to host, buffer to the empty string, and state to path start state.
- ~IF[ %上書state ~NEQ ε ] ⇒ ~RET ◎ If state override is given, then return.
- %~buffer ~SET 空~文字列 ◎ ↑
- %state ~SET `~path開始-$st ◎ ↑
-
~ELSE : ◎ Otherwise:
- ~IF[ `C$V ~EQ ❝[ ] ⇒ %~brackets~flag ~SET ~ON ◎ If c is U+005B ([), then set the [] flag.
- ~IF[ `C$V ~EQ ❝] ] ⇒ %~brackets~flag ~SET ~OFF ◎ If c is U+005D (]), then unset the [] flag.
- %~buffer ~APPEND `C$V ◎ Append c to buffer.
- `~port@st
-
- ~IF[ `C$V ~IN `~ASCII数字$ ] ⇒ %~buffer ~APPEND `C$V ◎ If c is an ASCII digit, append c to buffer.
-
~ELIF[ 次のいずれかが満たされる ]…: ◎ Otherwise, if one of the following is true
- `C$V ~IN { `EOF$i, ❝/, ❝?, ❝# } ◎ c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
- [ %url は`特別$である ]~AND[ `C$V ~EQ ❝\ ] ◎ url is special and c is U+005C (\)
- %上書state ~NEQ ε ◎ state override is given
…ならば: ◎ then:
-
~IF[ %~buffer ~NEQ 空~文字列 ]: ◎ If buffer is not the empty string, then:
- %~port ~LET %~buffer を[ その各 `~ASCII数字$を基数 10 による値 0 〜 9 と解釈した ]下で表現される,数学的な整数~値 ◎ Let port be the mathematical integer value that is represented by buffer in radix-10 using ASCII digits for digits with values 0 through 9.
- ~IF[ %~port ~GTE ( 2 の 16 乗 ) ] ⇒# `検証~error$; ~RET `失敗^i ◎ If port is greater than 216 − 1, validation error, return failure.
- %url の`~port$url ~SET[ %~port ~EQ %url の`~scheme$urlの`既定~port$ならば ~NULL / ~ELSE_ %~port ] ◎ Set url’s port to null, if port is url’s scheme’s default port, and to port otherwise.
- %~buffer ~SET 空~文字列 ◎ Set buffer to the empty string.
- ~IF[ %上書state ~NEQ ε ] ⇒ ~RET ◎ If state override is given, then return.
- %~pointer ~DECBY 1 ◎ ↓
- %state ~SET `~path開始-$st ◎ Set state to path start state, and decrease pointer by one.
- ~ELSE ⇒# `検証~error$; ~RET `失敗^i ◎ Otherwise, validation error, return failure.
- `~file@st
-
- %url の`~scheme$url ~SET `file^l ◎ Set url’s scheme to "file".
-
~IF[ `C$V ~IN { ❝/, ❝\ } ]: ◎ If c is U+002F (/) or U+005C (\), then:
- ~IF[ `C$V ~EQ ❝\ ] ⇒ `検証~error$ ◎ If c is U+005C (\), validation error.
- %state ~SET `~file~slash$st ◎ Set state to file slash state.
-
~ELIF[ %基底 ~NEQ ~NULL ]~AND[ %基底 の`~scheme$url ~EQ `file^l ]: ◎ Otherwise, if base is non-null and base’s scheme is "file",\
-
%D ~LET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ 並び[ `C$V, `C1$V, `C2$V ]は`~drive_letterから開始されて$いる
注記: これは~drive_letterのための(~platformに依存しない)過去互換対処である。
◎ ↓↓ - ~IF[ %D ~EQ ~F ] ⇒# %url の`~host$url ~SET %基底 の`~host$url; %url の`~path$url ~SET %基底 の`~path$urlの複製 ◎ ↓↓
-
`C$V に応じて: ◎ switch on c:
- `EOF$i ⇒ %url の`~query$url ~SET %基底 の`~query$url ◎ The EOF code point • Set url’s host to base’s host, url’s path to a copy of base’s path, and url’s query to base’s query.
- ❝? ⇒# %url の`~query$url ~SET 空~文字列; %state ~SET `~query$st ◎ U+003F (?) • Set url’s host to base’s host, url’s path to a copy of base’s path, url’s query to the empty string, and state to query state.
- ❝# ⇒# %url の`~query$url ~SET %基底 の`~query$url; %url の`素片$url ~SET 空~文字列; %state ~SET `素片$st ◎ U+0023 (#) • Set url’s host to base’s host, url’s path to a copy of base’s path, url’s query to base’s query, url’s fragment to the empty string, and state to fragment state.
-
その他: ◎ Otherwise
- ~IF[ %D ~EQ ~F ] ⇒ %url の`~pathを短縮する$ ◎ If the substring from pointer in input does not start with a Windows drive letter, then set url’s host to base’s host, url’s path to a copy of base’s path, and then shorten url’s path. This is a (platform-independent) Windows drive letter quirk.
- ~ELSE ⇒ `検証~error$ ◎ Otherwise, validation error.
- %~pointer ~DECBY 1; ◎ ↓
- %state ~SET `~path$st ◎ Set state to path state, and decrease pointer by one.
-
- ~ELSE ⇒# %~pointer ~DECBY 1; %state ~SET `~path$st ◎ Otherwise, set state to path state, and decrease pointer by one.
- `~file~slash@st
-
-
~IF[ `C$V ~IN { ❝/, ❝\ } ]: ◎ If c is U+002F (/) or U+005C (\), then:
- ~IF[ `C$V ~EQ ❝\ ] ⇒ `検証~error$ ◎ If c is U+005C (\), validation error.
- %state ~SET `~file~host$st ◎ Set state to file host state.
-
~ELSE : ◎ Otherwise:
-
~IF[ %基底 ~NEQ ~NULL ]~AND[ %基底 の`~scheme$url ~EQ `file^l ]~AND[ 並び[ `C$V, `C1$V, `C2$V ]は`~drive_letterから開始されて$いない ]: ◎ If base is non-null, base’s scheme is "file", and the substring from pointer in input does not start with a Windows drive letter, then:
-
~IF[[ %基底 の`~path$url[0] ]は `正規化-済み~drive_letter$である ] ⇒ %url の`~path$urlに[ %基底 の`~path$url[0] ]を付加する ◎ If base’s path[0] is a normalized Windows drive letter, then append base’s path[0] to url’s path.
注記: これは~drive_letterのための(~platformに依存しない)過去互換対処である。 この条件の下では、 %url, %基底 いずれの`~host$urlも~NULLであり、したがって,複製されない。 ◎ This is a (platform-independent) Windows drive letter quirk. Both url’s and base’s host are null under these conditions and therefore not copied.
- ~ELSE ⇒ %url の`~host$url ~SET %基底 の`~host$url ◎ Otherwise, set url’s host to base’s host.
-
- %~pointer ~DECBY 1 ◎ ↓
- %state ~SET `~path$st ◎ Set state to path state, and decrease pointer by one.
-
-
- `~file~host@st
-
-
~IF[ `C$V ~IN { `EOF$i, ❝/, ❝\, ❝?, ❝# } ]: ◎ If c is the EOF code point, U+002F (/), U+005C (\), U+003F (?), or U+0023 (#), then\
- %~pointer ~DECBY 1 ◎ decrease pointer by one and then:\
-
~IF[ %上書state ~EQ ε ]~AND[ %~buffer は`~drive_letter$である ] ⇒# `検証~error$; %state ~SET `~path$st ◎ If state override is not given and buffer is a Windows drive letter, validation error, set state to path state.
注記: これは~drive_letterのための(~platformに依存しない)過去互換対処である。 ここでは %~buffer は設定し直されず,代わりに`~path$stの中で利用される。 ◎ This is a (platform-independent) Windows drive letter quirk. buffer is not reset here and instead used in the path state.
-
~ELIF[ %~buffer ~EQ 空~文字列 ]: ◎ Otherwise, if buffer is the empty string, then:
- %url の`~host$url ~SET 空~文字列 ◎ Set url’s host to the empty string.
- ~IF[ %上書state ~NEQ ε ] ⇒ ~RET ◎ If state override is given, then return.
- %state ~SET `~path開始-$st ◎ Set state to path start state.
-
~ELSE : ◎ Otherwise, run these steps:
- %~host ~LET `~host構文解析器$( %~buffer, `特別でない?$( %url ) ) ◎ Let host be the result of host parsing buffer with url is not special.
- ~IF[ %~host ~EQ `失敗^i ] ⇒ ~RET `失敗^i ◎ If host is failure, then return failure.
- ~IF[ %~host ~EQ `localhost^l ] ⇒ %~host ~SET 空~文字列 ◎ If host is "localhost", then set host to the empty string.
- %url の`~host$url ~SET %~host ◎ Set url’s host to host.
- ~IF[ %上書state ~NEQ ε ] ⇒ ~RET ◎ If state override is given, then return.
- %~buffer ~SET 空~文字列 ◎ Set buffer to the empty string and\
- %state ~SET `~path開始-$st ◎ state to path start state.
- ~ELSE ⇒ %~buffer ~APPEND `C$V ◎ Otherwise, append c to buffer.
-
- `~path開始-@st
-
-
~IF[ %url は`特別$である ]: ◎ If url is special, then:
- ~IF[ `C$V ~EQ ❝\ ] ⇒ `検証~error$ ◎ If c is U+005C (\), validation error.
- ~IF[ `C$V ~NIN { ❝/, ❝\ } ] ⇒ %~pointer ~DECBY 1 ◎ Set state to path state. ◎ If c is neither U+002F (/) nor U+005C (\), then decrease pointer by one.
- %state ~SET `~path$st ◎ ↑
- ~ELIF[ %上書state ~EQ ε ]~AND[ `C$V ~EQ ❝? ] ⇒# %url の`~query$url ~SET 空~文字列; %state ~SET `~query$st ◎ Otherwise, if state override is not given and c is U+003F (?), set url’s query to the empty string and state to query state.
- ~ELIF[ %上書state ~EQ ε ]~AND[ `C$V ~EQ ❝# ] ⇒# %url の`素片$url ~SET 空~文字列; %state ~SET `素片$st ◎ Otherwise, if state override is not given and c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.
-
~ELIF[ `C$V ~NEQ `EOF$i ]: ◎ Otherwise, if c is not the EOF code point:
- ~IF[ `C$V ~NEQ ❝/ ] ⇒ %~pointer ~DECBY 1 ◎ Set state to path state. ◎ If c is not U+002F (/), then decrease pointer by one.
- %state ~SET `~path$st ◎ ↑
-
- `~path@st
-
- %~slash ~LET [ 次が満たされるならば ~T / ~ELSE_ ~F ] ⇒ [ `C$V ~EQ ❝/ ]~OR[[ %url は`特別$である ]~AND[ `C$V ~EQ ❝\ ]] ◎ ↓
-
~IF[ 次のいずれかが満たされる ]…: ◎ If one of the following is true
- `C$V ~EQ `EOF$i ◎ c is the EOF code point or U+002F (/) ↓
- %~slash ~EQ ~T ◎ url is special and c is U+005C (\)
- [ %上書state ~EQ ε ]~AND[ `C$V ~IN { ❝?, ❝# } ]: ◎ state override is not given and c is U+003F (?) or U+0023 (#)
…ならば: ◎ then:
- ~IF[ %url は`特別$である ]~AND[ `C$V ~EQ ❝\ ] ⇒ `検証~error$ ◎ If url is special and c is U+005C (\), validation error.
-
~IF[ %~buffer は`二重dot~path区分$である ]:
- %url の`~pathを短縮する$
- ~IF[ %~slash ~EQ ~F ] ⇒ %url の`~path$urlに空~文字列を`付加する$
- ~ELIF[ %~buffer は`単dot~path区分$である ] ⇒ ~IF[ %~slash ~EQ ~F ] ⇒ %url の`~path$urlに空~文字列を`付加する$ ◎ Otherwise, if buffer is a single-dot path segment and if neither c is U+002F (/), nor url is special and c is U+005C (\), append the empty string to url’s path.
-
~ELSE : ◎ Otherwise, if buffer is not a single-dot path segment, then:
-
~IF[ %url の`~scheme$url ~EQ `file^l ]~AND[ %url の`~path$urlは`空$である ]~AND[ %~buffer は`~drive_letter$である ]: ◎ If url’s scheme is "file", url’s path is empty, and buffer is a Windows drive letter, then:
- ~IF[ %url の`~host$url ~NIN { 空~文字列, ~NULL } ] ⇒# `検証~error$; %url の`~host$url ~SET 空~文字列 ◎ If url’s host is neither the empty string nor null, validation error, set url’s host to the empty string.
- %~buffer の 2 個目の~cpを ❝: に置換する ◎ Replace the second code point in buffer with U+003A (:).
注記: これは~drive_letterのための(~platformに依存しない)過去互換対処である。 ◎ This is a (platform-independent) Windows drive letter quirk.
- %url の`~path$urlに %~buffer を`付加する$ ◎ Append buffer to url’s path.
-
- %~buffer ~SET 空~文字列 ◎ Set buffer to the empty string.
- ~IF[ %url の`~scheme$url ~EQ `file^l ]~AND[ `C$V ~IN { `EOF$i, ❝?, ❝# } ] ⇒ ~WHILE[ %url の`~path$urlの`~size$ ~GT 1 ]~AND[ %url の`~path$url[0] ~EQ 空~文字列 ] ⇒# `検証~error$; %url の`~path$urlから最初の`~item$を`除去する$ ◎ If url’s scheme is "file" and c is the EOF code point, U+003F (?), or U+0023 (#), then while url’s path’s size is greater than 1 and url’s path[0] is the empty string, validation error, remove the first item from url’s path.
- ~IF[ `C$V ~EQ ❝? ] ⇒# %url の`~query$url ~SET 空~文字列; %state ~SET `~query$st ◎ If c is U+003F (?), then set url’s query to the empty string and state to query state.
- ~IF[ `C$V ~EQ ❝# ] ⇒# %url の`素片$url ~SET 空~文字列; %state ~SET `素片$st ◎ If c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
-
~ELSE : ◎ Otherwise, run these steps:
- `~URL単位かどうか検証する$ ◎ If c is not a URL code point and not U+0025 (%), validation error. ◎ If c is U+0025 (%) and remaining does not start with two ASCII hex digits, validation error.
- %~buffer ~APPEND `~UTF-8~percent-符号化する$( `~path~percent-符号化-集合$, `C$V ) ◎ UTF-8 percent encode c using the path percent-encode set, and append the result to buffer.
- `~cannot-be-a-base-URL~path@st
-
-
`C$V に応じて: ◎ ↓
- ❝? ⇒# %url の`~query$url ~SET 空~文字列; %state ~SET `~query$st ◎ If c is U+003F (?), then set url’s query to the empty string and state to query state.
- ❝# ⇒# %url の`素片$url ~SET 空~文字列; %state ~SET `素片$st ◎ Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
- `EOF$i ⇒ 何もしない ◎ ↓
-
~OTHER: ◎ Otherwise:
- `~URL単位かどうか検証する$ ◎ If c is not the EOF code point, not a URL code point, and not U+0025 (%), validation error. ◎ If c is U+0025 (%) and remaining does not start with two ASCII hex digits, validation error.
- %url の`~path$url[0] ~APPEND `~UTF-8~percent-符号化する$( `~C0制御文字~percent-符号化-集合$, `C$V ) ◎ If c is not the EOF code point, UTF-8 percent encode c using the C0 control percent-encode set, and append the result to url’s path[0].
-
- `~query@st
-
- ~IF[ %url は`特別$でない ]~OR[ %url の`~scheme$url ~IN { `ws^l, `wss^l } ] ⇒ %符号化法 ~SET `~UTF-8$ ◎ If encoding is not UTF-8 and one of the following is true • url is not special • url’s scheme is "ws" or "wss" ◎ then set encoding to UTF-8.
- ~IF[ %上書state ~EQ ε ]~AND[ `C$V ~EQ ❝# ] ⇒# %url の`素片$url ~SET 空~文字列; %state ~SET `素片$st ◎ If state override is not given and c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
-
~ELIF[ `C$V ~NEQ `EOF$i ]: ◎ Otherwise, if c is not the EOF code point:
- `~URL単位かどうか検証する$ ◎ If c is not a URL code point and not U+0025 (%), validation error. ◎ If c is U+0025 (%) and remaining does not start with two ASCII hex digits, validation error.
- %~byte列 ~LET `符号化法を用いて符号化する$( `C$V, %符号化法 ) ◎ Let bytes be the result of encoding c using encoding.
-
~IF[ %~byte列 の[ 1 個目, 2 個目, 最後 ]の~byte ~EQ 順に[ `26^X `&^smb, ❛#, ❛; ] ⇒ %url の`~query$urlに次の結果を付加する ⇒ `同型に復号する$( 次を順に連結した結果 ) ⇒# `%26%23^bl, %~byte列 から 1 個目, 2 個目, 最後の~byteを除去した結果, `%3B^bl ◎ If bytes starts with `&#` and ends with 0x3B (;), then: • Replace `&#` at the start of bytes with `%26%23`. • Replace 0x3B (;) at the end of bytes with `%3B`. • Append bytes, isomorphic decoded, to url’s query.
注記: これは、`~UTF-8$以外の`符号化法$を用いて~cpを符号化するときに起こり得る。 ◎ This can happen when encoding code points using a non-UTF-8 encoding.
-
~ELSE ⇒ %~byte列 内の ~EACH( %~byte ) に対し: ◎ Otherwise, for each byte in bytes:
- ~IF[ %~byte ~LT ❛! ]~OR[ %~byte ~GT ❛~ ]~OR[ %~byte ~IN { ❛", ❛#, `3C^X `<^smb, `3E^X `>^smb } ]~OR[[ %~byte ~EQ ❛' ]~AND[ %url は`特別$である ]] ⇒ %url の`~query$urlに次の結果を付加する ⇒ `~byteを文字列に~percent-符号化する$( %~byte ) ◎ If one of the following is true • byte is less than 0x21 (!) • byte is greater than 0x7E (~) • byte is 0x22 ("), 0x23 (#), 0x3C (<), or 0x3E (>) • byte is 0x27 (') and url is special ◎ then append byte, percent encoded, to url’s query.
- ~ELSE ⇒ %url の`~query$urlに %~byte を値とする~cpを付加する ◎ Otherwise, append a code point whose value is byte to url’s query.
- `素片@st
-
-
`C$V に応じて: ◎ Switching on c:
- `EOF$i ⇒ 何もしない ◎ The EOF code point • Do nothing.
- `0000^U NULL ⇒ `検証~error$ ◎ U+0000 NULL • Validation error.
-
~OTHER: ◎ Otherwise
- `~URL単位かどうか検証する$ ◎ If c is not a URL code point and not U+0025 (%), validation error. ◎ If c is U+0025 (%) and remaining does not start with two ASCII hex digits, validation error.
- %url の`素片$url ~APPEND `~UTF-8~percent-符号化する$( `素片~percent-符号化-集合$, `C$V ) ◎ UTF-8 percent encode c using the fragment percent-encode set and append the result to url’s fragment.
-
◎ ↑↑Return url.
`~URLの~usernameを設定する@ ときは、所与の ( `~URL$ %url, 文字列 %~username ) に対し,次を走らす: ◎ To set the username given a url and username, run these steps:
- %url の`~username$url ~SET 空~文字列 ◎ Set url’s username to the empty string.
- %~username 内の ~EACH( ~cp %C ) に対し ⇒ %url の`~username$url ~APPEND `~UTF-8~percent-符号化する$( `~userinfo~percent-符号化-集合$, %C ) ◎ For each code point in username, UTF-8 percent encode it using the userinfo percent-encode set, and append the result to url’s username.
`~URLの~passwordを設定する@ ときは、所与の ( `~URL$ %url, 文字列 %~username ) に対し,次を走らす: ◎ To set the password given a url and password, run these steps:
- %url の`~password$url ~SET 空~文字列 ◎ Set url’s password to the empty string.
- %~password 内の ~EACH( ~cp %C ) に対し ⇒ %url の`~password$url ~APPEND `~UTF-8~percent-符号化する$( `~userinfo~percent-符号化-集合$, %C ) ◎ For each code point in password, UTF-8 percent encode it using the userinfo percent-encode set, and append the result to url’s password.
4.5. ~URLの直列化-法
`~URL直列化器@ は、所与の ( `~URL$ %url, %素片は除外する~flag ~IN { `素片は除外する^i, ε }(省略時は ε ) ) に対し,次を走らす: ◎ The URL serializer takes a URL url, an optional exclude fragment flag, and then runs these steps:
- %出力 ~LET 空~文字列 ~APPEND %url の`~scheme$url ~APPEND ❝: ◎ Let output be url’s scheme and U+003A (:) concatenated.
-
~IF[ %url の`~host$url ~NEQ ~NULL ]: ◎ If url’s host is non-null:
- %出力 ~APPEND `//^l ◎ Append "//" to output.
-
~IF[ %url は`資格証明情報を含む$ ]: ◎ If url includes credentials, then:
- %出力 ~APPEND %url の`~username$url ◎ Append url’s username to output.
- ~IF[ %url の`~password$url ~NEQ 空~文字列 ] ⇒ %出力 ~APPEND ❝: ~APPEND %url の`~password$url ◎ If url’s password is not the empty string, then append U+003A (:), followed by url’s password, to output.
- %出力 ~APPEND ❝@ ◎ Append U+0040 (@) to output.
- %出力 ~APPEND `~hostを直列化する$( %url の`~host$url ) ◎ Append url’s host, serialized, to output.
- ~IF[ %url の`~port$url ~NEQ ~NULL ] ⇒ %出力 ~APPEND ❝: ~APPEND `整数を直列化する$( %url の`~port$url ) ◎ If url’s port is non-null, append U+003A (:) followed by url’s port, serialized, to output.
- ~ELIF[ %url の`~host$url ~EQ ~NULL ]~AND[ %url の`~scheme$url ~EQ `file^l ] ⇒ %出力 ~APPEND `//^l ◎ Otherwise, if url’s host is null and url’s scheme is "file", append "//" to output.
- ~IF[ %url の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ] ⇒ %出力 ~APPEND %url の`~path$url[0] ◎ If url’s cannot-be-a-base-URL flag is set, append url’s path[0] to output.
- ~ELSE ⇒ %url の`~path$url内の ~EACH( %文字列 ) に対し ⇒ %出力 ~APPEND ❝/ ~APPEND %文字列 ◎ Otherwise, then for each string in url’s path, append U+002F (/) followed by the string to output.
- ~IF[ %url の`~query$url ~NEQ ~NULL ] ⇒ %出力 ~APPEND ❝? ~APPEND %url の`~query$url ◎ If url’s query is non-null, append U+003F (?), followed by url’s query, to output.
- ~IF[ %素片は除外する~flag ~EQ ε ]~AND[ %url の`素片$url ~NEQ ~NULL ] ⇒ %出力 ~APPEND ❝# ~APPEND %url の`素片$url ◎ If the exclude fragment flag is unset and url’s fragment is non-null, append U+0023 (#), followed by url’s fragment, to output.
- ~RET %出力 ◎ Return output.
4.6. ~URLの等価性
2 つの`~URL$[ %A, %B ]は、次が満たされるならば,所与の ( %素片は除外する~flag ~IN { `素片は除外する^i, ε }(省略時は ε ) ) の下で `同等@ とされる ⇒ `~URLを直列化する$( %A, %素片除外~flag ) ~EQ `~URLを直列化する$( %B, %素片除外~flag ) ◎ To determine whether a URL A equals B, optionally with an exclude fragments flag, run these steps: ◎ • Let serializedA be the result of serializing A, with the exclude fragment flag set if the exclude fragments flag is set. ◎ • Let serializedB be the result of serializing B, with the exclude fragment flag set if the exclude fragments flag is set. ◎ • Return true if serializedA is serializedB, and false otherwise.
4.7. 生成元
注記: 必要な背景情報については,~HTMLによる`生成元$の定義を見よ。 `HTML$r ◎ See origin’s definition in HTML for the necessary background information. [HTML]
`~URL$ %~URL の `生成元@url は、 %~URL の`~scheme$urlに応じて,次を走らせて得られる`生成元$である: ◎ A URL’s origin is the origin returned by running these steps, switching on URL’s scheme:
- `blob^l
-
- %url ~LET [ %~URL の`~path$url[0] ]を`基本~URL構文解析器$にかけた結果 ◎ Let url be the result of parsing URL’s path[0].
- ~RET [ %url ~EQ `失敗^i ならば 新たな`不透明な生成元$ / ~ELSE_ %url の`生成元$url ] ◎ Return a new opaque origin, if url is failure, and url’s origin otherwise.
- `blob:https://whatwg.org/d0360e2f-caee-469f-9a2f-87d5b0456f6f^l の`生成元$urlは、成分組 ( `https^c, `whatwg.org^c, ~NULL, ~NULL ) になる。 ◎ The origin of blob:https://whatwg.org/d0360e2f-caee-469f-9a2f-87d5b0456f6f is the tuple (https, whatwg.org, null, null).
- `ftp^l
- `gopher^l
- `http^l
- `https^l
- `ws^l
- `wss^l
- ~RET 新たな`成分組~生成元$( %~URL の`~scheme$url, %~URL の`~host$url, %~URL の`~port$url, ~NULL ) ◎ Return a tuple consisting of URL’s scheme, URL’s host, URL’s port, and null.
- `file^l
- あいにく、これについては,実装に委ねられる。 疑わしい場合は 新たな`不透明な生成元$を返すこと。 ◎ Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.
- ~OTHER
-
~RET 新たな`不透明な生成元$ ◎ Return a new opaque origin.
注記: これは~~実際に、この種の`~URL$は,自身と`同一生成元$になり得ないことを意味する。 【毎回,異なる結果が返されるので。】 ◎ This does indeed mean that these URLs cannot be same-origin with themselves.
4.8. ~URLの描画-法
`~URL$の描画に際しては、`~URL直列化器$にかけた形に,以下の改変を加えるべきである: ◎ A URL should be rendered in its serialized form, with these modifications:
- `~URL$の `~username$url, `~password$urlは、`~URL$の`~host$urlに~~誤認され易いので描画されるべきでない。 例えば, https://examplecorp.com@attacker.example/ 。 ◎ A URL’s username and password should not be rendered as they can be mistaken for a URL’s host. E.g., consider https://examplecorp.com@attacker.example/.
- `~URL$の`~host$urlは、`~domainを~Unicode化する$を用いて描画されるべきである。 ◎ A URL’s host should be rendered using domain to Unicode.
- `~URL$の他の部分における`~percent-符号化された~byte$並びは、それを`~percent-復号-$した結果の~byte列による~cpに置換されるべきである — その結果が不可視になる場合は除いて。 ◎ Other parts of the URL should have their sequences of percent-encoded bytes replaced with code points resulting from percent decoding those sequences converted to bytes, unless that renders those sequences invisible.
【 “描画( `rendering^en )” の原義には、音声化なども含まれる — その場合の取り扱いは多少異なるものになるであろうが,同様の趣旨に従うことになる。 】
双方向的~textの目的においては、左横書き埋め込み( `left-to-right embedding^en )であったかのように描画されるべきである。 `BIDI$r ◎ For the purposes of bidirectional text it should be rendered as if it were in a left-to-right embedding. [BIDI]
あいにく、描画された`~URL$は,どこにでも現れるような文字列であり、描画される`~URL$に特有の双方向的~algoがあっても,広範に採用される見込みは薄いであろう。 双方向的~textによる~URLの各部への~~作用は、ここでの~modelと異なる描画にさせ得る。 したがって,双方向的~言語の利用者は、特に,素の~text環境の下では,このことについて予期しておくよう注意されたし。 ◎ Unfortunately, as rendered URLs are strings and can appear anywhere, a specific bidirectional algorithm for rendered URLs would not see wide adoption. Bidirectional text interacts with the parts of a URL in ways that can cause the rendering to be different from the model. Users of bidirectional languages are thus cautioned that this is to be expected, particularly in plain text environments.
双方向的~textにおいては、`~URL$の`~host$urlと`~path$urlが,誤認され易くなる。 そのため,~browserには、利用者が この 2 つを判別できることが重要になる所では, `~URL$の`~host$urlのみを描画することが奨励される。 例えば利用者は、~address~bar内に描画された`~URL$の`~host$urlに基いて,信用に関する裁定を下すものと予期されるので。 ◎ Due to the confusion that can arise between a URL’s host and path with bidirectional text, browsers are encouraged to only render a URL’s host in places where it is important for users to distinguish between the two. E.g., users are expected to make trust decisions based on a URL’s host rendered in the address bar.
5. ~form_urlencoded
`~form_urlencoded形式@ は、一連の名値~組を符号化する仕方を供する。 ◎ The application/x-www-form-urlencoded format provides a way to encode name-value pairs.
注記: ~form_urlencoded形式は、何年にもわたる実装の不幸な巡り合わせの結果,多くの面で奇異なものになっており、相互運用性のために必要とされる要件の集合からなる,妥協の産物である — 良い設計の実施を表現する仕方は無い。 読者は特に、文字~符号化法と~byte列との間で繰り返される(場合によっては入子にされた)変換のひねくれた詳細に,注意を払うように。 あいにく,この形式は~HTML~formに普及しているがため、広く利用されている。 `HTML$r ◎ The application/x-www-form-urlencoded format is in many ways an aberrant monstrosity, the result of many years of implementation accidents and compromises leading to a set of requirements necessary for interoperability, but in no way representing good design practices. In particular, readers are cautioned to pay close attention to the twisted details involving repeated (and in some cases nested) conversions between character encodings and byte sequences. Unfortunately the format is in widespread use due to the prevalence of HTML forms. [HTML]
5.1. ~form_urlencoded構文解析-法
注記: 旧来の~server向け実装には、`~UTF-8$以外の`符号化法$を~supportするとともに[ 名 ~EQ `_charset^bl ]なる組に対する特別な~logicを伴うものもある。 そのような~logicは、ここでは述べられない — 適合するのは`~UTF-8$に限られる。 ◎ A legacy server-oriented implementation might have to support encodings other than UTF-8 as well as have special logic for tuples of which the name is `_charset`. Such logic is not described here as only UTF-8 is conforming.
`~form_urlencoded構文解析器@ は、所与の ( ~byte列 %入力 ) に対し,次を走らす: ◎ The application/x-www-form-urlencoded parser takes a byte sequence input, and then runs these steps:
- %~byte列~list ~LET %入力 を `26^X `&^smb で分割した結果 ◎ Let sequences be the result of splitting input on 0x26 (&).
- %出力 ~LET 空`~list$(名, 値のいずれも文字列であるような,名値~組からなる~list) ◎ Let output be an initially empty list of name-value tuples where both name and value hold a string.
-
%~byte列~list 内の ~EACH( %~byte列 ) に対し: ◎ For each byte sequence bytes in sequences:
- ~IF[ %~byte列 ~EQ 空~byte列 ] ⇒ ~CONTINUE ◎ If bytes is the empty byte sequence, then continue.
- ( %名, %値 ) ~LET ( %~byte列, 空~byte列 ) ◎ ↓
- ~IF[ %~byte列 内に ❛= がある ] ⇒ ( %名, %値 ) ~SET %~byte列 を最初の ❛= の所で 2 個の~byte列に分割した結果(その最初の ❛= は結果に含めない — したがって,いずれも空~byte列になり得る) ◎ If bytes contains a 0x3D (=), then let name be the bytes from the start of bytes up to but excluding its first 0x3D (=), and let value be the bytes, if any, after the first 0x3D (=) up to the end of bytes. If 0x3D (=) is the first byte, then name will be the empty byte sequence. If it is the last, then value will be the empty byte sequence. ◎ Otherwise, let name have the value of bytes and let value be the empty byte sequence.
- [ %名, %値 ]内のすべての ❛+ を `20^X (SP) に置換する ◎ Replace any 0x2B (+) in name and value with 0x20 (SP).
- %名~文字列 ~LET `~BOMはそのままに~UTF-8復号する$( `~byte列を~byte列に~percent-復号する$( %名 ) ) ◎ ↓
- %値~文字列 ~LET `~BOMはそのままに~UTF-8復号する$( `~byte列を~byte列に~percent-復号する$( %値 ) ) ◎ Let nameString and valueString be the result of running UTF-8 decode without BOM on the percent decoding of name and value, respectively.
- %出力 に 組( %名~文字列, %値~文字列 ) を`付加する$ ◎ Append (nameString, valueString) to output.
- ~RET %出力 ◎ Return output.
5.2. ~form_urlencoded直列化-法
`~form_urlencoded~byte直列化器@ は、所与の ( ~byte列 %入力 ) に対し,次を走らす: ◎ The application/x-www-form-urlencoded byte serializer takes a byte sequence input and then runs these steps:
- %出力 ~LET 空~文字列 ◎ Let output be the empty string.
-
%入力 内の ~EACH( %~byte ) に対し ⇒ %出力 ~APPEND [ %~byte に応じて次で与えられる文字列 ]: ◎ For each byte in input, depending on byte:
- `20^X (SP)
- ❝+ ◎ Append U+002B (+) to output.
- ❛*
- ❛-
- ❛.
- ❛0 〜 ❛9
- ❛A 〜 ❛Z
- ❛_
- ❛a 〜 ❛z
- %~byte を値とする~cp ◎ Append a code point whose value is byte to output.
- ~OTHER
- `~byteを文字列に~percent-符号化する$( %~byte ) ◎ Append byte, percent encoded, to output.
- ~RET %出力 ◎ Return output.
`~form_urlencoded直列化器@ は、所与の ( 一連の[名値~組]からなる~list %組~list, `符号化法$ %上書符号化法(省略時は ε ) ) に対し,次を走らす: ◎ The application/x-www-form-urlencoded serializer takes a list of name-value tuples tuples, optionally with an encoding encoding override, and then runs these steps:
- %符号化法 ~LET `~UTF-8$ ◎ Let encoding be UTF-8.
- ~IF[ %上書符号化法 ~NEQ ε ] ⇒ %符号化法 ~SET `符号化法から出力~符号化法を取得する$( %上書符号化法 ) ◎ If encoding override is given, set encoding to the result of getting an output encoding from encoding override.
- %出力 ~LET 空~文字列 ◎ Let output be the empty string.
-
%組~list 内の ~EACH( %組 ) に対し: ◎ For each tuple in tuples:
- %名 ~LET `~form_urlencoded~byte直列化器$( `符号化法を用いて符号化する$( %符号化法, %組 の名 ) ) ◎ Let name be the result of serializing the result of encoding tuple’s name, using encoding.
- %値 ~LET %組 の値 ◎ Let value be tuple’s value.
- ~IF[ %値 は~fileである ] ⇒ %値 ~SET %値 の~filename成分 ◎ If value is a file, then set value to value’s filename.
- %値 ~SET `~form_urlencoded~byte直列化器$( `符号化法を用いて符号化する$( %符号化法, %値 ) ) ◎ Set value to the result of serializing the result of encoding value, using encoding.
- ~IF[ %組 は %組~list 内の最初の組でない ] ⇒ %出力 ~APPEND `0026^U `&^smb ◎ If tuple is not the first pair in tuples, then append U+0026 (&) to output.
- %出力 ~APPEND %名 ~APPEND ❝= ~APPEND %値 ◎ Append name, followed by U+003D (=), followed by value, to output.
- ~RET %出力 ◎ Return output.
注記: `HTML$r は、組の値に~fileを伴う~listで この~algoを呼出す。 ◎ The HTML standard invokes this algorithm with values that are files. [HTML]
5.3. ~hooks
`~form_urlencoded文字列~構文解析器@ は、所与の ( 文字列 %入力 ) に対し,次の結果を返す ⇒ `~form_urlencoded構文解析器$( `~UTF-8符号化する$( %入力 ) ) ◎ The application/x-www-form-urlencoded string parser takes a string input, UTF-8 encodes it, and then returns the result of application/x-www-form-urlencoded parsing it.
6. ~API
6.1. `URL^I ~class
[Constructor(`USVString$ %url, optional `USVString$ %base), `Exposed$=(Window,Worker), `LegacyWindowAlias$=`webkitURL@] interface `URL@I { `stringifier@m attribute `USVString$ `href$m; readonly attribute `USVString$ `origin$m; attribute `USVString$ `protocol$m; attribute `USVString$ `username$m; attribute `USVString$ `password$m; attribute `USVString$ `host$m; attribute `USVString$ `hostname$m; attribute `USVString$ `port$m; attribute `USVString$ `pathname$m; attribute `USVString$ `search$m; [`SameObject$] readonly attribute `URLSearchParams$I `searchParams$m; attribute `USVString$ `hash$m; `USVString$ `toJSON$m(); };
各 `URL$I ~objには、次のものが結付けられる: ◎ ↓
- `~url@url
- `~URL$
- `~query~obj@url
- `URLSearchParams$I ~obj
`URL(url, base)@m 構築子の被呼出時には、次を走らせ~MUST: ◎ The URL(url, base) constructor, when invoked, must run these steps:
- %解析済み基底 ~LET ~NULL ◎ Let parsedBase be null.
-
~IF[ %base は与えられている ]: ◎ If base is given, then:
- %解析済み基底 ~SET %base を`基本~URL構文解析器$にかけた結果 ◎ Let parsedBase be the result of running the basic URL parser on base.
- ~IF[ %解析済み基底 ~EQ `失敗^i ] ⇒ ~THROW `TypeError$E ◎ If parsedBase is failure, then throw a TypeError.
- %解析済み~URL ~LET 次を与える下で, %url を`基本~URL構文解析器$にかけた結果 ⇒ `基底~URL$ : %解析済み基底 ◎ Let parsedURL be the result of running the basic URL parser on url with parsedBase.
- ~IF[ %解析済み~URL ~EQ `失敗^i ] ⇒ ~THROW `TypeError$E ◎ If parsedURL is failure, then throw a TypeError.
- %~query ~LET [ %解析済み~URL の `~query$url ~NEQ ~NULL ならば それ / ~ELSE_ 空~文字列 ] ◎ Let query be parsedURL’s query, if that is non-null, and the empty string otherwise.
- %結果 ~LET 新たな `URL$I ~obj ◎ Let result be a new URL object.
- %結果 の`~url$url ~SET %解析済み~URL ◎ Set result’s url to parsedURL.
- %~obj ~SET `新たな~URLSearchParams~obj$( %~query ) ◎ ↓
- %結果 の`~query~obj$url ~SET %~obj ◎ ↓
- %~obj の`~url~obj$ ~SET %結果 ◎ Set result’s query object to a new URLSearchParams object using query, and then set that query object’s url object to result.
- ~RET %結果 ◎ Return result.
`基底~URL$を用いずに,文字列を構文解析して `~URL$を得るときは、単独の引数で `URL$I 構築子を呼び出す: ◎ To parse a string into a URL without using a base URL, invoke the URL constructor with a single argument:
var %input = `https://example.org/💩^l, %url = new URL(%input); %url.pathname; // `/%F0%9F%92%A9^l
次のものは、入力が`素片~付き絶対~URL$sTでない場合には,例外を投出する: ◎ This throws an exception if the input is not an absolute-URL-with-fragment string:
try {
var %url = new URL(`/🍣🍺^l);
} catch(%e) {
// ここに来る
}
入力が`相対~URL$sTの場合には、`基底~URL$が必要とされる: ◎ A base URL is necessary if the input is a relative-URL string:
var %input = `/🍣🍺^l, %url = new URL(%input, document.baseURI); %url.href; // `https://url.spec.whatwg.org/%F0%9F%8D%A3%F0%9F%8D%BA^l
`URL$I ~objは`基底~URL$として利用できる(~IDLからは文字列を引数にとるよう要求されるが、 `URL$I ~objは,その `href$m 属性~値に文字列化される): ◎ A URL object can be used as base URL (while IDL requires a string as argument, a URL object stringifies to its href attribute value):
var %url = new URL(`🏳🌈^l, new URL(`https://pride.example/hello-world^l)) %url.pathname // `/%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88^l
- `toJSON()@m
- 被呼出時には、此れの `href$m の取得子と同じ結果を返さ~MUST。 ◎ ↓
- `href@m
-
取得子は、次を走らせ~MUST: ◎
- ~RET `~URLを直列化する$( 此れの`~url$url )
-
設定子は、次を走らせ~MUST: ◎ The href attribute’s setter must run these steps:
- %解析済み~URL ~LET 所与の値を`基本~URL構文解析器$にかけた結果 ◎ Let parsedURL be the result of running the basic URL parser on the given value.
- ~IF[ %解析済み~URL ~EQ `失敗^i ] ⇒ ~THROW `TypeError$E ◎ If parsedURL is failure, then throw a TypeError.
- 此れの`~url$url ~SET %解析済み~URL ◎ Set context object’s url to parsedURL.
- 此れの`~query~obj$urlの`名値~組~list$を空にする ◎ Empty context object’s query object’s list.
- %~query ~LET 此れの`~url$urlの`~query$url ◎ Let query be context object’s url’s query.
- ~IF[ %~query ~NEQ ~NULL ] ⇒ 此れの`~query~obj$urlの`名値~組~list$ ~SET `~form_urlencoded文字列~構文解析器$( %~query ) ◎ If query is non-null, then set context object’s query object’s list to the result of parsing query.
- `origin@m
-
取得子は、次を走らせ~MUST:
- ~RET `生成元を直列化する$( 此れの`~url$urlの`生成元$url ) `HTML$r
- `protocol@m
-
取得子は、次を走らせ~MUST:
- ~RET 空~文字列 ~APPEND 此れの`~url$urlの`~scheme$url ~APPEND ❝:
-
設定子は、次を走らせ~MUST:
- 次を与える下で,[ 所与の値 ~APPEND ❝: ]を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( 此れの`~url$url, `~scheme開始-$st )
- `username@m
-
取得子は、次を走らせ~MUST:
- ~RET 此れの`~url$urlの`~username$url
-
設定子は、次を走らせ~MUST: ◎ The username attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url は`~username/~password/~portを持てない$ ] ⇒ ~RET ◎ If context object’s url cannot have a username/password/port, then return.
- `~URLの~usernameを設定する$( %url, 所与の値 ) ◎ Set the username given context object’s url and the given value.
- `password@m
-
取得子は、次を走らせ~MUST:
- ~RET 此れの`~url$urlの`~password$url
-
設定子は、次を走らせ~MUST: ◎ The password attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url は`~username/~password/~portを持てない$ ] ⇒ ~RET ◎ If context object’s url cannot have a username/password/port, then return.
- `~URLの~passwordを設定する$( %url, 所与の値 ) ◎ Set the password given context object’s url and the given value.
- `host@m
-
取得子は、次を走らせ~MUST: ◎ The host attribute’s getter must run these steps:
- %url ~LET 此れの`~url$url ◎ Let url be context object’s url.
- ~IF[ %url の`~host$url ~EQ ~NULL ] ⇒ ~RET 空~文字列 ◎ If url’s host is null, return the empty string.
- %~host ~LET `~hostを直列化する$( `~host$url ) ◎ ↓
- ~IF[ %url の`~port$url ~EQ ~NULL ] ⇒ ~RET %~host ◎ If url’s port is null, return url’s host, serialized.
- ~RET %~host ~APPEND ❝: ~APPEND `整数を直列化する$( `~port$url ) ◎ Return url’s host, serialized, followed by U+003A (:) and url’s port, serialized.
-
設定子は、次を走らせ~MUST: ◎ The host attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ] ⇒ ~RET ◎ If context object’s url’s cannot-be-a-base-URL flag is set, then return.
- 次を与える下で,所与の値を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( %url , `~host$st ) ◎ Basic URL parse the given value with context object’s url as url and host state as state override.
- 注記: `host$m 属性の設定子に与える値が,`~URL~port$sTを欠いている場合、 %url の`~port$urlは変化しないことになる。 `host^c 属性の取得子が`~URL~port$sTを返さないために、設定子が常に両者を “設定し直す” と見做してしまいそうだが。 ◎ If the given value for the host attribute’s setter lacks a port, context object’s url’s port will not change. This can be unexpected as host attribute’s getter does return a URL-port string so one might have assumed the setter to always "reset" both.
- `hostname@m
-
取得子は、次を走らせ~MUST: ◎ The hostname attribute’s getter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~host$url ~EQ ~NULL ] ⇒ ~RET 空~文字列 ◎ If context object’s url’s host is null, return the empty string.
- ~RET `~hostを直列化する$( %url の`~host$url ) ◎ Return context object’s url’s host, serialized.
-
設定子は、次を走らせ~MUST: ◎ The hostname attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ] ⇒ ~RET ◎ If context object’s url’s cannot-be-a-base-URL flag is set, then return.
- 次を与える下で,所与の値を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( %url , `~hostname$st ) ◎ Basic URL parse the given value with context object’s url as url and hostname state as state override.
- `port@m
-
取得子は、次を走らせ~MUST: ◎ The port attribute’s getter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~port$url ~EQ ~NULL ] ⇒ ~RET 空~文字列 ◎ If context object’s url’s port is null, return the empty string.
- ~RET `整数を直列化する$( %url の`~port$url ) ◎ Return context object’s url’s port, serialized.
-
設定子は、次を走らせ~MUST: ◎ The port attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url は`~username/~password/~portを持てない$ ] ⇒ ~RET ◎ If context object’s url cannot have a username/password/port, then return.
- ~IF[ 所与の値 ~EQ 空~文字列 ] ⇒ %url の`~port$url ~SET ~NULL ◎ If the given value is the empty string, then set context object’s url’s port to null.
- ~ELSE ⇒ 次を与える下で,所与の値を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( %url , `~port$st ) ◎ Otherwise, basic URL parse the given value with context object’s url as url and port state as state override.
- `pathname@m
-
取得子は、次を走らせ~MUST: ◎ The pathname attribute’s getter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ] ⇒ ~RET[ %url の`~path$url[0] ] ◎ If context object’s url’s cannot-be-a-base-URL flag is set, then return context object’s url’s path[0].
- %結果 ~LET 空~文字列 ◎ If context object’s url’s path is empty, then return the empty string.
- %url の`~path$url内の ~EACH( %文字列 ) に対し ⇒ %結果 ~APPEND ❝/ ~APPEND %文字列 ◎ ↓
- ~RET %結果 ◎ Return U+002F (/), followed by the strings in context object’s url’s path (including empty strings), if any, separated from each other by U+002F (/).
-
設定子は、次を走らせ~MUST: ◎ The pathname attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~cannot-be-a-base-URL~flag$ ~EQ ~ON ] ⇒ ~RET ◎ If context object’s url’s cannot-be-a-base-URL flag is set, then return.
- %url の`~path$urlを空にする ◎ Empty context object’s url’s path.
- 次を与える下で,所与の値を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( %url , `~path開始-$st ) ◎ Basic URL parse the given value with context object’s url as url and path start state as state override.
- `search@m
-
取得子は、次を走らせ~MUST: ◎ The search attribute’s getter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`~query$url ~IN { ~NULL, 空~文字列 } ] ⇒ ~RET 空~文字列 ◎ If context object’s url’s query is either null or the empty string, return the empty string.
- ~RET [ ❝? ~APPEND %url の`~query$url ] ◎ Return U+003F (?), followed by context object’s url’s query.
-
設定子は、次を走らせ~MUST: ◎ The search attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ Let url be context object’s url.
- ~IF[ 所与の値 ~EQ 空~文字列 ] ⇒# %url の`~query$url ~SET ~NULL; 此れの`~query~obj$urlの`名値~組~list$を空にする; ~RET ◎ If the given value is the empty string, set url’s query to null, empty context object’s query object’s list, and then return.
- %入力 ~LET 所与の値 — ただし,先頭 1 個の ❝? は(もし在れば)除去する ◎ Let input be the given value with a single leading U+003F (?) removed, if any.
- %url の`~query$url ~SET 空~文字列 ◎ Set url’s query to the empty string.
- 次を与える下で, %入力 を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( %url, `~query$st ) ◎ Basic URL parse input with url as url and query state as state override.
- 此れの`~query~obj$urlの`名値~組~list$ ~SET `~form_urlencoded文字列~構文解析器$( %入力 ) ◎ Set context object’s query object’s list to the result of parsing input.
- `searchParams@m
-
取得子は、次を走らせ~MUST:
- ~RET 此れの`~query~obj$url
- `hash@m
-
取得子は、次を走らせ~MUST: ◎ The hash attribute’s getter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- ~IF[ %url の`素片$url ~IN { ~NULL, 空~文字列 } ] ⇒ ~RET 空~文字列 ◎ If context object’s url’s fragment is either null or the empty string, return the empty string.
- ~RET [ ❝# ~APPEND %url の`素片$url ] ◎ Return U+0023 (#), followed by context object’s url’s fragment.
-
設定子は、次を走らせ~MUST: ◎ The hash attribute’s setter must run these steps:
- %url ~LET 此れの`~url$url ◎ ↓
- %入力 ~LET 所与の値 ◎ ↓
- ~IF[ %入力 ~EQ 空~文字列 ] ⇒# %url の`素片$url ~SET ~NULL; ~RET ◎ If the given value is the empty string, then set context object’s url’s fragment to null and return.
- ~IF[ %入力 の先頭の文字 ~EQ ❝# ] ⇒ %入力 から先頭の文字を除去する ◎ Let input be the given value with a single leading U+0023 (#) removed, if any.
- %url の`素片$url ~SET 空~文字列 ◎ Set context object’s url’s fragment to the empty string.
- 次を与える下で, %入力 を`基本~URL構文解析器$にかける ⇒ `~URL$と上書stateの組: ( %url , `素片$st ) ◎ Basic URL parse input with context object’s url as url and fragment state as state override.
6.2. `URLSearchParams^I ~class
[Constructor(optional (`sequence$<`sequence$<`USVString$>> or `record$<`USVString$, `USVString$> or `USVString$) %init = ""), `Exposed$=(Window,Worker)] interface `URLSearchParams@I { void `append$m(`USVString$ %name, `USVString$ %value); void `delete$m(`USVString$ %name); `USVString$? `get$m(`USVString$ %name); `sequence$<`USVString$> `getAll$m(`USVString$ %name); `boolean$ `has$m(`USVString$ %name); void `set$m(`USVString$ %name, `USVString$ %value); void `sort$m(); iterable<`USVString$, `USVString$>; `stringifier$m; };
`URLSearchParams$I ~objを構築する/文字列化するのは、簡単である: ◎ Constructing and stringifying a URLSearchParams object is fairly straightforward:
let %params = new URLSearchParams({key: "730d67"}) %params.toString() // `key=730d67^l
各 `URLSearchParams$I ~objには、次のものが結付けられる: ◎ ↓
- `名値~組~list@
- 0 個以上の名値~組からなる~list(初期~時は空) ◎ A URLSearchParams object has an associated list of name-value pairs, which is initially empty.
- `~url~obj@
- (初期~時は ~NULL ) ◎ A URLSearchParams object has an associated url object, which is initially null.
`新たな~URLSearchParams~obj@ を作成するときは、所与の ( %init ) に対し,次を走らす: ◎ To create a new URLSearchParams object using init, run these steps:
- %~query ~LET 新たな `URLSearchParams$I ~obj ◎ Let query be a new URLSearchParams object.
-
~IF[ %init は`連列~型$である ]: ◎ If init is a sequence, then\
-
%init 内の ~EACH( %組 ) に対し: ◎ for each pair in init:
- ~IF[ %組 内の~itemの個数 ~NEQ 2 ] ⇒ ~THROW `TypeError$E ◎ If pair does not contain exactly two items, then throw a TypeError.
- %~query の`名値~組~list$に,新たな 組( %組 内の 1 個目の~item, %組 内の 2 個目の~item ) を付加する ◎ Append a new name-value pair whose name is pair’s first item, and value is pair’s second item, to query’s list.
-
- ~ELIF[ %init は`~record型$である ] ⇒ %init 内の ~EACH( %名 → %値 ) に対し ⇒ %~query の`名値~組~list$に,新たな 組( %名, %値 ) を付加する ◎ Otherwise, if init is a record, then for each name → value in init, append a new name-value pair whose name is name and value is value, to query’s list.
- ~ELIF[ %init は文字列である ] ⇒ %~query の`名値~組~list$ ~SET `~form_urlencoded文字列~構文解析器$( %init ) ◎ Otherwise, init is a string, then set query’s list to the result of parsing init.
- ~RET %~query ◎ Return query.
`URLSearchParams$I ~obj %O の `更新~手続き@ は、次を走らす: ◎ A URLSearchParams object’s update steps are to run these steps:
- %~query ~LET `~form_urlencoded直列化器$( %O の`名値~組~list$ ) ◎ Let query be the serialization of URLSearchParams object’s list.
- %O の`~url~obj$の`~url$urlの`~query$url ~SET[ %~query ~EQ 空~文字列 ならば ~NULL / ~ELSE_ %~query ] ◎ If query is the empty string, then set query to null. ◎ Set url object’s url’s query to query.
- `URLSearchParams(init)@m
-
この構築子の被呼出時には、次を走らせ~MUST: ◎ The URLSearchParams(init) constructor, when invoked, must run these steps:
- ~IF[ %init の最初の~cp ~EQ ❝? ] ⇒ %init から最初の~cpを除去する ◎ If init is a string and starts with U+003F (?), remove the first code point from init.
- ~RET `新たな~URLSearchParams~obj$( %init ) ◎ Return a new URLSearchParams object using init.
- `append(name, value)@m
-
被呼出時には、次を走らせ~MUST: ◎ The append(name, value) method, when invoked, must run these steps:
- 此れの`名値~組~list$に,新たな組( %name, %value ) を付加する ◎ Append a new name-value pair whose name is name and value is value, to list.
- `更新~手続き$を走らす ◎ Run the update steps.
- `delete(name)@m
-
被呼出時には、次を走らせ~MUST: ◎ The delete(name) method, when invoked, must run these steps:
- 此れの`名値~組~list$から[ 名 ~EQ %name ]なるすべての組を除去する ◎ Remove all name-value pairs whose name is name from list.
- `更新~手続き$を走らす ◎ Run the update steps.
- `get(name)@m
-
被呼出時には、次を走らせ~MUST:
- ~RET 此れの`名値~組~list$内に[ 名 ~EQ %name ]なる組が[ 在れば それらのうちの最初の組の値 / 無ければ ~NULL ]
- `getAll(name)@m
-
被呼出時には、次を走らせ~MUST:
- ~RET 此れの`名値~組~list$内の[ 名 ~EQ %name ]なる組すべてからなる,~list順による`連列~型$の値(空にもなり得る)
- `has(name)@m
-
被呼出時には、次を走らせ~MUST:
- ~RET 此れの`名値~組~list$内に[ 名 ~EQ %name ]なる組が[ 在れば ~T / 無ければ ~F ]
- `set(name, value)@m
-
被呼出時には、次を走らせ~MUST: ◎ The set(name, value) method, when invoked, must run these steps:
- ~IF[ 此れの`名値~組~list$内に[ 名 ~EQ %name ]なる組が在る ] ⇒ それらのうちの ⇒# 最初の組の値 ~SET %value; 最初でない組はすべて此れの`名値~組~list$から除去する ◎ If there are any name-value pairs whose name is name, in list, set the value of the first such name-value pair to value and remove the others.
- ~ELSE ⇒ 此れの`名値~組~list$に,新たな組 ( %name, %value ) を付加する ◎ Otherwise, append a new name-value pair whose name is name and value is value, to list.
- `更新~手続き$を走らす ◎ Run the update steps.
`URLSearchParams$I ~obj内の名値~組を~sortすると有用になることもある — 特に,~cache-hit率を高めれる。 これは、 `sort()$m ~methodを呼出すことで達成できる: ◎ It can be useful to sort the name-value pairs in a URLSearchParams object, in particular to increase cache hits. This can be accomplished through invoking the sort() method:
const %url = new URL("https://example.org/?q=🏳️🌈&key=e1f7bc78"); %url.searchParams.sort(); %url.search; // `?key=e1f7bc78&q=%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88^l
例えば比較~目的など,元の入力を改めたくない場合は、新たな `URLSearchParams$I ~objを構築する: ◎ To avoid altering the original input, e.g., for comparison purposes, construct a new URLSearchParams object:
const %sorted = new URLSearchParams(%url.search) %sorted.sort()
- `sort()@m
-
被呼出時には、次を走らせ~MUST: ◎ The sort() method, when invoked, must run these steps:
-
此れの`名値~組~list$内の すべての組を,名で~sortする — ここで:
- 名の比較は符号単位に基づくとする。
- 名が等しい組どうしの順序は保全され~MUST。
- `更新~手続き$を走らす ◎ Run the update steps.
-
- `反復される値の~pair$
- 此れの`名値~組~list$で与えられ、その各 ( 名, 値 ) が,反復される値の ( key, value ) に対応するとする。 ◎ The value pairs to iterate over are the list name-value pairs with the key being the name and the value being the value.
- `stringifier@m
- `文字列化の挙動$は、次の結果を返さ~MUST ⇒ `~form_urlencoded直列化器$( 此れの`名値~組~list$ ) ◎ The stringification behavior must return the serialization of the URLSearchParams object’s list.
6.3. 他の仕様における~URL~API
`~URL$を公開する標準は、`~URL$を(内部的な`~URL$は`~URL直列化器$にかけるなどして)文字列として公開するべきである。 標準は、`URL$I ~objを用いて`~URL$を公開するべきでない。 `URL$I ~objは、`~URL$を操作するためにある。 ~IDLにおいては、 `USVString^I 型が利用されるべきである。 ◎ A standard that exposes URLs, should expose the URL as a string (by serializing an internal URL). A standard should not expose a URL using a URL object. URL objects are meant for URL manipulation. In IDL the USVString type should be used.
注記: より高次の観点からは、それらの値は,変異-不能な~data構造として公開されるものになる。 ◎ The higher-level notion here is that values are to be exposed as immutable data structures.
標準が,それが定義する特色機能に `URL^l という名前の変種を用いるものと裁定する場合、その種の特色機能には `url^l (すなわち,小文字, 末尾は “エル” )と命名するべきであり、 `URL^l, `URI^l, `IRI^l などの名前は用いられるべきでない。 しかしながら,その名前が複合的なものである場合は、大文字の `URL^l が好ましい — `newURL^l や `oldURL^l など。 ◎ If a standard decides to use a variant of the name "URL" for a feature it defines, it should name such a feature "url" (i.e., lowercase and with an "l" at the end). Names such as "URL", "URI", and "IRI" should not be used. However, if the name is a compound, "URL" (i.e., uppercase) is preferred, e.g., "newURL" and "oldURL".
注記: 適正な命名~例としては、~HTMLの `EventSource$I や `HashChangeEvent$I ~interfaceが挙げられる。 `HTML$r ◎ The EventSource and HashChangeEvent interfaces in HTML are examples of proper naming. [HTML]