Fossil

Artifact [dfe2d24c]
Login

Artifact [dfe2d24c]

Artifact dfe2d24c5aeb3032344e5782fa50d0574bc43e481f17bde3c5bdacb06bb0e8de:

Wiki page [branch/base-href-fix] by george 2022-02-15 20:53:49.
D 2022-02-15T20:53:49.011
L branch/base-href-fix
N text/x-markdown
U george
W 2514
The primary purpose of this branch is to fix a problem with `#fragment` hyperlinks.
The problem is observed on webpages which satisfy all the following conditions:

 1. Contain `#fragment` links or relative links.

 2. Have more than one segment in their [`PATH_INFO`][]
    or have non-empty `QUERY_STRING` (or both).

 3. Have `<base>` element in their `<head>` section that
    does not account for (2).

It turns out that some important pages are affected by this issue: `/forumpost`,
`/forumthread`, `/tktview`, `/timeline`, `/wiki` and `/wikiedit` (and perhaps other).
Notably the `/doc` pages are not affected unless QUERY_STRING is non-empty
(which makes sense for the TH1-enabled pages).

This issue was discovered earlier under a custom skin and recently
[became a real obstacle for proper functioning of footnotes][obstacle]
within Forum, Tickets and Wiki.

The solution proposed in this branch consists of changing
the value of base href attribute so that it is consistent with the requested URI.
It introduces [`style_set_base_href_suffix()`][func] function that may be called by
a page's handler to override value in base href. If a particular handler
does not call `style_set_base_href_suffix()` than a regular value
(consistent with the `REQUEST_URI`) is emited into a page's header.

Thus the change is applied to almost all pages where it seems practical, with
a noteworthy exception of `/file` pages (that are handled in `src/info.c`)
and `/fileedit` pages.

It was chosen not to reuse `$current_page` variable as it may break
deployments of some users.

Administrators of Fossil instances do not need to take special actions
to benefit from this change, unless a custom header that overrides
the `<base>` generation is used. In the later case administrator is
advised to amend their code [accordingly][], unless the old semi-broken
behavior is desired.

Apart from the primary goal this branch also [fixes a subtle bug][bug]
and introduces (but does not document) [auxiliary TH1 variable][wpn]
and the [corresponding class on the `<body>`][body].

[`PATH_INFO`]: /artifact?name=b10651443f5c35ae&ln=1199-1209
[obstacle]:    forum:/forumpost/34afff1da99fdc891c37a35
[func]:        /file?ci=89dd34519f454333&name=src/style.c&ln=410-432
[accordingly]: /file?ci=89dd34519f454333&name=src/style.c&ln=677
[bug]:  /info/5ce372ce4843a239
[wpn]:  /file?ci=89dd34519f454333&name=src/style.c&ln=800
[body]: /file?ci=89dd34519f454333&name=src/style.c&ln=685
Z 8f66da911d7a85357bd9cf4c8bac56f1