On Wed, 2 Apr 2008 13:39:38 -0400, Joey Hess <[EMAIL PROTECTED]> said: 

> Manoj Srivastava wrote:
>> The issue is that we need to convert relative links to absolute
>> ones for atom and rss feeds -- but there are two types of relative
>> links. The first kind, relative to the current document (
>> href="some/path") is handled correctly. The second kind of relative
>> url is is relative to the http server base (href="/semi-abs/path"),
>> and that broke.
>> 
>> It broke because we just prepended the url of the current document
>> to the href (http://host/path/to/this-doc/ + link), which gave us,
>> in the first place: http://host/path/to/this-doc/some/path
>> [correct], and http://host/path/to/this-doc//semi-abs/path [wrong]
>> 
>> The fix is to calculate the base for the http server (the base of
>> the wiki does not help, since the base of the wiki can be different
>> from the base of the http server -- I have, for example, "url =>
>> http://host.name.mine/blog/manoj/";), and prepend that to the
>> relative references that start with a /.

> How does a relative url start with / ? That would be broken anyway,
> so can't this be simplified to just adding [^\/] to the url regexp?

        I meant href="/subdir/of/var/www/"; which is relative to
 Document root, not relative to the current tree.

        Suppose you are reading http://localhost/main/pages/some.html.
 This corresponds to /var/www/main/pages/some.html (and comes from
 ./main/pages/some.mdwn in ikiwiki).

        In this, there is a link: href="/subdir/of/var/www/index.html"
 The browser will resolve it to
   http://localhost/subdir/of/var/www/index.html
 corresponding to
   /var/www/subdir/of/var/www/index.html

        Ikiwiki, of course, does:
 http://localhost/main/pages//subdir/of/var/www/index.html
  which would have meant:
  /var/www/main/pages//subdir/of/var/www/index.html
 which breaks.

        href="/subdir/of/var/www/" is legal; and I think it should be
 supported. Here are the references for why absolute-path relative
 references are defined:
,----
| RFC 3986                   URI Generic Syntax               January 2005
| Berners-Lee, et al.         Standards Track                    [Page 25]
| 4.2.  Relative Reference
|    ....
|    A relative reference that begins with two slash characters is
|    termed a network-path reference; such references are rarely used.
|    A relative reference that begins with a single slash character is
|    termed an absolute-path reference.  A relative reference that does
|    not begin with a slash character is termed a relative-path
|    reference.
`----
,----
| 5.4.  Reference Resolution Examples
|    Within a representation with a well defined base URI of
|       http://a/b/c/d;p?q
|    a relative reference is transformed to its target URI as follows.
| 5.4.1.  Normal Examples
|   ....
|       "g"             =  "http://a/b/c/g";
|       "g/"            =  "http://a/b/c/g/";
|       "/g"            =  "http://a/g";
|       "//g"           =  "http://g";
|  ....
`----

 It does work perfectly i the HTML part; only the rss generation
 produces dangling links. The patch provided implements the
 absolute-path and relative-path refernces, it will not be hard to
 extend the concept to support  network-path references as well.

        Please let me know if you want me to do that, I'll send a
 patch if you do.

        thanks,

        manoj
-- 
if (instr(buf,sys_errlist[errno])) /* you don't see this */ --Larry
Wall in eval.c from the perl source code
Manoj Srivastava <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> 
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to