Fossil

Check-in [b05a6c6bc8]
Login

Check-in [b05a6c6bc8]

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

Overview
Comment:Supply TH1 interpreter with two auxiliary variables: <var>$requested_page</var> (holds the first segment of the requested [/file/src/cgi.c?ln=1199-1209&ci=2022-05-09|PATH_INFO]) and <var>$canonical_page</var> (holds the canonical name of a web-page being served). Also amend default HTML header: add two corresponding classes to the BODY element and move <code><meta charset="UTF-8"></code> to the top.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b05a6c6bc826d3c29a4b4a3bde3e20e7337293098c77db135475372ff310b27e
User & Date: george 2022-05-09 21:22:41.795
References
2022-05-11
21:23
Ensure that <var>$requested_page</var> is always initialized. This is a follow-up to [c68fa2edd76d90] that fixes a bug in [b05a6c6bc826d3]. ... (check-in: a44e3c7338 user: george tags: trunk)
11:08
Fix NULL pointer dereference introduced by check-in [b05a6c6bc826d3c2]. Fix for the problem reported by [forum:/forumpost/bfb99db2886ca3b5|forum post/bfb99db2886ca3b5]. ... (check-in: c68fa2edd7 user: drh tags: trunk)
Context
2022-05-10
11:54
Update the built-in SQLite to the latest 3.39.0 alpha for testing. ... (check-in: 0833f7225b user: drh tags: trunk)
2022-05-09
21:22
Supply TH1 interpreter with two auxiliary variables: <var>$requested_page</var> (holds the first segment of the requested [/file/src/cgi.c?ln=1199-1209&ci=2022-05-09|PATH_INFO]) and <var>$canonical_page</var> (holds the canonical name of a web-page being served). Also amend default HTML header: add two corresponding classes to the BODY element and move <code><meta charset="UTF-8"></code> to the top. ... (check-in: b05a6c6bc8 user: george tags: trunk)
2022-05-04
11:47
/timeline: correct rendering of event.comment entries for wiki attachments, per problem reported in [forum:749baecf6d08ecb1 | forum post 749baecf6d08ecb1]. ... (check-in: b3e534fa88 user: stephan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
136
137
138
139
140
141
142
143

144
145
146
147
148
149
150
};
#endif

struct Global {
  int argc; char **argv;  /* Command-line arguments to the program */
  char *nameOfExe;        /* Full path of executable. */
  const char *zErrlog;    /* Log errors to this file, if not NULL */
  const char *zPhase;     /* Phase of operation, for use by the error log */

  int isConst;            /* True if the output is unchanging & cacheable */
  const char *zVfsName;   /* The VFS to use for database connections */
  sqlite3 *db;            /* The connection to the databases */
  sqlite3 *dbConfig;      /* Separate connection for global_config table */
  char *zAuxSchema;       /* Main repository aux-schema */
  int dbIgnoreErrors;     /* Ignore database errors if true */
  char *zConfigDbName;    /* Path of the config database. NULL if not open */







|
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
};
#endif

struct Global {
  int argc; char **argv;  /* Command-line arguments to the program */
  char *nameOfExe;        /* Full path of executable. */
  const char *zErrlog;    /* Log errors to this file, if not NULL */
  const char *zPhase;     /* Phase of operation, for use by the error log
                          ** and for deriving $canonical_page TH1 variable */
  int isConst;            /* True if the output is unchanging & cacheable */
  const char *zVfsName;   /* The VFS to use for database connections */
  sqlite3 *db;            /* The connection to the databases */
  sqlite3 *dbConfig;      /* Separate connection for global_config table */
  char *zAuxSchema;       /* Main repository aux-schema */
  int dbIgnoreErrors;     /* Ignore database errors if true */
  char *zConfigDbName;    /* Path of the config database. NULL if not open */
Changes to src/style.c.
645
646
647
648
649
650
651
652
653

654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
** 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/$current_page" />
@ <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" />
@ </head>
@ <body class="$current_feature">
;

/*
** Returns the default page header.
*/
const char *get_default_header(){
  return zDfltHeader;







<

>







|







645
646
647
648
649
650
651

652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
** 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>

@ <meta charset="UTF-8">
@ <base href="$baseurl/$current_page" />
@ <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" />
@ </head>
@ <body class="$current_feature rpage-$requested_page cpage-$canonical_page">
;

/*
** Returns the default page header.
*/
const char *get_default_header(){
  return zDfltHeader;
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773





774
775
776
777
778
779
780
}

/*
** Initialize all the default TH1 variables
*/
static void style_init_th1_vars(const char *zTitle){
  const char *zNonce = style_nonce();
  char *zDfltCsp;

  zDfltCsp = style_csp(1);
  /*
  ** Do not overwrite the TH1 variable "default_csp" if it exists, as this
  ** allows it to be properly overridden via the TH1 setup script (i.e. it
  ** is evaluated before the header is rendered).
  */
  Th_MaybeStore("default_csp", zDfltCsp);
  fossil_free(zDfltCsp);
  Th_Store("nonce", zNonce);
  Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
  Th_Store("project_description", db_get("project-description",""));
  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();







|



















>
>
>
>
>







747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
}

/*
** Initialize all the default TH1 variables
*/
static void style_init_th1_vars(const char *zTitle){
  const char *zNonce = style_nonce();
  char *zDfltCsp, *zSlash = 0;

  zDfltCsp = style_csp(1);
  /*
  ** Do not overwrite the TH1 variable "default_csp" if it exists, as this
  ** allows it to be properly overridden via the TH1 setup script (i.e. it
  ** is evaluated before the header is rendered).
  */
  Th_MaybeStore("default_csp", zDfltCsp);
  fossil_free(zDfltCsp);
  Th_Store("nonce", zNonce);
  Th_Store("project_name", db_get("project-name","Unnamed Fossil Project"));
  Th_Store("project_description", db_get("project-description",""));
  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);
  /* store the first segment of a path; make a temporary cut if necessary */
  if(( zSlash = strchr(g.zPath,'/') )) *zSlash = 0;
  Th_Store("requested_page", escape_quotes(g.zPath));
  if( zSlash ) *zSlash = '/';
  Th_Store("canonical_page", escape_quotes(g.zPhase+1));
  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();