[#42243] コミュニティと宗教の分離について — Beyond <beyond@...>

14 messages 2006/05/21

[#42267] メニューのループについて — リックス <rubyer4649@...>

りっくすです

21 messages 2006/05/27

[#42301] Re: メニューのループについて — "conundrum /" <conundrum@...>

conundrumです。

11 messages 2006/05/28

[ruby-list:42215] URI relative reference beyond root path

From: Masao Takaku <masao@...>
Date: 2006-05-13 04:47:52 UTC
List: ruby-list #42215
はじめまして、たかくと申します。

以下のようなルートパスを踏み越えるような URI の相対パスの展開について、
うかがいたいのですが、

  (URI.parse("http://www.example.com/") + "../index.html").to_s
  => "http://www.example.com/../index.html"

これはブラウザ等が、"http://www.example.com/index.html" と解釈する
のと異なる挙動なので、困ることがあります。

すこし調べてみたところ、RFC 3986 では相対パスの展開方法の記述が
変更され、以下のような節が追加になっています:

  5.4.2.  Abnormal Examples
  
     Although the following abnormal examples are unlikely to occur in
     normal practice, all URI parsers should be capable of resolving
     them consistently.  Each example uses the same base as that
     above.
  
     Parsers must be careful in handling cases where there are more
     ".." segments in a relative-path reference than there are
     hierarchical levels in the base URI's path.  Note that the ".."
     syntax cannot be used to change the authority component of a URI.
  
        "../../../g"    =  "http://a/g"
        "../../../../g" =  "http://a/g"

上記仕様に沿えば、最初に示した例は、http://www.example.com/index.html
と展開するので良さそうに見えます。
いかがでしょうか?

ちなみに手元の環境は ruby 1.8.4 (2005-12-24) [i686-linux] です。

よろしくお願いします。
--
高久 雅生 // masao@nii.ac.jp

In This Thread

Prev Next