urnのヘルプ・マニュアル
日本語 英語
urn --help
man urn
URI(7) Linux Programmer’s Manual URI(7)
名前
uri, url, urn - uniform resource identifier (URI), URL と URN も含む.
書式
URI = [ absoluteURI | relativeURI ] [ "#" fragment ]
absoluteURI = scheme ":" ( hierarchical_part | opaque_part )
relativeURI = ( net_path | absolute_path | relative_path ) [ "?" query ]
scheme = "http" | "ftp" | "gopher" | "mailto" | "news" | "telnet" |
"file" | "man" | "info" | "whatis" | "ldap" | "wais" | ...
hierarchical_part = ( net_path | absolute_path ) [ "?" query ]
net_path = "//" authority [ absolute_path ]
absolute_path = "/" path_segments
relative_path = relative_segment [ absolute_path ]
説明
Uniform Resource Identifier (URI) は抽象的・物理的なリソース (web ペー
ジなど) を識別するための短い文字列である 。 Uniform Resource Locator
(URL) は URI の一種で、リソースの名前などの属性でではなく、そのリソース
に対応するアクセスメカニズムを通してリソースを指定する (つまりネット ワ
ーク上の「場所 (location)」を指定する)。 Uniform Resource Name (URN) は
URI の一種で、これは対象のリソースが廃棄されたり利用できなくなった場 合
にも、グローバルに他と重なることなく永続しなければならない。
URI は、 web ブラウザなどのツールでハイパーテキストリンクのリンク先を指
定する時の標準的な方法である。文字列 "http://www.kernelnotes.org" は
URL である (従って URI でもある)。多くの人々は、 URL という言葉をほぼ
URI の同義語として使っている (しかし技術的には URL は URI のサブセッ ト
である)。
URI は絶対的にも相対的にも指定できる。絶対的な指定は、リソースをコンテ
クストに依存しないかたちで参照する。相対的な指定は、リソースを現在の コ
ン テ ク ス トからの差異によって記述する。相対パス参照では、 "." および
".." だけのパス部分 (path segment) は特別な意味を持ち、それぞれ「現在の
階 層 レベル」および「現在の階層の一つ上のレベル」として扱われる (Unix-
like なシステムと同様)。コロン文字を含むパス部分は相対 URI パスの先頭に
用 いることはできない (つまり "this:that" はダメ)。スキーム名と区別でき
ないからである。このような場合には ./ を 前 置 す る こ と ( つ ま り
"./this:that" とする)。 MS-DOS の子孫 (Microsoft Windows など) は、デバ
イス名のコロンを URI では垂直バー ("|") に置き換える。したがっ て "C:"
は "C|" となる。
フ ラグメント指定子 (fragment identifier) は、(もし含まれていれば) リソ
ース中の名前付けされた特定の部分 (フラグメント) を参照する。 '#' 指定子
以 降の文字列がフラグメントを指定する。 '#' で始まる URI は現在のリソー
ス中のフラグメントを参照する。 URI のスキームには色々な種類があり、それ
ぞ れ固有のルールや意味が追加されている。しかしできるだけ統一したものに
しようという努力もなされている。例えば、多くの URL スキーム は 「 機 関
(authority) 」 に対して以下の書式 (ここでは ip_server と呼ぶことにする)
を許している (角括弧内部は省略可能)。
ip_server = [user [ : password ] @ ] host [ : port]
このフォーマットには、ユーザ名、ユーザ名+パスワードを指定できる。ポート
番 号 を 追加することも可能である。 host はホストコンピュータの名前で、
DNS で定義される名前か IP アドレス (ピリオドで区切られた数字) で指定 す
る 。したがって URI は、ホスト
xyz.com に fred として (パスワードを使って) ポート 8080 を使ってログ イ
ンする。パスワードは可能なら URI には含めないほうが良いだろう。パスワー
ドを直書きすると様々なセキュリティ上のリスクが生じるからである。 URL に
ユ ーザ名だけを与え、パスワードを与えない場合は、リモートサーバはパスワ
ードを要求してくる。 URL を解釈したプログラムが、ユーザにこの入力を促す
ことになろう。
以下に、 Unix-like なシステムで非常に良く用いられており、多くのツールが
理解するスキームを示す。 URI を使うツールの多くでは、内部スキームや特殊
な スキームも使えることが多い。そのようなスキームに関してはツールのドキ
ュメントを見ること。
http - Web (HTTP) サーバ
http://ip_server/path
http://ip_server/path?query
これは web (HTTP) サーバにアクセスするための URL である。デフォルトのポ
ー ト は 80。パスがディレクトリを参照しているときは、返される情報は web
サーバが選択する。通常は、 "index.html" や "index.htm" のようなファイル
が あれば、その内容が返される。なければ、カレントディレクトリのリストが
(適切なリンクとともに) 生成されて返される。例としては
など。
問 い合わせ (query) を、古い "isindex" フォーマットによって送ることもで
きる。このフォーマットは単語またはフレーズからなり、等号 (=) は含まない
。より長い "GET" フォーマットでも問い合わせは行える。このフォーマットに
は、一つ以上の問い合わせエントリが key=value という形式で含まれる。それ
ぞ れのエントリはアンパサンド (&) で区切られる。 key は複数個指定するこ
ともできる。しかしそれに意味があるかどうかは web サーバとアプリケーショ
ン プログラムが決める。 HTML/XML/SGML と GET 問い合わせ形式の間には、不
幸な関係がある。一つ以上のキーの含まれる URI が SGML/XML 文書 (HTML も
そ う) に埋めこまれる際には、アンパサンド (&) は & と書かなければな
らない。全ての問い合わせがこの形式を使うわけではない。フォームが長く な
ると URI に入れるには長すぎるから、別の通信メカニズム (POST と呼ばれる)
が用いられる。 POST では URI にはデータは含まれない。より詳しい情報は、
にある Common Gateway Interface の仕様書を見よ
。
ftp - ファイル転送プロトコル (FTP)
ftp://ip_server/path
これはファイル転送プロトコル (FTP) を通してファイルにアクセスするための
URL である。デフォルトの (制御用) ポートは 21 である。ユーザ名がない場
合には、ユーザ名 anonymous が与えられる。そしてその場合には、クライアン
ト の多くは要求した人のインターネットメールアドレスをパスワードとして与
える。例としては など。
gofer - Gofer サーバ
gopher://ip_server/gophertype selector
gopher://ip_server/gophertype selector%09search
gopher://ip_server/gophertype selector%09search%09gopher+_string
デフォルトの gopher ポートは 70 である。 gophertype は 1 文字からなるフ
ィールドで、 URL が参照している Gopher のリソースタイプを示す。パス全体
が空であってもよく、その場合は区切りの "/" も省略でき る 。 こ の と き
gophertype のデフォルトは "1" になる。
selector は Gopher セレクタ文字列である。Gopher プロトコルでは、 Gopher
セレクタ文字列はオクテット文字からなり、 16進数の 09 (US-ASCII の HT ま
た は tab)、 0A (US-ASCII の LF 文字)、 0D (US-ASCII の CR 文字) 以外な
らどんなオクテットも指定できる。
mailto - 電子メールアドレス
mailto:email-address
これは電子メールアドレスで、通常 name@hostname という形式をとる。電子メ
ールアドレスの正しいフォーマットに関するより詳しい情報は mailaddr(7) を
見よ。 % 文字はすべて %25 と書き直さなければならないことに注意。例と し
ては など。
news - ニュースグループ・ニュースメッセージ
news:newsgroup-name
news:message-id
newsgroup-name は ピ リ オ ド で 区切られた階層的な名前である。例えば
"comp.infosystems.www.misc" など。 が "*" ( つ ま り
) の場合には、「参照できる全てのニュースグループ」の意味になる
。例としては など。
message-id は IETF RFC 1036 の Message-ID から、囲みの "<" と ">" を 取
ったものに対応する。 Message-ID は unique@full_domain_name という形式を
とる。メッセージの指定には "@" 文字が含まれるので、ニュースグループの名
前と区別できるだろう。
telnet - telnet ログイン
telnet://ip_server/
Telnet URL スキームは対話的なテキストサービスに Telnet プロトコルを通し
てアクセスするために用いられる。最後の "/" 文字は省略してよい。例として
は など。
file - 通常のファイル
file://ip_server/path_segments
file:path_segments
こ れはローカルに直接アクセスできるファイルを示す。特殊なケースとして、
host には "localhost" という文字列を用いたり、空文字にしてもよい。こ れ
は 「URI が解釈されたマシン」とみなされる。 path がディレクトリの場合は
、ビューアはディレクトリの内容をリンクを張ったかたちで表示するとよい だ
ろ う 。 しかし現在は、まだ全てのビューアがこの動作をするわけではない。
KDE は生成ファイル (generated file) を URL の形式でサポ
ー トしている。与えられたファイルが見付からなかった場合は、ファイル名を
グロブによって展開すると良いかもしれない (glob(7) および glob(3) を 見
よ)。
二つめの書式 (例えば ) もローカルファイルを参照する正
しいフォーマットである。しかし古い標準ではこの書式を許していなかった の
で、これを URI として認識しないプログラムも存在する。より汎用的な文法は
、サーバ名に空文字を用いるもの、つまり のような も
の である。この形式も指す内容は同じであり、パターンマッチやより古いプロ
グラムでも URI として認識されやすい。もし意図するところが「現在の場所か
らスタート」なら、スキームは一切用いるべきではない。 <../test.txt> のよ
うな、スキームに依存しない相対リンクを用いること。このスキームの例と し
ては など。
man - man ページ文書
man:command-name
man:command-name(section)
これはローカルのオンラインマニュアル (man) リファレスページを参照する。
command-name には括弧とセクション番号を追加してもよい。セクション番号の
意 味 に つ いて詳しく知りたい場合は man(7) をみよ。この URI スキームは
Unix-like なシステム (Linux など) に特有のものであり、現在はま だ IETF
による登録はされていない。例としては など。
info - info ページ文書
info:virtual-filename
info:virtual-filename#nodename
info:(virtual-filename)
info:(virtual-filename)nodename
こ のスキームは、オンラインの info リファレンスページ (texinfo ファイル
から生成される) を参照する。 info ページは GNU ツールなどのプログラムで
用 いられている文書フォーマットである。この URI スキームは Unix-like な
システム (Linux など) に特有のものであり、現在はまだ IETF による登録 は
さ れていない。この文書の執筆時において、 GNOME と KDE はそれぞれ異なる
文法の URI を用いており、お互い相手の文法を受け入れない。最初の 2 つ の
書式は GNOME の書式である。ノード名 (nodename) のスペースはすべてアンダ
ースコアに変換される。 3 つめと 4 つめは KDE の書式である。ノード名のス
ペースはそのままスペースで書かれる (URI の標準では禁止されているのだが)
。将来は多くのツールがこれらの書式すべてを理解するようになり、ノード 名
の アンダースコア、スペースを両方とも理解できるようになることを期待した
い。 GNOME でも KDE でも、ノード名が省略された場合は、ノード名 と し て
"Top" が 用 い ら れ る 。 GNOME 書 式 の 例としては や
など、 KDE 書式の例とし て は や
など。
whatis - 文書検索
whatis:string
こ のスキームは、コマンドに関する短い (1 行の) 説明を集めたデータベース
を検索し、 string を含む文字列をリストして返す。単語が完全にマッチし た
結果だけが返される。 whatis(1) を見よ。この URI スキームは Unix-like な
システム (Linux など) に特有のものであり、現在はまだ IETF による登録 は
されていない。
ghelp - GNOME ヘルプ文書
ghelp:name-of-application
与えられた application に対応する GNOME help をロードする。この書式を用
いた文書はまだあまり多くない。
ldap - 軽量ディレクトリアクセスプロトコル
ldap://hostport
ldap://hostport/
ldap://hostport/dn
ldap://hostport/dn?attributes
ldap://hostport/dn?attributes?scope
ldap://hostport/dn?attributes?scope?filter
ldap://hostport/dn?attributes?scope?filter?extensions
このスキームは Lightweight Directory Access Protocol (LDAP) へのクエ リ
ー をサポートする。 LDAP は複数のサーバに分散した、階層化された情報 (人
々や計算資源など) に問い合わせるためのプロトコルである。 LDAP の URL ス
キームに関するより詳しい情報は RFC 2255 で見ることができる。この URL の
各部は以下の通り:
hostport クエリーを行う LDAP サーバ。ホスト名を書く。続けてコロン と
ポ ート番号を追加することもできる。 LDAP のデフォルトのポー
トは TCP ポート 389 である。省略されると、どの LDAP サー バ
を用いるかはクライアントが決定する。
dn LDAP の Distintuished Name (識別名)。 LDAP 検索の base オブ
ジェクトを指定するものである ( RFC 2253 の section 3 を 見
よ)。
attributes コ ン マ 区 切 り の 、返される属性 (attribute) のリスト。
RFC 2251 の section 4.1.5 を見よ。省略されると全ての属性 が
返される。
scope 検索のスコープを指定する。 "base" (base オブジェクト検索),
"one" (1 レベル検索), "sub" (サブツリー検索) のいずれかを指
定する。省略すると "base" が仮定される。
filter 検索フィルタ (返されるエントリのサブセット) を指定する。省
略されると、全てのエントリが返される。 RFC 2254 の section
4 を見よ。
extensions コ ンマで区切られた type=value ペアのリスト。ここで =value
の部分は、それを要求しないオプションに対しては省略できる 。
'!' が前置された extension は critical (サポートしていなけ
ればならない) であり、そうでなければ critical ではない ( 省
略できる)。
LDAP の ク エリーは、例とともに説明するのが最も簡単である。次の例は、
ldap.itd.umich.edu に、 U.S. にある University of Michigan の情報を尋ね
る例である。
ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US
郵便用の住所属性だけを取得する場合は、次のようにリクエストする:
ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress
host.com のポート 6666 に、 University of Michigan にいる common name
(cn) が "Babs Jenson" の人の情報を尋ねる場合は、次のようにリクエスト す
る:
ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)
wais - 広域情報サービス
wais://hostport/database
wais://hostport/database?search
wais://hostport/database/wtype/wpath
このスキームは WAIS のデータベース、検索、文書を指定する (WAIS に関する
詳しい情報は IETF RFC 1625 を見よ)。 hostport は、ホスト名にコロンと ポ
ート番号を付加したものである (コロン + ポート番号は省略可。デフォルトの
ポート番号は 210 である)。
最初の書式は WAIS のデータベースに対する検索の指定である。二つめの書 式
は 特定の WAIS データベース database に対する検索の指定である。三つめの
書式は WAIS データベースにある特定の文書を取出す指定である。 wtype は
WAIS のオブジェクト形式指定であり、 wpath は WAIS document-id である。
その他のスキーム
他 にも多くの URI スキームが存在する。 URI を受付けるほとんどのツールは
、内部 URI のセットをサポートする (例えば Mozilla は内部情報用の about:
というスキームを受付けるし、 GNOME ヘルプブラウザはいろいろな出発点用に
toc: というスキームを持っている)。定義されたスキームはたくさんあるが 、
現 時点で広く用いられてはいない (例えば prospero とか)。 nntp: スキーム
は news: スキームが好んで用いられるようになったので使わないほうが良い。
URN は urn: スキームによって、階層的な名前空間 (例えば urn:ietf:... は
IETF 文書を示す) としてサポートされるべきであるが、現時点では URN は あ
ま り用いられていない。全てのツールが全てのスキームをサポートしているわ
けではない。
文字エンコード
URI では、色々な状況下で入力できるように、文字の種類を制限している。
以下の文字は予約されている。すなわち、これらの文字は URI に登場すること
が あるが、それらの利用法 (解釈のされ方) は予約された目的に制限されてい
る (衝突するデータは URI にする前にエスケープしなければならない)。
; / ? : @ & = + $ ,
未予約文字 (unreserved character) は URI に使ってよい。これには英字の大
文字と小文字、10 進の数字、および以下の句読文字・記号が含まれる
- _ . ! ~ * ’ ( )
他 の文字はすべてエスケープしなければならない。エスケープされたオクテッ
トは 3 文字からなる: 先頭にパーセント文字 "%"、それに続けてオクテットコ
ー ドを表す 2 文字の 16 進数字である (16 進数の英字は大文字小文字どちら
でも良い)。例えば空白文字は "%20" のようにエスケープしなければならず 、
タブ文字は "%09"、 "&" は "%26" となる。パーセント文字 "%" は常にエスケ
ープを示す予約された目的に用いられるので、 "%" 自身を表すには "%25" と
エ スケープしなければならない。クエリーのテキストでは、スペース文字をプ
ラス記号 (+) でエスケープすることも一般に良く行われる。この慣例は 関 連
RFC で実際に定義されているわけではない (代わりに %20 を推奨している) が
、クエリーテキストを受付けるツールは、この書式への対応を用意しておく べ
きであろう。 URI は、常に「エスケープされた」かたちで表示される。
未予約文字もエスケープすることができ、これによって URI の意味するところ
が変わるわけではない。しかしURI にその非エスケープ文字が現れることが 許
されないような特殊な場合を除いて、これは避けるべきである。例えば、 HTTP
URL の path において "%7e" が "~" の代わりに用いられることがあるが、 こ
の二つは HTTP URL としては等価である。
US ASCII キャラクタセット以外の文字を URI として扱う場合、 HTML 4.1 規
格 (section B.2) 及び IETF RFC 2718 (section 2.2.5) は以下の手法を用 い
るよう推奨している。
1. キャラクタ列を UTF-8 (IETF RFC 2279, utf-8(7) 参照) に変換し、
2. URI エスケープ機構を用いる。つまり、安全でないオクテットを %HH でエ
ンコードする。
URI を書くには
URI を書く時には、ダブルクォートの内部に書く ( 例: "http://www.kernel-
notes.org") か、 angle ブラケットで囲む (例: ) か、一行
に URI だけを書くかする。ダブルクォートを使う人に警告: 絶対に句読点 (文
末のピリオドやリスト区切りのコンマ) を URI の内部に移動してはならない。
代わりに angle ブラケットを使うか、外にある文字をクォーテーションマーク
の 内 部 に 決 し て 含めないような引用方式に切替えること。後者の方式は
"Hart’s Rules" や "Oxford Dictionary for Writers and Editors" によれ ば
「 新しい (new) 引用方式」あるいは「論理的 (logical) な引用方式」と呼ば
れており、 イギリス人や世界中のハッカー達はこちらの慣習を好んでいる (よ
り 詳 し い 情 報 は Hacker Writing Style の Jargon File のセクション
http://www.fwi.uva.nl/~mes/jargon/h/HackerWritingStyle.html を見よ)。古
い文書では、 "URL:" という文字列を URI の直前に挿入することを勧めている
ものもあるが、しかしこの形式はまったく流行しなかった。
URI の書式は曖昧さを排除するように設計されている。しかし URI が広まるに
つれ、昔ながらのメディア (TV、ラジオ、新聞、看板などなど) は URI 参照を
省略したかたち、すなわち機関部とパス部だけでリソースを指定することが 多
く なっている (例: )。このような参照はマシンとい
うよりは人間向けのもので、コンテキストベースの推測によって URI の補完が
可能であることをあてにしているのである (例えば "www" ではじまるホスト名
なら "http://" がつくだろうし、 "ftp" ではじまるホスト名な ら "ftp://"
がつくだろう)。多くのクライアントの実装では、この種の参照を推測によって
解決する。このような推測は時代とともに変わりうる。特に新しいスキーム が
導 入されるとそうである。 URI の省略形では相対 URL パスの区別が付けられ
ないので、省略形 URI 参照は相対 URI の利用できるところでは使えない。 つ
ま り定義済みのベース (ダイアログボックスなど) がない場合に限って利用で
きる。文書内部でのハイパーテキストリンクには省略形 URI を使ってはならな
い。上述の標準フォーマットを使うこと。
準拠
http://www.ietf.org/rfc/rfc2396.txt (IETF RFC 2396),
http://www.w3.org/TR/REC-html40 (HTML 4.0).
注意
Linux システムで URI を受付けるツール (例えば web ブラウザなど) は、 上
に あげた全てのスキームを (直接または間接に) 扱えるべきである。 man: や
info: も含めて、である。スキームの処理に他のプログラムを実行するのは 良
いことだし、実はすすんでそうすべきである。
技術的には、フラグメントは URI の一部ではない。
URI (URL も含む) をデータフォーマットに埋めこむ方法に関する情報は、その
フォーマットのドキュメントを見よ。 HTML は text を 用
い る。 texinfo は @uref{uri} という書式を用いる。 man と mdoc は、最近
追加された UR マクロを使う。あるいは URI をそのままテキストに埋めこむ (
ビューアが :// を URI の一部と解釈できなければならない)。
デスクトップ環境である GNOME と KDE は、それぞれ受付ける URI が (特にそ
れぞれのヘルプブラウザにおいて) 異なっている。 man ページをリストするに
は 、 GNOME では を用い、 KDE では を用いる。ま
た info ページをリストするには、 GNOME では を用い、 KDE で
は を用いる (本 man ページの著者は KDE のアプローチのほう
が好みである。しかしより標準的な書式の方が更に良いが)。一般に KDE は 生
成 ファイル (generated file) のプレフィックスとして を
用いる。 KDE は HTML の文書を 経由でアクセ ス
す るのが好みなようである。 GNOME は文書の保管・検索に ghelp スキームを
用いる方法を取っているようだ。どちらのブラウザも、現時点では file: によ
る ディレクトリ参照を扱えない。したがってディレクトリ全体をブラウズ可能
な URI で参照することが難しい。先に述べたように、これら二つの環境 で は
info: スキームの扱いが異なっている (おそらく最も重要な差異であろう)。
GNOME と KDE が共通 URI フォーマットに収斂することが望ましい。この man
ペ ージが、将来はその収斂した結果を記述できることを望む。この作業への助
力を喚起したい。
セキュリティ
URI そのものはセキュリティの脅威を引き起こすものではない。ある時点で は
リソースの場所を与えていた URL が、ずっとそうでありつづけるという保証は
一般にはない。またある URL が、将来には別のリソースを示さないとも限らな
い 。このような保証は、その名前空間とリソースとを管理している個人に帰す
るものに過ぎない。
無害に見える操作 (リソースに関連づけられたエンティティの取得など) に よ
って、実際にはリモートにダメージを与える動作を引き起こすような URL を記
述することも場合によっては可能である。危険な URL の典型的なものは、その
ネ ットワークプロトコルに予約されているポート番号とは異なるポートを指定
しているものである。 URL の内容には命令が含まれていて、そのプロトコルに
し たがって解釈されたとき、予期されない動作を引起こすのである。例をあげ
ると、 gopher の URL によって、意図しないメッセージやなりすましメッセー
ジなどが SMTP サーバ経由で送信されるようなことがあった。
そのプロトコルのデフォルト以外のポート番号を指定している URL を用いると
きには注意すべきである。特にその番号が予約空間の内部にある場合には。
URI に、そのプロトコルに対するデリミタがエスケープされたかたちで入っ て
い る場合も注意が必要である (例えば telnet プロトコルに対する CR 文字や
LF 文字など)。なぜならこれらは転送前にエスケープが外されないからであ る
。 これはプロトコルに反しており、予期しない、おそらくは害になるようなリ
モート動作を引起こす結果となりかねない。
秘密にしておくべきパスワードを含んだ URI を使うのが賢くないのは明らかで
ある。特に、パスワードを URI の "userinfo" の部分に使うのは絶対に避ける
べきである。ただしその "password" のパラメータを意図的に公開したい場 合
は別であるが。
バグ
文 書は様々な場所に置かれうる。したがって現時点では、任意のフォーマット
で書かれた一般のオンライン文書に対する良い URI スキームが存在しな い 。
形式の参照は使えない。なぜならディストリビューシ
ョンやローカルへのインストールの際の条件によって、ファイルは異なるデ ィ
レ ク トリに置かれることがあるからである (/usr/doc か /usr/local/doc か
/usr/share かその他の場所か、などなど)。また、ディレクトリ ZZZ は通常バ
ー ジョンが変わると異なったものになる (ファイル名のグロブによってある程
度克服できるだろうが)。最後にもう一つ、文書をインターネットから (ローカ
ル のファイルシステムにファイルをロードするのではなく) 動的にロードする
人々は、なかなか file: スキームを使ってくれない。将来には新たな URI ス
キ ーム (例えば "userdoc:" のような) が追加され、より詳しい文書へのクロ
スリファレンスが、その文書の正確な場所をプログラムが知らなくても可能 に
な るかもしれない。あるいは、ファイルシステム規格の将来の版でファイルの
場所の指定をより厳密にして、 file: スキームによる文書の位置指定が可能に
なるかもしれない。
プログラムやファイルフォーマットの多くでは、 URI を使ったリンクを取り込
んだり実装したりする方法がない。
プログラムの多くは、これらの URI フォーマットをすべては扱えない。ユーザ
の 環境 (テキストかグラフィックか、デスクトップ環境、ローカルユーザの好
み、現在実行されているツール) などを自動的に検知して、任意の URI をロー
ドし、その URI に適したツールを起動するような標準的な仕組みがあるといい
のだろうが。
関連項目
lynx(1), man2html(1), mailaddr(7), utf-8(7), IETF RFC 2255
Linux 2000-03-14 URI(7)
URI(7) Linux Programmer’s Manual URI(7)
NAME
uri, url, urn - uniform resource identifier (URI), including a URL or
URN
SYNOPSIS
URI = [ absoluteURI | relativeURI ] [ "#" fragment ]
absoluteURI = scheme ":" ( hierarchical_part | opaque_part )
relativeURI = ( net_path | absolute_path | relative_path ) [ "?" query ]
scheme = "http" | "ftp" | "gopher" | "mailto" | "news" | "telnet" |
"file" | "man" | "info" | "whatis" | "ldap" | "wais" | ...
hierarchical_part = ( net_path | absolute_path ) [ "?" query ]
net_path = "//" authority [ absolute_path ]
absolute_path = "/" path_segments
relative_path = relative_segment [ absolute_path ]
DESCRIPTION
A Uniform Resource Identifier (URI) is a short string of characters
identifying an abstract or physical resource (for example, a web page).
A Uniform Resource Locator (URL) is a URI that identifies a resource
through its primary access mechanism (e.g., its network "location"),
rather than by name or some other attribute of that resource. A Uni-
form Resource Name (URN) is a URI that must remain globally unique and
persistent even when the resource ceases to exist or becomes unavail-
able.
URIs are the standard way to name hypertext link destinations for tools
such as web browsers. The string "http://www.kernelnotes.org" is a URL
(and thus it is also a URI). Many people use the term URL loosely as a
synonym for URI (though technically URLs are a subset of URIs).
URIs can be absolute or relative. An absolute identifier refers to a
resource independent of context, while a relative identifier refers to
a resource by describing the difference from the current context.
Within a relative path reference, the complete path segments "." and
".." have special meanings: "the current hierarchy level" and "the
level above this hierarchy level", respectively, just like they do in
Unix-like systems. A path segment which contains a colon character
can’t be used as the first segment of a relative URI path (e.g.,
"this:that"), because it would be mistaken for a scheme name; precede
such segments with ./ (e.g., "./this:that"). Note that descendants of
MS-DOS (e.g., Microsoft Windows) replace devicename colons with the
vertical bar ("|") in URIs, so "C:" becomes "C|".
A fragment identifier, if included, refers to a particular named por-
tion (fragment) of a resource; text after a '#' identifies the frag-
ment. A URI beginning with '#' refers to that fragment in the current
resource.
Usage
There are many different URI schemes, each with specific additional
rules and meanings, but they are intentionally made to be as similar as
possible. For example, many URL schemes permit the authority to be the
following format, called here an ip_server (square brackets show what’s
optional):
ip_server = [user [ : password ] @ ] host [ : port]
This format allows you to optionally insert a username, a user plus
password, and/or a port number. The host is the name of the host com-
puter, either its name as determined by DNS or an IP address (numbers
separated by periods). Thus the URI logs into a web server on host xyz.com as fred
(using fredpassword) using port 8080. Avoid including a password in a
URI if possible because of the many security risks of having a password
written down. If the URL supplies a username but no password, and the
remote server requests a password, the program interpreting the URL
should request one from the user.
Here are some of the most common schemes in use on Unix-like systems
that are understood by many tools. Note that many tools using URIs
also have internal schemes or specialized schemes; see those tools’
documentation for information on those schemes.
http - Web (HTTP) server
http://ip_server/path
http://ip_server/path?query
This is a URL accessing a web (HTTP) server. The default port is 80.
If the path refers to a directory, the web server will choose what to
return; usually if there is a file named "index.html" or "index.htm"
its content is returned, otherwise, a list of the files in the current
directory (with appropriate links) is generated and returned. An exam-
ple is .
A query can be given in the archaic "isindex" format, consisting of a
word or phrase and not including an equal sign (=). A query can also
be in the longer "GET" format, which has one or more query entries of
the form key=value separated by the ampersand character (&). Note that
key can be repeated more than once, though it’s up to the web server
and its application programs to determine if there’s any meaning to
that. There is an unfortunate interaction with HTML/XML/SGML and the
GET query format; when such URIs with more than one key are embedded in
SGML/XML documents (including HTML), the ampersand (&) has to be
rewritten as &. Note that not all queries use this format; larger
forms may be too long to store as a URI, so they use a different inter-
action mechanism (called POST) which does not include the data in the
URI. See the Common Gateway Interface specification at
for more information.
ftp - File Transfer Protocol (FTP)
ftp://ip_server/path
This is a URL accessing a file through the file transfer protocol
(FTP). The default port (for control) is 21. If no username is
included, the username "anonymous" is supplied, and in that case many
clients provide as the password the requestor’s Internet email address.
An example is .
gopher - Gopher server
gopher://ip_server/gophertype selector
gopher://ip_server/gophertype selector%09search
gopher://ip_server/gophertype selector%09search%09gopher+_string
The default gopher port is 70. gophertype is a single-character field
to denote the Gopher type of the resource to which the URL refers. The
entire path may also be empty, in which case the delimiting "/" is also
optional and the gophertype defaults to "1".
selector is the Gopher selector string. In the Gopher protocol, Gopher
selector strings are a sequence of octets which may contain any octets
except 09 hexadecimal (US-ASCII HT or tab), 0A hexadecimal (US-ASCII
character LF), and 0D (US-ASCII character CR).
mailto - Email address
mailto:email-address
This is an email address, usually of the form name@hostname. See
mailaddr(7) for more information on the correct format of an email
address. Note that any % character must be rewritten as %25. An exam-
ple is .
news - Newsgroup or News message
news:newsgroup-name
news:message-id
A newsgroup-name is a period-delimited hierarchical name, such as
"comp.infosystems.www.misc". If is "*" (as in
), it is used to refer to "all available news groups". An
example is .
A message-id corresponds to the Message-ID of IETF RFC 1036, without
the enclosing "<" and ">"; it takes the form unique@full_domain_name.
A message identifier may be distinguished from a news group name by the
presence of the "@" character.
telnet - Telnet login
telnet://ip_server/
The Telnet URL scheme is used to designate interactive text services
that may be accessed by the Telnet protocol. The final "/" character
may be omitted. The default port is 23. An example is .
file - Normal file
file://ip_server/path_segments
file:path_segments
This represents a file or directory accessible locally. As a special
case, host can be the string "localhost" or the empty string; this is
interpreted as "the machine from which the URL is being interpreted".
If the path is to a directory, the viewer should display the direc-
tory’s contents with links to each containee; not all viewers currently
do this. KDE supports generated files through the URL .
If the given file isn’t found, browser writers may want to try to
expand the filename via filename globbing (see glob(7) and glob(3)).
The second format (e.g., ) is a correct format for
referring to a local file. However, older standards did not permit
this format, and some programs don’t recognize this as a URI. A more
portable syntax is to use an empty string as the server name, for exam-
ple, ; this form does the same thing and is easily
recognized by pattern matchers and older programs as a URI. Note that
if you really mean to say "start from the current location," don’t
specify the scheme at all; use a relative address like <../test.txt>,
which has the side-effect of being scheme-independent. An example of
this scheme is .
man - Man page documentation
man:command-name
man:command-name(section)
This refers to local online manual (man) reference pages. The command
name can optionally be followed by a parenthesis and section number;
see man(7) for more information on the meaning of the section numbers.
This URI scheme is unique to Unix-like systems (such as Linux) and is
not currently registered by the IETF. An example is .
info - Info page documentation
info:virtual-filename
info:virtual-filename#nodename
info:(virtual-filename)
info:(virtual-filename)nodename
This scheme refers to online info reference pages (generated from tex-
info files), a documentation format used by programs such as the GNU
tools. This URI scheme is unique to Unix-like systems (such as Linux)
and is not currently registered by the IETF. As of this writing, GNOME
and KDE differ in their URI syntax and do not accept the other’s syn-
tax. The first two formats are the GNOME format; in nodenames all
spaces are written as underscores. The second two formats are the KDE
format; spaces in nodenames must be written as spaces, even though this
is forbidden by the URI standards. It’s hoped that in the future most
tools will understand all of these formats and will always accept
underscores for spaces in nodenames. In both GNOME and KDE, if the
form without the nodename is used the nodename is assumed to be "Top".
Examples of the GNOME format are and .
Examples of the KDE format are and .
whatis - Documentation search
whatis:string
This scheme searches the database of short (one-line) descriptions of
commands and returns a list of descriptions containing that string.
Only complete word matches are returned. See whatis(1). This URI
scheme is unique to Unix-like systems (such as Linux) and is not cur-
rently registered by the IETF.
ghelp - GNOME help documentation
ghelp:name-of-application
This loads GNOME help for the given application. Note that not much
documentation currently exists in this format.
ldap - Lightweight Directory Access Protocol
ldap://hostport
ldap://hostport/
ldap://hostport/dn
ldap://hostport/dn?attributes
ldap://hostport/dn?attributes?scope
ldap://hostport/dn?attributes?scope?filter
ldap://hostport/dn?attributes?scope?filter?extensions
This scheme supports queries to the Lightweight Directory Access Proto-
col (LDAP), a protocol for querying a set of servers for hierarchically
organized information (such as people and computing resources). More
information on the LDAP URL scheme is available in RFC 2255. The com-
ponents of this URL are:
hostport the LDAP server to query, written as a hostname optionally
followed by a colon and the port number. The default LDAP
port is TCP port 389. If empty, the client determines
which the LDAP server to use.
dn the LDAP Distinguished Name, which identifies the base
object of the LDAP search (see RFC 2253 section 3).
attributes a comma-separated list of attributes to be returned; see
RFC 2251 section 4.1.5. If omitted, all attributes should
be returned.
scope specifies the scope of the search, which can be one of
"base" (for a base object search), "one" (for a one-level
search), or "sub" (for a subtree search). If scope is
omitted, "base" is assumed.
filter specifies the search filter (subset of entries to return).
If omitted, all entries should be returned. See RFC 2254
section 4.
extensions a comma-separated list of type=value pairs, where the
=value portion may be omitted for options not requiring it.
An extension prefixed with a '!' is critical (must be sup-
ported to be valid), otherwise it is non-critical
(optional).
LDAP queries are easiest to explain by example. Here’s a query that
asks ldap.itd.umich.edu for information about the University of Michi-
gan in the U.S.:
ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US
To just get its postal address attribute, request:
ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress
To ask a host.com at port 6666 for information about the person with
common name (cn) "Babs Jensen" at University of Michigan, request:
ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)
wais - Wide Area Information Servers
wais://hostport/database
wais://hostport/database?search
wais://hostport/database/wtype/wpath
This scheme designates a WAIS database, search, or document (see IETF
RFC 1625 for more information on WAIS). Hostport is the hostname,
optionally followed by a colon and port number (the default port number
is 210).
The first form designates a WAIS database for searching. The second
form designates a particular search of the WAIS database database. The
third form designates a particular document within a WAIS database to
be retrieved. wtype is the WAIS designation of the type of the object
and wpath is the WAIS document-id.
other schemes
There are many other URI schemes. Most tools that accept URIs support
a set of internal URIs (e.g., Mozilla has the about: scheme for inter-
nal information, and the GNOME help browser has the toc: scheme for
various starting locations). There are many schemes that have been
defined but are not as widely used at the current time (e.g., pros-
pero). The nntp: scheme is deprecated in favor of the news: scheme.
URNs are to be supported by the urn: scheme, with a hierarchical name
space (e.g., urn:ietf:... would identify IETF documents); at this time
URNs are not widely implemented. Not all tools support all schemes.
Character Encoding
URIs use a limited number of characters so that they can be typed in
and used in a variety of situations.
The following characters are reserved, that is, they may appear in a
URI but their use is limited to their reserved purpose (conflicting
data must be escaped before forming the URI):
; / ? : @ & = + $ ,
Unreserved characters may be included in a URI. Unreserved characters
include upper and lower case English letters, decimal digits, and the
following limited set of punctuation marks and symbols:
- _ . ! ~ * ’ ( )
All other characters must be escaped. An escaped octet is encoded as a
character triplet, consisting of the percent character "%" followed by
the two hexadecimal digits representing the octet code (you can use
upper or lower case letters for the hexadecimal digits). For example,
a blank space must be escaped as "%20", a tab character as "%09", and
the "&" as "%26". Because the percent "%" character always has the
reserved purpose of being the escape indicator, it must be escaped as
"%25". It is common practice to escape space characters as the plus
symbol (+) in query text; this practice isn’t uniformly defined in the
relevant RFCs (which recommend %20 instead) but any tool accepting URIs
with query text should be prepared for them. A URI is always shown in
its "escaped" form.
Unreserved characters can be escaped without changing the semantics of
the URI, but this should not be done unless the URI is being used in a
context that does not allow the unescaped character to appear. For
example, "%7e" is sometimes used instead of "~" in an HTTP URL path,
but the two are equivalent for an HTTP URL.
For URIs which must handle characters outside the US ASCII character
set, the HTML 4.01 specification (section B.2) and IETF RFC 2718 (sec-
tion 2.2.5) recommend the following approach:
1. translate the character sequences into UTF-8 (IETF RFC 2279) — see
utf-8(7) — and then
2. use the URI escaping mechanism, that is, use the %HH encoding for
unsafe octets.
Writing a URI
When written, URIs should be placed inside double quotes (e.g.,
"http://www.kernelnotes.org"), enclosed in angle brackets (e.g.,
), or placed on a line by themselves. A warning for
those who use double-quotes: never move extraneous punctuation (such as
the period ending a sentence or the comma in a list) inside a URI,
since this will change the value of the URI. Instead, use angle brack-
ets instead, or switch to a quoting system that never includes extrane-
ous characters inside quotation marks. This latter system, called the
’new’ or ’logical’ quoting system by "Hart’s Rules" and the "Oxford
Dictionary for Writers and Editors", is preferred practice in Great
Britain and hackers worldwide (see the Jargon File’s section on Hacker
Writing Style, http://www.fwi.uva.nl/~mes/jargon/h/HackerWrit-
ingStyle.html, for more information). Older documents suggested
inserting the prefix "URL:" just before the URI, but this form has
never caught on.
The URI syntax was designed to be unambiguous. However, as URIs have
become commonplace, traditional media (television, radio, newspapers,
billboards, etc.) have increasingly used abbreviated URI references
consisting of only the authority and path portions of the identified
resource (e.g., ). Such references are primar-
ily intended for human interpretation rather than machine, with the
assumption that context-based heuristics are sufficient to complete the
URI (e.g., hostnames beginning with "www" are likely to have a URI pre-
fix of "http://" and hostnames beginning with "ftp" likely to have a
prefix of "ftp://"). Many client implementations heuristically resolve
these references. Such heuristics may change over time, particularly
when new schemes are introduced. Since an abbreviated URI has the same
syntax as a relative URL path, abbreviated URI references cannot be
used where relative URIs are permitted, and can only be used when there
is no defined base (such as in dialog boxes). Don’t use abbreviated
URIs as hypertext links inside a document; use the standard format as
described here.
CONFORMING TO
http://www.ietf.org/rfc/rfc2396.txt (IETF RFC 2396),
http://www.w3.org/TR/REC-html40 (HTML 4.0).
NOTES
Any tool accepting URIs (e.g., a web browser) on a Linux system should
be able to handle (directly or indirectly) all of the schemes described
here, including the man: and info: schemes. Handling them by invoking
some other program is fine and in fact encouraged.
Technically the fragment isn’t part of the URI.
For information on how to embed URIs (including URLs) in a data format,
see documentation on that format. HTML uses the format
text . Texinfo files use the format @uref{uri}. Man and mdoc have
the recently added UR macro, or just include the URI in the text (view-
ers should be able to detect :// as part of a URI).
The GNOME and KDE desktop environments currently vary in the URIs they
accept, in particular in their respective help browsers. To list man
pages, GNOME uses while KDE uses , and to list
info pages, GNOME uses while KDE uses (the
author of this man page prefers the KDE approach here, though a more
regular format would be even better). In general, KDE uses as a prefix to a set of generated files. KDE prefers documenta-
tion in HTML, accessed via the . GNOME
prefers the ghelp scheme to store and find documentation. Neither
browser handles file: references to directories at the time of this
writing, making it difficult to refer to an entire directory with a
browsable URI. As noted above, these environments differ in how they
handle the info: scheme, probably the most important variation. It is
expected that GNOME and KDE will converge to common URI formats, and a
future version of this man page will describe the converged result.
Efforts to aid this convergence are encouraged.
Security
A URI does not in itself pose a security threat. There is no general
guarantee that a URL, which at one time located a given resource, will
continue to do so. Nor is there any guarantee that a URL will not
locate a different resource at some later point in time; such a guaran-
tee can only be obtained from the person(s) controlling that namespace
and the resource in question.
It is sometimes possible to construct a URL such that an attempt to
perform a seemingly harmless operation, such as the retrieval of an
entity associated with the resource, will in fact cause a possibly dam-
aging remote operation to occur. The unsafe URL is typically con-
structed by specifying a port number other than that reserved for the
network protocol in question. The client unwittingly contacts a site
that is in fact running a different protocol. The content of the URL
contains instructions that, when interpreted according to this other
protocol, cause an unexpected operation. An example has been the use
of a gopher URL to cause an unintended or impersonating message to be
sent via a SMTP server.
Caution should be used when using any URL that specifies a port number
other than the default for the protocol, especially when it is a number
within the reserved space.
Care should be taken when a URI contains escaped delimiters for a given
protocol (for example, CR and LF characters for telnet protocols) that
these are not unescaped before transmission. This might violate the
protocol, but avoids the potential for such characters to be used to
simulate an extra operation or parameter in that protocol, which might
lead to an unexpected and possibly harmful remote operation to be per-
formed.
It is clearly unwise to use a URI that contains a password which is
intended to be secret. In particular, the use of a password within the
"userinfo" component of a URI is strongly recommended against except in
those rare cases where the "password" parameter is intended to be pub-
lic.
BUGS
Documentation may be placed in a variety of locations, so there cur-
rently isn’t a good URI scheme for general online documentation in
arbitrary formats. References of the form don’t
work because different distributions and local installation require-
ments may place the files in different directories (it may be in
/usr/doc, or /usr/local/doc, or /usr/share, or somewhere else). Also,
the directory ZZZ usually changes when a version changes (though file-
name globbing could partially overcome this). Finally, using the file:
scheme doesn’t easily support people who dynamically load documentation
from the Internet (instead of loading the files onto a local file sys-
tem). A future URI scheme may be added (e.g., "userdoc:") to permit
programs to include cross-references to more detailed documentation
without having to know the exact location of that documentation.
Alternatively, a future version of the file-system specification may
specify file locations sufficiently so that the file: scheme will be
able to locate documentation.
Many programs and file formats don’t include a way to incorporate or
implement links using URIs.
Many programs can’t handle all of these different URI formats; there
should be a standard mechanism to load an arbitrary URI that automati-
cally detects the users’ environment (e.g., text or graphics, desktop
environment, local user preferences, and currently executing tools) and
invokes the right tool for any URI.
SEE ALSO
lynx(1), man2html(1), mailaddr(7), utf-8(7), IETF RFC 2255
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2000-03-14 URI(7)