Index: auto.def ================================================================== --- auto.def +++ auto.def @@ -5,10 +5,11 @@ options { with-openssl:path|auto|none => {Look for OpenSSL in the given path, or auto or none} with-miniz=0 => {Use miniz from the source tree} with-zlib:path => {Look for zlib in the given path} + with-th1-docs=0 => {Enable TH1 for embedded documentation pages} with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages} with-tcl:path => {Enable Tcl integration, with Tcl in the specified path} with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism} with-tcl-private-stubs=0 => {Enable Tcl integration via private stubs mechanism} @@ -84,10 +85,16 @@ # reading config.h first. define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON define FOSSIL_ENABLE_JSON msg-result "JSON support enabled" } + +if {[opt-bool with-th1-docs]} { + define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS + define FOSSIL_ENABLE_TH1_DOCS + msg-result "TH1 embedded documentation support enabled" +} if {[opt-bool with-th1-hooks]} { define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_HOOKS define FOSSIL_ENABLE_TH1_HOOKS msg-result "TH1 hooks support enabled" Index: src/configure.c ================================================================== --- src/configure.c +++ src/configure.c @@ -97,10 +97,13 @@ { "timeline-max-comment", CONFIGSET_SKIN }, { "timeline-plaintext", CONFIGSET_SKIN }, { "adunit", CONFIGSET_SKIN }, { "adunit-omit-if-admin", CONFIGSET_SKIN }, { "adunit-omit-if-user", CONFIGSET_SKIN }, +#ifdef FOSSIL_ENABLE_TH1_DOCS + { "th1-docs", CONFIGSET_TH1 }, +#endif #ifdef FOSSIL_ENABLE_TH1_HOOKS { "th1-hooks", CONFIGSET_TH1 }, #endif { "th1-setup", CONFIGSET_TH1 }, { "th1-uri-regexp", CONFIGSET_TH1 }, Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -2201,10 +2201,13 @@ { "ssl-identity", 0, 40, 0, 0, "" }, #ifdef FOSSIL_ENABLE_TCL { "tcl", 0, 0, 0, 0, "off" }, { "tcl-setup", 0, 40, 1, 1, "" }, #endif +#ifdef FOSSIL_ENABLE_TH1_DOCS + { "th1-docs", 0, 0, 0, 0, "off" }, +#endif #ifdef FOSSIL_ENABLE_TH1_HOOKS { "th1-hooks", 0, 0, 0, 0, "off" }, #endif { "th1-setup", 0, 40, 1, 1, "" }, { "th1-uri-regexp", 0, 40, 1, 0, "" }, @@ -2410,10 +2413,20 @@ ** expressions and scripts. Default: off. ** ** tcl-setup This is the setup script to be evaluated after creating ** (versionable) and initializing the Tcl interpreter. By default, this ** is empty and no extra setup is performed. +** +** th1-docs WARNING: If enabled (and Fossil was compiled with TH1 +** support for embedded documentation files), this allows +** embedded documentation files to contain arbitrary TH1 +** scripts that are evaluated on the server. If native +** Tcl integration is also enabled, this setting has the +** potential to allow anybody with check-in privileges to +** do almost anything that the associated operating system +** user account could do. Extreme caution should be used +** when enabling this setting. Default: off. ** ** th1-hooks If enabled (and Fossil was compiled with support for TH1 ** hooks), special TH1 commands will be called before and ** after any Fossil command or web page. Default: off. ** Index: src/doc.c ================================================================== --- src/doc.c +++ src/doc.c @@ -256,10 +256,11 @@ { "tcl", 3, "application/x-tcl" }, { "tex", 3, "application/x-tex" }, { "texi", 4, "application/x-texinfo" }, { "texinfo", 7, "application/x-texinfo" }, { "tgz", 3, "application/x-tar-gz" }, + { "th1", 3, "application/x-th1" }, { "tif", 3, "image/tiff" }, { "tiff", 4, "image/tiff" }, { "tr", 2, "application/x-troff" }, { "tsi", 3, "audio/TSP-audio" }, { "tsp", 3, "application/dsptype" }, @@ -524,10 +525,19 @@ style_header("Documentation"); @
     @ %h(blob_str(&filebody))
     @ 
style_footer(); +#ifdef FOSSIL_ENABLE_TH1_DOCS + }else if( db_get_boolean("th1-docs", 0) && + fossil_strcmp(zMime, "application/x-th1")==0 ){ + char *zHtml = htmlize(zName, -1); + style_header(zHtml); + Th_Render(blob_str(&filebody)); + style_footer(); + fossil_free(zHtml); +#endif }else{ cgi_set_content_type(zMime); cgi_set_content(&filebody); } return; Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -975,10 +975,13 @@ #else fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion()); #endif #if defined(FOSSIL_ENABLE_SSL) fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION)); +#endif +#if defined(FOSSIL_ENABLE_TH1_DOCS) + fossil_print("TH1_DOCS\n"); #endif #if defined(FOSSIL_ENABLE_TH1_HOOKS) fossil_print("TH1_HOOKS\n"); #endif #if defined(FOSSIL_ENABLE_TCL) Index: src/makemake.tcl ================================================================== --- src/makemake.tcl +++ src/makemake.tcl @@ -444,10 +444,14 @@ #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 + +#### Enable TH1 scripts in embedded documentation files +# +# FOSSIL_ENABLE_TH1_DOCS = 1 #### Enable hooks for commands and web pages via TH1 # # FOSSIL_ENABLE_TH1_HOOKS = 1 @@ -597,10 +601,16 @@ # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif + +# With TH1 embedded docs support +ifdef FOSSIL_ENABLE_TH1_DOCS +TCC += -DFOSSIL_ENABLE_TH1_DOCS=1 +RCC += -DFOSSIL_ENABLE_TH1_DOCS=1 +endif # With TH1 hook support ifdef FOSSIL_ENABLE_TH1_HOOKS TCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 RCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 @@ -1157,10 +1167,13 @@ # Uncomment to enable miniz usage # FOSSIL_ENABLE_MINIZ = 1 # Uncomment to enable SSL support # FOSSIL_ENABLE_SSL = 1 + +# Uncomment to enable TH1 scripts in embedded documentation files +# FOSSIL_ENABLE_TH1_DOCS = 1 # Uncomment to enable TH1 hooks # FOSSIL_ENABLE_TH1_HOOKS = 1 # Uncomment to enable Tcl support @@ -1233,10 +1246,15 @@ TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1 LIBS = $(LIBS) $(SSLLIB) LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR) !endif + +!ifdef FOSSIL_ENABLE_TH1_DOCS +TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1 +RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1 +!endif !ifdef FOSSIL_ENABLE_TH1_HOOKS TCC = $(TCC) /DFOSSIL_ENABLE_TH1_HOOKS=1 RCC = $(RCC) /DFOSSIL_ENABLE_TH1_HOOKS=1 !endif Index: src/th_main.c ================================================================== --- src/th_main.c +++ src/th_main.c @@ -373,10 +373,11 @@ ** ** Return true if the fossil binary has the given compile-time feature ** enabled. The set of features includes: ** ** "ssl" = FOSSIL_ENABLE_SSL +** "th1Docs" = FOSSIL_ENABLE_TH1_DOCS ** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS ** "tcl" = FOSSIL_ENABLE_TCL ** "useTclStubs" = USE_TCL_STUBS ** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS ** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS @@ -402,10 +403,15 @@ } #if defined(FOSSIL_ENABLE_SSL) else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){ rc = 1; } +#endif +#if defined(FOSSIL_ENABLE_TH1_DOCS) + else if( 0 == fossil_strnicmp( zArg, "th1Docs\0", 8 ) ){ + rc = 1; + } #endif #if defined(FOSSIL_ENABLE_TH1_HOOKS) else if( 0 == fossil_strnicmp( zArg, "th1Hooks\0", 9 ) ){ rc = 1; } Index: win/Makefile.mingw ================================================================== --- win/Makefile.mingw +++ win/Makefile.mingw @@ -52,10 +52,14 @@ #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 + +#### Enable TH1 scripts in embedded documentation files +# +# FOSSIL_ENABLE_TH1_DOCS = 1 #### Enable hooks for commands and web pages via TH1 # # FOSSIL_ENABLE_TH1_HOOKS = 1 @@ -205,10 +209,16 @@ # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif + +# With TH1 embedded docs support +ifdef FOSSIL_ENABLE_TH1_DOCS +TCC += -DFOSSIL_ENABLE_TH1_DOCS=1 +RCC += -DFOSSIL_ENABLE_TH1_DOCS=1 +endif # With TH1 hook support ifdef FOSSIL_ENABLE_TH1_HOOKS TCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 RCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 Index: win/Makefile.mingw.mistachkin ================================================================== --- win/Makefile.mingw.mistachkin +++ win/Makefile.mingw.mistachkin @@ -52,10 +52,14 @@ #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 + +#### Enable TH1 scripts in embedded documentation files +# +# FOSSIL_ENABLE_TH1_DOCS = 1 #### Enable hooks for commands and web pages via TH1 # FOSSIL_ENABLE_TH1_HOOKS = 1 @@ -205,10 +209,16 @@ # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif + +# With TH1 embedded docs support +ifdef FOSSIL_ENABLE_TH1_DOCS +TCC += -DFOSSIL_ENABLE_TH1_DOCS=1 +RCC += -DFOSSIL_ENABLE_TH1_DOCS=1 +endif # With TH1 hook support ifdef FOSSIL_ENABLE_TH1_HOOKS TCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 RCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 Index: win/Makefile.msc ================================================================== --- win/Makefile.msc +++ win/Makefile.msc @@ -26,10 +26,13 @@ # Uncomment to enable miniz usage # FOSSIL_ENABLE_MINIZ = 1 # Uncomment to enable SSL support # FOSSIL_ENABLE_SSL = 1 + +# Uncomment to enable TH1 scripts in embedded documentation files +# FOSSIL_ENABLE_TH1_DOCS = 1 # Uncomment to enable TH1 hooks # FOSSIL_ENABLE_TH1_HOOKS = 1 # Uncomment to enable Tcl support @@ -102,10 +105,15 @@ TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1 LIBS = $(LIBS) $(SSLLIB) LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR) !endif + +!ifdef FOSSIL_ENABLE_TH1_DOCS +TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1 +RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1 +!endif !ifdef FOSSIL_ENABLE_TH1_HOOKS TCC = $(TCC) /DFOSSIL_ENABLE_TH1_HOOKS=1 RCC = $(RCC) /DFOSSIL_ENABLE_TH1_HOOKS=1 !endif Index: win/fossil.rc ================================================================== --- win/fossil.rc +++ win/fossil.rc @@ -115,10 +115,15 @@ VALUE "CommandLineIsUnicode", "Yes\0" #endif /* defined(BROKEN_MINGW_CMDLINE) */ #if defined(FOSSIL_ENABLE_SSL) VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0" #endif /* defined(FOSSIL_ENABLE_SSL) */ +#if defined(FOSSIL_ENABLE_TH1_DOCS) + VALUE "Th1Docs", "Yes\0" +#else + VALUE "Th1Docs", "No\0" +#endif /* defined(FOSSIL_ENABLE_TH1_DOCS) */ #if defined(FOSSIL_ENABLE_TH1_HOOKS) VALUE "Th1Hooks", "Yes\0" #else VALUE "Th1Hooks", "No\0" #endif /* defined(FOSSIL_ENABLE_TH1_HOOKS) */