Fossil

Update of "branch/base-href-fix"
Login

Update of "branch/base-href-fix"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: dfe2d24c5aeb3032344e5782fa50d0574bc43e481f17bde3c5bdacb06bb0e8de
Page Name:branch/base-href-fix
Date: 2022-02-15 20:53:49
Original User: george
Mimetype:text/x-markdown
Content

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 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() 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 and introduces (but does not document) auxiliary TH1 variable and the corresponding class on the <body>.