]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/preview_base_url_should_be_absolute.mdwn
Proposed patch for plugins/osm
[ikiwiki.git] / doc / bugs / preview_base_url_should_be_absolute.mdwn
1 The edit page CGI defines a `base` tag with an URL which is not
2 absolute, which can break the preview function in some circumstances
3 (with e.g. images not showing). The trivial [[patch]] that fixes
4 it can be found [[here|http://sprunge.us/EPHT]] as well as on [[my
5 git|http://git.oblomov.eu/ikiwiki]].
6
7 > That patch does mean that if you're accessing the CGI via HTTPS but your
8 > $config{url} and $config{cgiurl} are HTTP, you'll get preview images loaded
9 > via HTTP, causing the browser to complain. See
10 > [[todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both]]
11 > for background.
12 >
13 > Perhaps the CGI could form its `<base>` URL by using
14 > `URI->new_abs(urlto(...), $cgi->url)` instead?
15 >
16 > You'd also need to change `IkiWiki/Wrapper.pm` to pass at least the
17 > SERVER_NAME and SERVER_PORT through the environment, probably.
18 >
19 > Joey's last comment on
20 > [[todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both]]
21 > suggests that this might already work, but I'm not quite sure how - I'd
22 > expect it to need more environment variables? --[[smcv]]
23 >
24 >> `CGI::url` uses `REQUEST_URI`. So it could be used, but I don't see
25 >> how to get from the `CGI::url` to an url to the page that is being
26 >> edited. --[[Joey]]
27 >>> (The right rune seems to be: `URI->new_abs(urlto($params{page}), $cgi->url))` --[[Joey]] 
28
29 ---
30
31 Update: This bug is worse than it first appeared, and does not only affect
32 previewing. The cgi always has a `<base>` url, and it's always relative,
33 and that can break various links etc. For example, when the 404 plugin
34 displays a missing page, it has a Recentchanges link, which would be broken
35 if the cgi was in an unusual place.
36
37 `misctemplate` needs to *always* set an absolute baseurl. Which is a problem,
38 since `misctemplate` is not currently passed a cgi object from which to
39 construct one. --[[Joey]]
40
41 Update: Worse and worse. `baseurl(undef)` can be a relative url, but
42 nearly every use of it I can find actually needs to be absolute. 
43 the numerous `redirect($q, baseurl(undef))` all need to be absolute
44 according to `CGI` documentation.
45
46 So, I'm seriously thinking about reverting the part of
47 [[todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both]]
48 that made `baseurl(undef)` relative. 
49 And I suppose, re-opening that todo. :( --[[Joey]]
50
51 ----
52
53 This was fixed in version 3.20110105 [[done]] --[[Joey]]