1 |
|
2 |
*5. Normalization and Comparison
|
3 |
> Note: The structure and much of the material for this section is
|
4 |
taken from section 6 of [RFC3986]; the differences are due to the
|
5 |
specifics of IRIs.
|
6 |
|
7 |
この章の構造と大部分の内容は [[RFC 3968]] の6章から取りました。
|
8 |
違いは IRI 特有のことによります。
|
9 |
|
10 |
> One of the most common operations on IRIs is simple comparison:
|
11 |
Determining whether two IRIs are equivalent without using the IRIs or
|
12 |
the mapped URIs to access their respective resource(s). A comparison
|
13 |
is performed whenever a response cache is accessed, a browser checks
|
14 |
its history to color a link, or an XML parser processes tags within a
|
15 |
namespace. Extensive normalization prior to comparison of IRIs may
|
16 |
be used by spiders and indexing engines to prune a search space or
|
17 |
reduce duplication of request actions and response storage.
|
18 |
|
19 |
IRI にもっともよく行われる操作の一つに単純比較があります。
|
20 |
単純比較は、2つの IRI や写像した URI
|
21 |
をそれぞれの資源にアクセスせずに同値かどうか決定します。
|
22 |
比較は応答キャッシュにアクセスする時やブラウザがリンクを色付けするために履歴を調べる時や
|
23 |
XML 構文解析器が名前空間付きタグを処理する時に行われます。
|
24 |
蜘蛛や索引付け機関は検索範囲を狭めたり要求行為や応答蓄積域を削減したりするために
|
25 |
URI の比較に先立って大規模な正規化を行うこともあります。
|
26 |
|
27 |
> IRI comparison is performed for some particular purpose. Protocols
|
28 |
or implementations that compare IRIs for different purposes will
|
29 |
often be subject to differing design trade-offs in regards to how
|
30 |
much effort should be spent in reducing aliased identifiers. This
|
31 |
section describes various methods that may be used to compare IRIs,
|
32 |
the trade-offs between them, and the types of applications that might
|
33 |
use them.
|
34 |
|
35 |
IRI 比較は何らかの特定の目的で行います。 IRI を比較するプロトコルや実装は、
|
36 |
比較の目的によって別名識別子を減らすためにどれだけの労力を費やすべきかの算段により異なる設計をすることにもなります。
|
37 |
この章では IRI を比較するために使うことができる様々な方法とそれぞれの優劣、
|
38 |
そしてそれぞれが使われそうな応用の種類を説明します。
|
39 |
|
40 |
**5.1. Equivalence
|
41 |
> Because IRIs exist to identify resources, presumably they should be
|
42 |
considered equivalent when they identify the same resource. However,
|
43 |
this definition of equivalence is not of much practical use, as there
|
44 |
is no way for an implementation to compare two resources unless it
|
45 |
has full knowledge or control of them. For this reason, determination
|
46 |
of equivalence or difference of IRIs is based on string comparison,
|
47 |
perhaps augmented by reference to additional rules provided by URI
|
48 |
scheme definitions. We use the terms "different" and "equivalent" to
|
49 |
describe the possible outcomes of such comparisons, but there are
|
50 |
many application-dependent versions of equivalence.
|
51 |
|
52 |
IRI は資源を識別するために存在するのですから、おそらくは同じ資源を識別するのであれば同値と考えるべきでしょう。しかし、ある実装が2つの資源を比較するためには両資源についての完全な知識と制御権が必要となりますから、これはあまり現実的な同値性の定義ではありません。そのため、 IRI が等価か異なるかの決定は文字列としての比較と URI scheme の定義による追加の規則による補正で行います。この比較の結果となるものを説明するために 異なると同値という言葉を使いますが、実際には多くの応用依存の同値性が存在しています。
|
53 |
|
54 |
> Even though it is possible to determine that two IRIs are equivalent,
|
55 |
IRI comparison is not sufficient to determine whether two IRIs
|
56 |
identify different resources. For example, an owner of two different
|
57 |
domain names could decide to serve the same resource from both,
|
58 |
resulting in two different IRIs. Therefore, comparison methods are
|
59 |
designed to minimize false negatives while strictly avoiding false positives.
|
60 |
|
61 |
2つの IRI が同値かどうかを決定することは可能ですが、 2つの IRI が異なる資源を識別しているかどうかを決定するのに IRI の比較は不十分です。例えば、2つの異なるドメイン名の所有者は両方で、つまり2つの別の IRI で同じ資源を供給することができます。従って、比較法は偽陽性を厳密に避けつつ偽陰性を最小化するように設計されています。
|
62 |
|
63 |
> In testing for equivalence, applications should not directly compare
|
64 |
relative references; the references should be converted to their
|
65 |
respective target IRIs before comparison. When IRIs are compared to
|
66 |
select (or avoid) a network action, such as retrieval of a
|
67 |
representation, fragment components (if any) should be excluded from
|
68 |
the comparison.
|
69 |
|
70 |
応用は同値性の試験の際に相対参照を直接比較するべきではありません。参照は比較に先立ってそれぞれ対象 IRI に変換するべきです。 IRI の比較が表現の取出しなどのネットワーク動作の選択 (または回避) のためなら、
|
71 |
[CODE(ABNF)[fragment]] 部品を (あれば) 比較の対象から外すべきです。
|
72 |
|
73 |
> Applications using IRIs as identity tokens with no relationship to a
|
74 |
protocol MUST use the Simple String Comparison (see section 5.3.1).
|
75 |
All other applications MUST select one of the comparison practices
|
76 |
from the Comparison Ladder (see section 5.3 or, after IRI-to-URI
|
77 |
conversion, select one of the comparison practices from the URI
|
78 |
comparison ladder in [RFC3986], section 6.2)
|
79 |
|
80 |
IRI をプロトコルと関係ない識別字句として使う応用は単純文字列比較を使わなければ'''なりません'''。
|
81 |
他のすべての応用は比較梯子から比較方法を一つ選ばなければ
|
82 |
(5.3節か、 IRI から URI に変換した後 [[RFC 3986]] 6.2節の URI
|
83 |
比較梯子から比較方法を一つ選択しなければ) '''なりません'''。
|
84 |
|
85 |
** 5.2. Preparation for Comparison
|
86 |
> Any kind of IRI comparison REQUIRES that all escapings or encodings
|
87 |
in the protocol or format that carries an IRI are resolved. This is
|
88 |
usually done when the protocol or format is parsed. Examples of such
|
89 |
escapings or encodings are entities and numeric character references
|
90 |
in [HTML4] and [XML1]. As an example,
|
91 |
"http://example.org/rosé" (in HTML),
|
92 |
"http://example.org/rosé"; (in HTML or XML), and
|
93 |
"http://example.org/rosé"; (in HTML or XML) are all resolved into
|
94 |
what is denoted in this document (see section 1.4) as
|
95 |
"http://example.org/rosé"; (the "é" here standing for the
|
96 |
actual e-acute character, to compensate for the fact that this
|
97 |
document cannot contain non-ASCII characters).
|
98 |
|
99 |
どんな IRI 比較法であってもIRI
|
100 |
を伝達してきたプロトコルや書式のすべての逃避や符号化を解決する'''必要があります'''。
|
101 |
これは通常プロトコルや書式の構文解析の際に行われます。
|
102 |
逃避や符号化の例には [[HTML 4]] や [[XML 1.0]] の[[実体参照]]や[[数値文字参照]]があります。
|
103 |
例えば [SAMP(HTML)[http://example.org/rosé]] (HTML)、
|
104 |
[SAMP(HTML)[http://example.org/rosé]] (HTML や XML)、
|
105 |
[SAMP(HTML)[http://example.org/rosé]] (HTML や XML)
|
106 |
はすべてこの文書での表記法でいう [SAMP(URI)[http://example.org/ros'''é''']]
|
107 |
に解決されます
|
108 |
(ここで [SAMP(URI)['''é''']] は実際のアキュート・アクセント付き文字 e
|
109 |
で、この文書は非 ASCII 文字を含めることができないのでこう表記しています)。
|
110 |
|
111 |
> Similar considerations apply to encodings such as Transfer Codings in
|
112 |
HTTP (see [RFC2616]) and Content Transfer Encodings in MIME
|
113 |
([RFC2045]), although in these cases, the encoding is based not on
|
114 |
characters but on octets, and additional care is required to make
|
115 |
sure that characters, and not just arbitrary octets, are compared
|
116 |
(see section 5.3.1).
|
117 |
|
118 |
同じことが [[HTTP]] の[[転送符号化]]や [[MIME]] の[[内容転送符号化]]にも言えますが、
|
119 |
これらの場合は符号化は文字ではなくオクテットによっていますから、
|
120 |
単にオクテットを比較するのではなく文字を比較するように特に注意する必要があります。
|
121 |
|
122 |
**5.3. Comparison Ladder
|
123 |
> In practice, a variety of methods are used, to test IRI equivalence.
|
124 |
These methods fall into a range distinguished by the amount of
|
125 |
processing required and the degree to which the probability of false
|
126 |
negatives is reduced. As noted above, false negatives cannot be
|
127 |
eliminated. In practice, their probability can be reduced, but this
|
128 |
reduction requires more processing and is not cost-effective for all applications.
|
129 |
|
130 |
IRI の同値性を試験するために様々な方法が実際に用いられています。それらの方法は必要な処理の量と偽陰性の可能性を減らせる度合で分類できます。前述のように、偽陰性は見積もることができません。実際にはその可能性を減らすことはできますが、減らすためにはより処理が必要となり、すべての応用にとって経費的に有効ではありません。
|
131 |
|
132 |
> If this range of comparison practices is considered as a ladder, the
|
133 |
following discussion will climb the ladder, starting with practices
|
134 |
that are cheap but have a relatively higher chance of producing false
|
135 |
negatives, and proceeding to those that have higher computational
|
136 |
cost and lower risk of false negatives.
|
137 |
|
138 |
この比較法の分類は梯子のように考えることができます。以後の議論では安価ながら偽陰性を生成する機会が比較的高い方法からはじめ、梯子をのぼって計算経費が高つくものの偽陰性の虞が減る方法へと進んでいきます。
|
139 |
|
140 |
***5.3.1. Simple String Comparison
|
141 |
> If two IRIs, when considered as character strings, are identical,
|
142 |
then it is safe to conclude that they are equivalent. This type of
|
143 |
equivalence test has very low computational cost and is in wide use
|
144 |
in a variety of applications, particularly in the domain of parsing.
|
145 |
It is also used when a definitive answer to the question of IRI
|
146 |
equivalence is needed that is independent of the scheme used and that
|
147 |
can be calculated quickly and without accessing a network. An
|
148 |
example of such a case is XML Namespaces ([XMLNamespace]).
|
149 |
|
150 |
2つの URI が文字列として見た時に同一であれば、両者は同値であると安全に結論できます。この種類の同値性試験は計算経費が極めて低く、様々な応用で、特に構文解析の分野で広く使われています。
|
151 |
この方法は使用されている scheme と独立に、
|
152 |
しかも素早くネットワークにアクセスせずに IRI
|
153 |
の同値性の決定的な答えが求められる時にも使われます。
|
154 |
その例が XML 名前空間です。
|
155 |
|
156 |
> Testing strings for equivalence requires some basic precautions. This
|
157 |
procedure is often referred to as "bit-for-bit" or "byte-for-byte"
|
158 |
comparison, which is potentially misleading. Testing strings for
|
159 |
equality is normally based on pair comparison of the characters that
|
160 |
make up the strings, starting from the first and proceeding until
|
161 |
both strings are exhausted and all characters are found to be equal,
|
162 |
until a pair of characters compares unequal, or until one of the
|
163 |
strings is exhausted before the other.
|
164 |
|
165 |
文字列の同値性の試験にはいくつかの基本的な用意が必要です。この方法はしばしば[Q[ビット毎]]の比較だとか[Q[バイト毎]]の比較だとか言われますが、それには誤解の虞があります。文字列の同値性の検査は通常文字列を構成している文字を最初から順に見て、両文字列の最後まで来てすべての文字が等しかったと分かるか、どれかの文字の組が等しくないか、一方の文字列が他方よりも先に終わってしまうまで文字の組毎に比較を行います。
|
166 |
|
167 |
> This character comparison requires that each pair of characters be
|
168 |
put in comparable encoding form. For example, should one IRI be
|
169 |
stored in a byte array in UTF-8 encoding form and the second in a
|
170 |
UTF-16 encoding form, bit-for-bit comparisons applied naively will
|
171 |
produce errors. It is better to speak of equality on a
|
172 |
character-for-character rather than on a byte-for-byte or bit-for-bit
|
173 |
basis. In practical terms, character-by-character comparisons should
|
174 |
be done codepoint by codepoint after conversion to a common character
|
175 |
encoding form. When comparing character by character, the comparison
|
176 |
function MUST NOT map IRIs to URIs, because such a mapping would
|
177 |
create additional spurious equivalences. It follows that an IRI
|
178 |
SHOULD NOT be modified when being transported if there is any chance
|
179 |
that this IRI might be used as an identifier.
|
180 |
|
181 |
この文字比較のためには文字の組の両方が比較できる形である必要があります。
|
182 |
例えば、ある IRI が UTF-8 符号化形のバイト配列に蓄積されており、
|
183 |
もう一つの IRI が UTF-16 符号化形で蓄積されているとしますと、
|
184 |
ビット毎の比較は当然誤りとなります。ですからバイト毎とかビット毎とかではなくて、
|
185 |
文字毎の同値性というのがよいのです。
|
186 |
実際上は文字毎の比較は共通の文字符号化に変換した後に符号位置毎に行うべきです。
|
187 |
比較関数は文字毎の比較の際に IRI を URI に写像しては'''なりません'''。
|
188 |
URI に写像してしまうと偽の同値という結果が増えてしまいます。
|
189 |
IRI が識別子として使われる可能性がある場合には輸送中に IRI
|
190 |
を修正する'''べきではありません'''。
|
191 |
|
192 |
> False negatives are caused by the production and use of IRI aliases.
|
193 |
Unnecessary aliases can be reduced, regardless of the comparison
|
194 |
method, by consistently providing IRI references in an already
|
195 |
normalized form (i.e., a form identical to what would be produced
|
196 |
after normalization is applied, as described below). Protocols and
|
197 |
data formats often limit some IRI comparisons to simple string
|
198 |
comparison, based on the theory that people and implementations will,
|
199 |
in their own best interest, be consistent in providing IRI
|
200 |
references, or at least be consistent enough to negate any efficiency
|
201 |
that might be obtained from further normalization.
|
202 |
|
203 |
偽陰性は IRI 別名の生成や使用によって起こります。 IRI 参照を正規化済みの形
|
204 |
(後述の正規化を適用した結果生成されるであろうものと同一の形)
|
205 |
を一貫して生成することによって不必要なべうt名を比較方法によらず減らすことができます。
|
206 |
プロトコルやデータ書式はしばしば人々と実装がそれぞれの最高の利益のために、
|
207 |
あるいは少なくても更に正規化を行って得られる効果を打ち消す程度には一貫した
|
208 |
IRI 参照を提供するであろうとの論理に基づいて IRI
|
209 |
の比較を単純な文字列の比較に限定していたりします。
|
210 |
|
211 |
***5.3.2. Syntax-Based Normalization
|
212 |
> Implementations may use logic based on the definitions provided by
|
213 |
this specification to reduce the probability of false negatives. This
|
214 |
processing is moderately higher in cost than character-for-character
|
215 |
string comparison. For example, an application using this approach
|
216 |
could reasonably consider the following two IRIs equivalent:
|
217 |
|
218 |
実装は偽陰性の可能性を減らすためにこの仕様書にある定義に基づいた論理を用いて構いません。この処理は文字毎の文字列比較より若干高価です。例えば、この方法を使った応用は次の 2つの IRI は同値であるというもっともらしい考えができます。
|
219 |
|
220 |
>
|
221 |
- [SAMP(URI)[example://a/b/c/%7Bfoo%7D/ros'''é''']]
|
222 |
- [SAMP(URI)[eXAMPLE://a/./b/../b/%63/%7bfoo%7d/ros%C3%A9]]
|
223 |
|
224 |
> Web user agents, such as browsers, typically apply this type of IRI
|
225 |
normalization when determining whether a cached response is
|
226 |
available. Syntax-based normalization includes such techniques as
|
227 |
case normalization, character normalization, percent-encoding
|
228 |
normalization, and removal of dot-segments.
|
229 |
|
230 |
Web 利用者エージェント、例えばブラウザは、普通キャッシュした応答が利用できるかどうか決定する時にこの種の IRI の正規化を行います。構文を基にした正規化には大文字・小文字の正規化、百分率符号化の正規化、点部分の削除などの技術があります。
|
231 |
|
232 |
***5.3.2.1. Case Normalization
|
233 |
> For all IRIs, the hexadecimal digits within a percent-encoding
|
234 |
triplet (e.g., "%3a" versus "%3A") are case-insensitive and therefore
|
235 |
should be normalized to use uppercase letters for the digits A - F.
|
236 |
|
237 |
すべての IRI について百分率符号化3文字組の中の十六進数字
|
238 |
(例えば [SAMP(URI)[%3a]] と [SAMP(URI)[%3A]]) は大文字・小文字の区別がなく、
|
239 |
故に大文字の数字 A〜F に正規化するべきです。
|
240 |
|
241 |
> When an IRI uses components of the generic syntax, the component
|
242 |
syntax equivalence rules always apply; namely, that the scheme and
|
243 |
US-ASCII only host are case insensitive and therefore should be
|
244 |
normalized to lowercase. For example, the URI
|
245 |
"HTTP://www.EXAMPLE.com/" is equivalent to "http://www.example.com/".
|
246 |
Case equivalence for non-ASCII characters in IRI components that are
|
247 |
IDNs are discussed in section 5.3.3. The other generic syntax
|
248 |
components are assumed to be case sensitive unless specifically
|
249 |
defined otherwise by the scheme.
|
250 |
|
251 |
IRI が一般構文の部品を使う場合、部品構文の同値性の規則が常に適用されます。
|
252 |
すなわち、 [CODE(ABNF)[[[scheme]]]] と [[US-ASCII]] だけの [CODE(ABNF)[[[host]]]]
|
253 |
は大文字と小文字を区別せず、小文字に正規化するべきです。例えば IRI
|
254 |
<HTTP://www.EXAMPLE.com/> は <http://www.example.com/> と同値です。
|
255 |
IRI 部品中の非 ASCII 文字であって [[IDN]] たるものの大文字・
|
256 |
小文字の同値性は5.3.3節で議論します。
|
257 |
他の一般構文の部品は scheme が特に規定していない限り大文字・
|
258 |
小文字を区別するものとします。
|
259 |
|
260 |
> Creating schemes that allow case-insensitive syntax components
|
261 |
containing non-ASCII characters should be avoided. Case normalization
|
262 |
of non-ASCII characters can be culturally dependent and is always a
|
263 |
complex operation. The only exception concerns non-ASCII host names
|
264 |
for which the character normalization includes a mapping step derived
|
265 |
from case folding.
|
266 |
|
267 |
非 ASCII 文字を含む構文部品で大文字・小文字を区別しないようにした
|
268 |
scheme を作ることは避けるべきです。非 ASCII
|
269 |
文字の大文字・小文字の正規化は文化に依存することがあり、常に複雑な操作となります。
|
270 |
唯一の例外は非 ASCII ホスト名についてで、文字正規化が大文字・
|
271 |
小文字の揃えによる写像の段階を含んでいます。
|
272 |
|
273 |
****5.3.2.2. Character Normalization
|
274 |
> The Unicode Standard [UNIV4] defines various equivalences between
|
275 |
sequences of characters for various purposes. Unicode Standard Annex
|
276 |
#15 [UTR15] defines various Normalization Forms for these
|
277 |
equivalences, in particular Normalization Form C (NFC, Canonical
|
278 |
Decomposition, followed by Canonical Composition) and Normalization
|
279 |
Form KC (NFKC, Compatibility Decomposition, followed by Canonical Composition).
|
280 |
|
281 |
Unicode 規格は様々な目的での様々な文字列の同値性を定義しています。
|
282 |
Unicode 規格附属書 15 は同値性についての色々な正規化形、
|
283 |
特に正規化形 C (NFC、正準分解の後に正準合成) と正規化形 KC
|
284 |
(NFKC、互換分解の後に正準合成) を定義しています。
|
285 |
|
286 |
> Equivalence of IRIs MUST rely on the assumption that IRIs are
|
287 |
appropriately pre-character-normalized rather than apply character
|
288 |
normalization when comparing two IRIs. The exceptions are conversion
|
289 |
from a non-digital form, and conversion from a non-UCS-based
|
290 |
character encoding to a UCS-based character encoding. In these cases,
|
291 |
NFC or a normalizing transcoder using NFC MUST be used for
|
292 |
interoperability. To avoid false negatives and problems with
|
293 |
transcoding, IRIs SHOULD be created by using NFC. Using NFKC may
|
294 |
avoid even more problems; for example, by choosing half-width Latin
|
295 |
letters instead of full-width ones, and full-width instead of half-width Katakana.
|
296 |
|
297 |
IRI の同値性は2つの IRI を比較する際に文字正規化を行うのではなく、
|
298 |
IRI は適切に文字毎に正規化されていると仮定して行わなければ'''なりません'''。
|
299 |
例外は非デジタル形からの変換と UCS を基にしていない文字符号化から
|
300 |
UCS を基にした文字符号化への変換です。これらの場合には相互運用性のため NFC
|
301 |
か NFC を使った正規化転符号化器を使わなければ'''なりません'''。
|
302 |
偽陰性と転符号化の問題を避けるため、 IRI は NFC を使って作成する'''べきです'''。
|
303 |
NFKC を使うと更に問題を回避できるかもしれません。例えば、全角ラテン文字ではなく半角ラテン文字を選び、
|
304 |
半角片仮名の代わりに全角片仮名を選ぶと良いかもしれません。
|
305 |
|
306 |
> As an example, "http://www.example.org/résumé.html" (in XML
|
307 |
Notation) is in NFC. On the other hand,
|
308 |
"http://www.example.org/résumé.html" is not in NFC.
|
309 |
|
310 |
例えば、 [SAMP(URI)[http://www.example.org/r'''é'''sum'''é'''.html]]
|
311 |
(XML 表記) は NFC です。一方、
|
312 |
[SAMP(URI)[http://www.example.org/re'''́'''sume'''́'''.html]]
|
313 |
は NFC ではありません。
|
314 |
|
315 |
> The former uses precombined e-acute characters, and the latter uses
|
316 |
"e" characters followed by combining acute accents. Both usages are
|
317 |
defined as canonically equivalent in [UNIV4].
|
318 |
|
319 |
前者は合成済みアキュート・アクセント付き文字 e を使っており、
|
320 |
後者は文字 e と合成用アキュート・アクセントを使っています。
|
321 |
両者は[[正準等価]]と定義されています。
|
322 |
|
323 |
> Note: Because it is unknown how a particular sequence of characters
|
324 |
is being treated with respect to character normalization, it would
|
325 |
be inappropriate to allow third parties to normalize an IRI
|
326 |
arbitrarily. This does not contradict the recommendation that
|
327 |
when a resource is created, its IRI should be as character
|
328 |
normalized as possible (i.e., NFC or even NFKC). This is similar
|
329 |
to the uppercase/lowercase problems. Some parts of a URI are case
|
330 |
insensitive (domain name). For others, it is unclear whether they
|
331 |
are case sensitive, case insensitive, or something in between
|
332 |
(e.g., case sensitive, but with a multiple choice selection if the
|
333 |
wrong case is used, instead of a direct negative result). The
|
334 |
best recipe is that the creator use a reasonable capitalization
|
335 |
and, when transferring the URI, capitalization never be changed.
|
336 |
|
337 |
注意: 特定の文字列が文字正規化に関してどう扱われるかはわかりませんから、
|
338 |
第三者が勝手に IRI を正規化するのを認めるのは不適切です。
|
339 |
これは資源を作成するときに IRI を可能な限り文字正規化 (NFC かもっと強く NFKC に)
|
340 |
するべきであるという推奨と矛盾しません。これは大文字・小文字の問題と同様です。
|
341 |
URI は部分的に大文字・小文字を区別しません (ドメイン名)。
|
342 |
他の部分は大文字・小文字を区別するかしないか中間か
|
343 |
(例えば区別はするものの間違っていたらすぐに失敗になるのではなく選択肢が示されるとか)
|
344 |
はわかりません。一番よいのは作者が適度な大文字化を行い、 URI
|
345 |
を転送する時に決して大文字・小文字を変えないことです。
|
346 |
|
347 |
> Various IRI schemes may allow the usage of Internationalized Domain
|
348 |
Names (IDN) [RFC3490] either in the ireg-name part or elsewhere.
|
349 |
Character Normalization also applies to IDNs, as discussed in section 5.3.3.
|
350 |
|
351 |
各 IRI scheme は国際化ドメイン名 (IDN) を [CODE(ABNF)[[[ireg-name]]]]
|
352 |
部やその他の部分で使うことを認めているかもしれません。
|
353 |
文字正規化は5.3.3節で議論する通り IRI にも適用します。
|
354 |
|
355 |
**** 5.3.2.3. Percent-Encoding Normalization
|
356 |
> The percent-encoding mechanism (section 2.1 of [RFC3986]) is a
|
357 |
frequent source of variance among otherwise identical IRIs. In
|
358 |
addition to the case normalization issue noted above, some IRI
|
359 |
producers percent-encode octets that do not require percent-encoding,
|
360 |
resulting in IRIs that are equivalent to their non encoded
|
361 |
counterparts. These IRIs should be normalized by decoding any
|
362 |
percent-encoded octet sequence that corresponds to an unreserved
|
363 |
character, as described in section 2.3 of [RFC3986].
|
364 |
|
365 |
百分率符号化法は本来同一の IRI を色々に変えてしまう大きな原因です。前述の大文字・小文字の正規化の問題に加えて、 IRI 生成器によっては百分率符号化が必要ではないオクテットを百分率符号化するものもあります。そのような IRI は百分率符号化オクテットを対応する非予約文字に復号して正規化するべきです。
|
366 |
|
367 |
> For actual resolution, differences in percent-encoding (except for
|
368 |
the percent-encoding of reserved characters) MUST always result in
|
369 |
the same resource. For example, "http://example.org/~user",
|
370 |
"http://example.org/%7euser", and "http://example.org/%7Euser", must
|
371 |
resolve to the same resource.
|
372 |
|
373 |
実際の解決では百分率符号化だけの違いは (予約文字の百分率符号化を除き)
|
374 |
常に同じ資源が得られなければ'''なりません'''。例えば、
|
375 |
[SAMP(URI)[http://example.org/~user]], [SAMP(URI)[http://example.org/%7euser]],
|
376 |
[SAMP(URI)[http://example.org/%7Euser]] は同じ資源に解決されなければなりません。
|
377 |
|
378 |
> If this kind of equivalence is to be tested, the percent-encoding of
|
379 |
both IRIs to be compared has to be aligned; for example, by
|
380 |
converting both IRIs to URIs (see section 3.1), eliminating escape
|
381 |
differences in the resulting URIs, and making sure that the case of
|
382 |
the hexadecimal characters in the percent-encoding is always the same
|
383 |
(preferably uppercase). If the IRI is to be passed to another
|
384 |
application or used further in some other way, its original form MUST
|
385 |
be preserved. The conversion described here should be performed only
|
386 |
for local comparison.
|
387 |
|
388 |
この種の同値性を試験する時には比較する両方の百分率符号化を揃えなければなりません。
|
389 |
例えば、両方の IRI を URI に変換し、その URI で異なる逃避を除去し、
|
390 |
百分率符号化の十六進数字の大文字・小文字を常に同じに (できれば大文字に)
|
391 |
します。 IRI を他の応用に渡したり皿に他の形で使ったりする時は、
|
392 |
元の形を保存しなければ'''なりません'''。ここで説明した変換は局所的な比較のためにのみ行うべきです。
|
393 |
|
394 |
****5.3.2.4. Path Segment Normalization
|
395 |
> The complete path segments "." and ".." are intended only for use
|
396 |
within relative references (section 4.1 of [RFC3986]) and are removed
|
397 |
as part of the reference resolution process (section 5.2 of
|
398 |
[RFC3986]). However, some implementations may incorrectly assume
|
399 |
that reference resolution is not necessary when the reference is
|
400 |
already an IRI, and thus fail to remove dot-segments when they occur
|
401 |
in non-relative paths. IRI normalizers should remove dot-segments by
|
402 |
applying the remove_dot_segments algorithm to the path, as described
|
403 |
in section 5.2.4 of [RFC3986].
|
404 |
|
405 |
[CODE(URI)[.]] や [CODE(URI)[..]] だけの [CODE(ABNF)[[[path]]]]
|
406 |
[CODE(ABNF)[[[segment]]]] は[[相対参照]]でのみ使うことが想定されており、
|
407 |
参照解決処理で削除されます。しかし、実際に使用されている実装の中には参照が既に
|
408 |
IRI である場合には参照解決が不要であると誤って仮定して非相対
|
409 |
[CODE(ABNF)[[[path]]]] に現れる[[点部分]]を削除しないものがあります。
|
410 |
IRI 正規化器は [CODE(ABNF)[[[path]]]] に[[点部分削除]]の算法を適用して正規化するべきです。
|
411 |
|
412 |
***5.3.3. Scheme-Based Normalization
|
413 |
> The syntax and semantics of IRIs vary from scheme to scheme, as
|
414 |
described by the defining specification for each scheme.
|
415 |
Implementations may use scheme-specific rules, at further processing
|
416 |
cost, to reduce the probability of false negatives. For example,
|
417 |
because the "http" scheme makes use of an authority component, has a
|
418 |
default port of "80", and defines an empty path to be equivalent to
|
419 |
"/", the following four IRIs are equivalent:
|
420 |
|
421 |
IRI の構文と意味は scheme 毎の仕様で定義されていますが、
|
422 |
scheme 毎に実に様々です。実装は偽陰性の可能性を削減するために更に処理費を掛けて
|
423 |
scheme 規定の規則を使っても構いません。例えば、
|
424 |
[SAMP(URI)[[[http]]]] scheme は [CODE(ABNF)[[[authority]]]] 部品を使い、
|
425 |
既定のポートは [CODE[80]] であり、空の [CODE(ABNF)[[[path]]]] は
|
426 |
[CODE(URI)[/]] と同値であると定義していますから、次の 4つの IRI は同値です。
|
427 |
|
428 |
>
|
429 |
- [SAMP(URI)[http://example.com]]
|
430 |
- [SAMP(URI)[http://example.com/]]
|
431 |
- [SAMP(URI)[http://example.com:/]]
|
432 |
- [SAMP(URI)[http://example.com:80/]]
|
433 |
|
434 |
> In general, an IRI that uses the generic syntax for authority with an
|
435 |
empty path should be normalized to a path of "/". Likewise, an
|
436 |
explicit ":port", for which the port is empty or the default for the
|
437 |
scheme, is equivalent to one where the port and its ":" delimiter are
|
438 |
elided and thus should be removed by scheme-based normalization. For
|
439 |
example, the second IRI above is the normal form for the "http" scheme.
|
440 |
|
441 |
一般に [CODE(ABNF)[authority]] と空の [CODE(ABNF)[path]] を一般構文に使う
|
442 |
IRI は [CODE(ABNF)[path]] を [CODE(URI)[/]] に正規化するべきです。同様に、
|
443 |
[CODE(URI)[:[VAR[ポート]]]] が明示されていて[VAR[ポート]]が空か、
|
444 |
その scheme の既定の値であるなら、その[VAR[ポート]]と区切子の [CODE(URI)[:]]
|
445 |
を除去したものと同値であり、 scheme を基にした正規化では削除するべきです。
|
446 |
例えば、前記の2番目の IRI が [CODE(URI)[[[http]]]] scheme での正規形です。
|
447 |
|
448 |
> Another case where normalization varies by scheme is in the handling
|
449 |
of an empty authority component or empty host subcomponent. For many
|
450 |
scheme specifications, an empty authority or host is considered an
|
451 |
error; for others, it is considered equivalent to "localhost" or the
|
452 |
end-user's host. When a scheme defines a default for authority and
|
453 |
an IRI reference to that default is desired, the reference should be
|
454 |
normalized to an empty authority for the sake of uniformity, brevity,
|
455 |
and internationalization. If, however, either the userinfo or port
|
456 |
subcomponents are non-empty, then the host should be given explicitly
|
457 |
even if it matches the default.
|
458 |
|
459 |
正規化が scheme によって変わる別の事例が空の [CODE(ABNF)[[[authority]]]]
|
460 |
部品や空の [CODE(ABNF)[[[host]]]] 部分部品の扱いです。多くの scheme
|
461 |
の仕様では空の [CODE(ABNF)[[[authority]]]] や [CODE(ABNF)[[[host]]]]
|
462 |
は誤りと考えています。ものによっては [CODE(URI)[[[localhost]]]]
|
463 |
(末端利用者のホスト) と同値と考えています。 Scheme が
|
464 |
[CODE(ABNF)[[[authority]]]] の既定値を定義していて、その既定値への IRI
|
465 |
参照を望む場合には、参照は統一性, 簡潔性, 国際化のため、空の
|
466 |
[CODE(ABNF)[[[authority]]]] に正規化するべきです。しかし、
|
467 |
[CODE(ABNF)[[[userinfo]]]] 部分部品や [CODE(ABNF)[[[port]]]]
|
468 |
部分部品が空でない場合は、 [CODE(ABNF)[[[host]]]]
|
469 |
が既定値に一致しても明示しておくべきです。
|
470 |
|
471 |
> Normalization should not remove delimiters when their associated
|
472 |
component is empty unless it is licensed to do so by the scheme
|
473 |
specification. For example, the IRI "http://example.com/?" cannot be
|
474 |
assumed to be equivalent to any of the examples above. Likewise, the
|
475 |
presence or absence of delimiters within a userinfo subcomponent is
|
476 |
usually significant to its interpretation. The fragment component is
|
477 |
not subject to any scheme-based normalization; thus, two IRIs that
|
478 |
differ only by the suffix "#" are considered different regardless of the scheme.
|
479 |
|
480 |
対応する部品が空の区切子は scheme
|
481 |
の仕様がそうしてもよいと規定しない限り削除するべきではありません。例えば、
|
482 |
IRI [SAMP(URI)[http://example.com/?]]
|
483 |
は先の例のいずれとも同値と考えることはできません。同様に、
|
484 |
[CODE(ABNF)[[[userinfo]]]] 部分部品中の区切子の有無は通常解釈に影響を持ちます。
|
485 |
[CODE(ABNF)[[[fragment]]]] 部品は scheme を基にした正規化の対象ではありません。
|
486 |
ですから、末尾の [CODE(URI)[#]] だけが異なる2つの IRI は scheme
|
487 |
に関わらず異なると考えます。
|
488 |
|
489 |
> Some IRI schemes may allow the usage of Internationalized Domain
|
490 |
Names (IDN) [RFC3490] either in their ireg-name part or elsewhere.
|
491 |
When in use in IRIs, those names SHOULD be validated by using the
|
492 |
ToASCII operation defined in [RFC3490], with the flags
|
493 |
"UseSTD3ASCIIRules" and "AllowUnassigned". An IRI containing an
|
494 |
invalid IDN cannot successfully be resolved. Validated IDN
|
495 |
components of IRIs SHOULD be character normalized by using the
|
496 |
Nameprep process [RFC3491]; however, for legibility purposes, they
|
497 |
SHOULD NOT be converted into ASCII Compatible Encoding (ACE).
|
498 |
|
499 |
IRI scheme いよっては国際化ドメイン名 ([[IDN]]) の使用を [CODE(ABNF)[[[ireg-name]]]]
|
500 |
部や他の部分で認めています。 IRI で使う際には国際化ドメイン名は
|
501 |
[[RFC 3490]] で定義された [CODE[[[ToASCII]]]] 操作で旗
|
502 |
[CODE[[[UseSTD3ASCIIRules]]]] および [CODE[[[AllowUnassigned]]]]
|
503 |
の下検証する'''べきです'''。不当な IDN を含んだ IRI
|
504 |
は解決に成功することがありません。 IRI の検証した IDN 部品は
|
505 |
[[Nameprep]] 処理を使って文字正規化する'''べきです'''。しかし、
|
506 |
判読性のために [[ASCII互換符号化]] ([[ACE]]) に変換する'''べきではありません'''。
|
507 |
|
508 |
> Scheme-based normalization may also consider IDN components and their
|
509 |
conversions to punycode as equivalent. As an example,
|
510 |
"http://résumé.example.org" may be considered equivalent to
|
511 |
"http://xn--rsum-bpad.example.org".
|
512 |
|
513 |
Scheme に基づく正規化は IDN 部品と [[Punycode]] に変換したものをも同値と考えて構いません。
|
514 |
例えば、 [SAMP(URI)[http://r'''é'''sum'''é'''.example.org]]
|
515 |
は [SAMP(URI)[http://xn--rsum-bpad.example.org]]
|
516 |
と同値と考えても構いません。
|
517 |
|
518 |
> Other scheme-specific normalizations are possible.
|
519 |
|
520 |
他の scheme 規定の正規化もあり得ます。
|
521 |
|
522 |
***5.3.4. Protocol-Based Normalization
|
523 |
> Substantial effort to reduce the incidence of false negatives is
|
524 |
often cost-effective for web spiders. Consequently, they implement
|
525 |
even more aggressive techniques in IRI comparison. For example, if
|
526 |
they observe that an IRI such as
|
527 |
|
528 |
偽陰性の発生を削減する実際的な試みもしばしば蜘蛛の巣の蜘蛛にとって経費に見合うだけのものです。ですから、蜘蛛はもっと積極的な IRI の比較の方法を実装しています。例えば、
|
529 |
|
530 |
> [SAMP(URI)[http://example.com/data]]
|
531 |
|
532 |
> redirects to an IRI differing only in the trailing slash
|
533 |
|
534 |
という IRI が末尾の斜線だけが違う
|
535 |
|
536 |
> [SAMP(URI)[http://example.com/data/]]
|
537 |
|
538 |
> they will likely regard the two as equivalent in the future. This
|
539 |
kind of technique is only appropriate when equivalence is clearly
|
540 |
indicated by both the result of accessing the resources and the
|
541 |
common conventions of their scheme's dereference algorithm (in this
|
542 |
case, use of redirection by HTTP origin servers to avoid problems
|
543 |
with relative references).
|
544 |
|
545 |
という IRI を再指向すると分かれば、将来も2つが同値と考えます。この種の技法は資源へのアクセスの結果とその scheme の参照を解く方法で広く行われている慣習の両方によって明らかに同値性が示されている時にのみ適切であります (この場合、相対参照での問題を避けるため HTTP 起点鯖により再指向が使われています)。
|
546 |
|
547 |
* メモ
|