Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | An attepmt to fix the
<base href="...">
element of webpages so that the value of href attribute
matches the URL being served.
This should fix "#fragment" hyperlinks on all pages where these
were broken (all except /doc ).
The values for /wiki and
/info were left unchanged
(it's yet unclear if they should also be changed).
|
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | base-href-fix |
Files: | files | file ages | folders |
SHA3-256: |
03b39f1d00ce06e67ee83ca92116e6f9 |
User & Date: | george 2022-02-12 19:53:00 |
Context
2022-02-12
| ||
21:51 |
Add an overlooked call to style_set_base_href_suffix() in src/info.c and add a comment of why not to do so for /ext
...
(check-in: 87fba731 user: george tags: base-href-fix)
| |
19:53 |
An attepmt to fix the
<base href="...">
element of webpages so that the value of href attribute
matches the URL being served.
This should fix "#fragment" hyperlinks on all pages where these
were broken (all except /doc ).
The values for /wiki and
/info were left unchanged
(it's yet unclear if they should also be changed).
...
(check-in: 03b39f1d user: george tags: base-href-fix)
| |
13:55 | Do not require mouse events for auto-hyperlink if the UserAgent string includes "Android". Describe the Safari visited/unvisited link limitation on the auto-hyperlink setting. ... (check-in: cef15ed3 user: drh tags: trunk) | |
Changes
Changes to src/info.c.
︙ | ︙ | |||
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 | @ <li>Executable file objType |= OBJTYPE_EXE; }else{ @ <li>File if( bNeedBase ){ bNeedBase = 0; style_set_current_page("doc/%S/%s",zVers,zName); } } objType |= OBJTYPE_CONTENT; @ %z(href("%R/finfo?name=%T&ci=%!S&m=%!S",zName,zVers,zUuid))\ @ %h(zName)</a> tag_private_status(rid); if( showDetail ){ | > | 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 | @ <li>Executable file objType |= OBJTYPE_EXE; }else{ @ <li>File if( bNeedBase ){ bNeedBase = 0; style_set_current_page("doc/%S/%s",zVers,zName); style_set_base_href_suffix("doc/%S/%s",zVers,zName); } } objType |= OBJTYPE_CONTENT; @ %z(href("%R/finfo?name=%T&ci=%!S&m=%!S",zName,zVers,zUuid))\ @ %h(zName)</a> tag_private_status(rid); if( showDetail ){ |
︙ | ︙ | |||
2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 | } } if( isFile ){ if( isSymbolicCI ){ zHeader = mprintf("%s at %s", file_tail(zName), zCI); style_set_current_page("doc/%t/%T", zCI, zName); }else if( zCIUuid && zCIUuid[0] ){ zHeader = mprintf("%s at [%S]", file_tail(zName), zCIUuid); style_set_current_page("doc/%S/%T", zCIUuid, zName); }else{ zHeader = mprintf("%s", file_tail(zName)); style_set_current_page("doc/tip/%T", zName); } }else if( descOnly ){ zHeader = mprintf("Artifact Description [%S]", zUuid); }else{ | > > | 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 | } } if( isFile ){ if( isSymbolicCI ){ zHeader = mprintf("%s at %s", file_tail(zName), zCI); style_set_current_page("doc/%t/%T", zCI, zName); style_set_base_href_suffix("doc/%t/%T", zCI, zName); }else if( zCIUuid && zCIUuid[0] ){ zHeader = mprintf("%s at [%S]", file_tail(zName), zCIUuid); style_set_current_page("doc/%S/%T", zCIUuid, zName); style_set_base_href_suffix("doc/%S/%T", zCIUuid, zName); }else{ zHeader = mprintf("%s", file_tail(zName)); style_set_current_page("doc/tip/%T", zName); } }else if( descOnly ){ zHeader = mprintf("Artifact Description [%S]", zUuid); }else{ |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
176 177 178 179 180 181 182 | int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */ char *zSshCmd; /* SSH command string */ const char *zHttpCmd; /* External program to do HTTP requests */ int fNoSync; /* Do not do an autosync ever. --nosync */ int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ char *zPath; /* Name of webpage being served */ char *zExtra; /* Extra path information past the webpage name */ | | > > | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */ char *zSshCmd; /* SSH command string */ const char *zHttpCmd; /* External program to do HTTP requests */ int fNoSync; /* Do not do an autosync ever. --nosync */ int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ char *zPath; /* Name of webpage being served */ char *zExtra; /* Extra path information past the webpage name */ char *zBaseURL; /* Full URL for the toplevel of the fossil tree */ const char *zUrlSuffix; /* Suffix of the URL including query string zBaseUrl/zUrlSuffix == Full text of the URL being served */ char *zHttpsURL; /* zBaseURL translated to https: */ char *zTop; /* Parent directory of zPath */ int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ const char *zExtRoot; /* Document root for the /ext sub-website */ const char *zContentType; /* The content type of the input HTTP request */ int iErrPriority; /* Priority of current error message */ char *zErrMsg; /* Text of an error message */ |
︙ | ︙ | |||
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 | ** g.zBaseURL and g.zTop is set from that instead. */ void set_base_url(const char *zAltBase){ int i; const char *zHost; const char *zMode; const char *zCur; if( g.zBaseURL!=0 ) return; if( zAltBase ){ int i, n, c; g.zTop = g.zBaseURL = mprintf("%s", zAltBase); i = (int)strlen(g.zBaseURL); while( i>3 && g.zBaseURL[i-1]=='/' ){ i--; } | > > > | 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 | ** g.zBaseURL and g.zTop is set from that instead. */ void set_base_url(const char *zAltBase){ int i; const char *zHost; const char *zMode; const char *zCur; const char *zRU; /* REQUEST_URI */ const char *zQS; /* QUERY_STRING */ size_t nTop; /* length of g.zTop */ if( g.zBaseURL!=0 ) return; if( zAltBase ){ int i, n, c; g.zTop = g.zBaseURL = mprintf("%s", zAltBase); i = (int)strlen(g.zBaseURL); while( i>3 && g.zBaseURL[i-1]=='/' ){ i--; } |
︙ | ︙ | |||
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 | g.zBaseURL = mprintf("http://%s%.*s", z, i, zCur); g.zTop = &g.zBaseURL[7+strlen(z)]; g.zHttpsURL = mprintf("https://%s%.*s", z, i, zCur); } fossil_free(z); } /* Try to record the base URL as a CONFIG table entry with a name ** of the form: "baseurl:BASE". This keeps a record of how the ** the repository is used as a server, to help in answering questions ** like "where is the CGI script that references this repository?" ** ** This is just a logging hint. So don't worry if it cannot be done. ** Don't try this if the repository database is not writable, for | > > > > > > > > | 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | g.zBaseURL = mprintf("http://%s%.*s", z, i, zCur); g.zTop = &g.zBaseURL[7+strlen(z)]; g.zHttpsURL = mprintf("https://%s%.*s", z, i, zCur); } fossil_free(z); } zRU = PD("REQUEST_URI",""); nTop = strlen( g.zTop ); g.zUrlSuffix = strncmp(zRU,g.zTop,nTop) ? "" : zRU+nTop; if(g.zUrlSuffix[0]=='/') g.zUrlSuffix++; zQS = PD("QUERY_STRING",""); if( zQS[0] ) g.zUrlSuffix = mprintf("%s?%s", g.zUrlSuffix, zQS); else g.zUrlSuffix = mprintf("%s", g.zUrlSuffix); /* Try to record the base URL as a CONFIG table entry with a name ** of the form: "baseurl:BASE". This keeps a record of how the ** the repository is used as a server, to help in answering questions ** like "where is the CGI script that references this repository?" ** ** This is just a logging hint. So don't worry if it cannot be done. ** Don't try this if the repository database is not writable, for |
︙ | ︙ |
Changes to src/style.c.
︙ | ︙ | |||
402 403 404 405 406 407 408 409 410 411 412 413 414 415 | }else{ va_list ap; va_start(ap, zFormat); local_zCurrentPage = vmprintf(zFormat, ap); va_end(ap); } } /* ** Create a TH1 variable containing the URL for the stylesheet. ** ** The name of the new variable will be "stylesheet_url". ** ** The value will be a URL for accessing the appropriate stylesheet. | > > > > > > > > > > > > > > > > > > > > | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | }else{ va_list ap; va_start(ap, zFormat); local_zCurrentPage = vmprintf(zFormat, ap); va_end(ap); } } /* Use this for the $base_href_suffix variable if it is not NULL. ** If it is NULL then use g.zUrlSuffix */ static char *local_zBaseHrefSuffix = 0; /* ** Set the desired $base_href_suffix to something other than g.zUrlSuffix */ void style_set_base_href_suffix(const char *zFormat, ...){ fossil_free(local_zBaseHrefSuffix); if( zFormat==0 ){ local_zBaseHrefSuffix = 0; }else{ va_list ap; va_start(ap, zFormat); local_zBaseHrefSuffix = vmprintf(zFormat, ap); va_end(ap); } } /* ** Create a TH1 variable containing the URL for the stylesheet. ** ** The name of the new variable will be "stylesheet_url". ** ** The value will be a URL for accessing the appropriate stylesheet. |
︙ | ︙ | |||
645 646 647 648 649 650 651 | ** Default HTML page header text through <body>. If the repository-specific ** header template lacks a <body> tag, then all of the following is ** prepended. */ static const char zDfltHeader[] = @ <html> @ <head> | | | 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | ** Default HTML page header text through <body>. If the repository-specific ** header template lacks a <body> tag, then all of the following is ** prepended. */ static const char zDfltHeader[] = @ <html> @ <head> @ <base href="$baseurl/$base_href_suffix" /> @ <meta charset="UTF-8"> @ <meta http-equiv="Content-Security-Policy" content="$default_csp" /> @ <meta name="viewport" content="width=device-width, initial-scale=1.0"> @ <title>$<project_name>: $<title></title> @ <link rel="alternate" type="application/rss+xml" title="RSS Feed" \ @ href="$home/timeline.rss" /> @ <link rel="stylesheet" href="$stylesheet_url" type="text/css" /> |
︙ | ︙ | |||
767 768 769 770 771 772 773 774 775 776 777 778 779 780 | if( zTitle ) Th_Store("title", zTitle); Th_Store("baseurl", g.zBaseURL); Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); Th_Store("home", g.zTop); Th_Store("index_page", db_get("index-page","/home")); if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath); Th_Store("current_page", local_zCurrentPage); Th_Store("csrf_token", g.zCsrfToken); Th_Store("release_version", RELEASE_VERSION); Th_Store("manifest_version", MANIFEST_VERSION); Th_Store("manifest_date", MANIFEST_DATE); Th_Store("compiler_name", COMPILER_NAME); Th_Store("mainmenu", style_get_mainmenu()); stylesheet_url_var(); | > > > > > > | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | if( zTitle ) Th_Store("title", zTitle); Th_Store("baseurl", g.zBaseURL); Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); Th_Store("home", g.zTop); Th_Store("index_page", db_get("index-page","/home")); if( local_zCurrentPage==0 ) style_set_current_page("%T", g.zPath); Th_Store("current_page", local_zCurrentPage); if( local_zBaseHrefSuffix==0 ){ style_set_base_href_suffix("%s",g.zUrlSuffix); /* %s because g.zUrlSuffix is already encoded (FIXME: really so?) */ } Th_Store("base_href_suffix", local_zBaseHrefSuffix); Th_Store("requested_url_suffix", g.zUrlSuffix); Th_Store("csrf_token", g.zCsrfToken); Th_Store("release_version", RELEASE_VERSION); Th_Store("manifest_version", MANIFEST_VERSION); Th_Store("manifest_date", MANIFEST_DATE); Th_Store("compiler_name", COMPILER_NAME); Th_Store("mainmenu", style_get_mainmenu()); stylesheet_url_var(); |
︙ | ︙ | |||
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 | if( isAuth ){ #if !defined(_WIN32) @ uid=%d(getuid()), gid=%d(getgid())<br /> #endif @ g.zBaseURL = %h(g.zBaseURL)<br /> @ g.zHttpsURL = %h(g.zHttpsURL)<br /> @ g.zTop = %h(g.zTop)<br /> @ g.zPath = %h(g.zPath)<br /> @ g.userUid = %d(g.userUid)<br /> @ g.zLogin = %h(g.zLogin)<br /> @ g.isHuman = %d(g.isHuman)<br /> @ g.javascriptHyperlink = %d(g.javascriptHyperlink)<br /> if( g.nRequest ){ | > | 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 | if( isAuth ){ #if !defined(_WIN32) @ uid=%d(getuid()), gid=%d(getgid())<br /> #endif @ g.zBaseURL = %h(g.zBaseURL)<br /> @ g.zHttpsURL = %h(g.zHttpsURL)<br /> @ g.zUrlSuffix = %h(g.zUrlSuffix)<br /> @ g.zTop = %h(g.zTop)<br /> @ g.zPath = %h(g.zPath)<br /> @ g.userUid = %d(g.userUid)<br /> @ g.zLogin = %h(g.zLogin)<br /> @ g.isHuman = %d(g.isHuman)<br /> @ g.javascriptHyperlink = %d(g.javascriptHyperlink)<br /> if( g.nRequest ){ |
︙ | ︙ |
Changes to src/wiki.c.
︙ | ︙ | |||
595 596 597 598 599 600 601 602 603 604 605 606 607 608 | } if( g.perm.Hyperlink ){ style_submenu_element("History", "%R/whistory?name=%T", zPageName); } } if( !isPopup ){ style_set_current_page("%T?name=%T", g.zPath, zPageName); wiki_page_header(WIKITYPE_UNKNOWN, zPageName, ""); if( !noSubmenu ){ wiki_standard_submenu(submenuFlags); } } if( zBody[0]==0 ){ @ <i>This page has been deleted</i> | > | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | } if( g.perm.Hyperlink ){ style_submenu_element("History", "%R/whistory?name=%T", zPageName); } } if( !isPopup ){ style_set_current_page("%T?name=%T", g.zPath, zPageName); style_set_base_href_suffix("%T?name=%T", g.zPath, zPageName); wiki_page_header(WIKITYPE_UNKNOWN, zPageName, ""); if( !noSubmenu ){ wiki_standard_submenu(submenuFlags); } } if( zBody[0]==0 ){ @ <i>This page has been deleted</i> |
︙ | ︙ | |||
1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | } if( !isSandbox && P("cancel")!=0 ){ manifest_destroy(pWiki); cgi_redirectf("wiki?name=%T", zPageName); return; } style_set_current_page("%T?name=%T", g.zPath, zPageName); style_set_current_feature("wiki"); style_header("Append Comment To: %s", zPageName); if( !goodCaptcha ){ @ <p class="generalError">Error: Incorrect security code.</p> } if( isSandbox ){ @ <p class="generalError">Error: the Sandbox page may not | > | 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 | } if( !isSandbox && P("cancel")!=0 ){ manifest_destroy(pWiki); cgi_redirectf("wiki?name=%T", zPageName); return; } style_set_current_page("%T?name=%T", g.zPath, zPageName); style_set_base_href_suffix("%T?name=%T", g.zPath, zPageName); style_set_current_feature("wiki"); style_header("Append Comment To: %s", zPageName); if( !goodCaptcha ){ @ <p class="generalError">Error: Incorrect security code.</p> } if( isSandbox ){ @ <p class="generalError">Error: the Sandbox page may not |
︙ | ︙ |