Fossil

Changes On Branch th1Hash
Login

Changes On Branch th1Hash

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

Changes In Branch th1Hash Excluding Merge-Ins

This is equivalent to a diff from b1c0409a56 to e3df21cdf1

2023-05-22
21:00
Fixed a symmetry problem in the vfile.chnged implementation: it had an explicit check for when a file used to be a regular file and was replaced by a symlink pointing to the same content, but it didn't then check for the inverse case. Since the size and hash checks become nonsense when both files aren't of the same type (whether symlinks or regular files) we have to check for this case, too, else the only way to get the "UNLINK" output from "fossil status" required trickery. See [forum:/forumpost/204ff988263d7795 | this forum post] for a test case and the trick previously needed to get Fossil to report "UNLINK" as a file's change status. ... (check-in: 4cca90338a user: wyoung tags: trunk)
2023-05-21
03:37
Merge updates from trunk. ... (Leaf check-in: e3df21cdf1 user: mistachkin tags: th1Hash)
2023-05-18
21:15
Enhancements to SEE integration. ... (check-in: d72ab72962 user: mistachkin tags: enhSee)
17:02
Update Pikchr to omit the artifical enlargement of "mono" text. ... (check-in: b1c0409a56 user: drh tags: trunk)
16:49
Update the built-in Pikchr to the version that supports "mono". There is an issue with the WASM module yet to be resolved. ... (check-in: 43eefe66ed user: drh tags: trunk)
2022-10-17
01:02
Merge updates from trunk. ... (check-in: 6f3640a71d user: mistachkin tags: th1Hash)

Changes to src/th_main.c.

933
934
935
936
937
938
939

940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS
** "json"            = FOSSIL_ENABLE_JSON
** "markdown"        = FOSSIL_ENABLE_MARKDOWN
** "unicodeCmdLine"  = !BROKEN_MINGW_CMDLINE
** "dynamicBuild"    = FOSSIL_DYNAMIC_BUILD
** "mman"            = USE_MMAN_H
** "see"             = USE_SEE

**
** Specifying an unknown feature will return a value of false, it will not
** raise a script error.
*/
static int hasfeatureCmd(
  Th_Interp *interp,
  void *p,
  int argc,
  const char **argv,
  int *argl
){
  int rc = 0;
  const char *zArg;
  if( argc!=2 ){
    return Th_WrongNumArgs(interp, "hasfeature STRING");
  }
  zArg = (const char *)argv[1];
  if(NULL==zArg){
    /* placeholder for following ifdefs... */
  }
#if defined(FOSSIL_ENABLE_SSL)
  else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){
    rc = 1;
  }







>
















|







933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS
** "json"            = FOSSIL_ENABLE_JSON
** "markdown"        = FOSSIL_ENABLE_MARKDOWN
** "unicodeCmdLine"  = !BROKEN_MINGW_CMDLINE
** "dynamicBuild"    = FOSSIL_DYNAMIC_BUILD
** "mman"            = USE_MMAN_H
** "see"             = USE_SEE
** "hardenedSha1"    = FOSSIL_HARDENED_SHA1
**
** Specifying an unknown feature will return a value of false, it will not
** raise a script error.
*/
static int hasfeatureCmd(
  Th_Interp *interp,
  void *p,
  int argc,
  const char **argv,
  int *argl
){
  int rc = 0;
  const char *zArg;
  if( argc!=2 ){
    return Th_WrongNumArgs(interp, "hasfeature STRING");
  }
  zArg = argv[1];
  if(NULL==zArg){
    /* placeholder for following ifdefs... */
  }
#if defined(FOSSIL_ENABLE_SSL)
  else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){
    rc = 1;
  }
1020
1021
1022
1023
1024
1025
1026





1027
1028
1029
1030
1031
1032
1033
1034
1035
1036






















































1037
1038
1039
1040
1041
1042
1043
    rc = 1;
  }
#endif
#if defined(USE_SEE)
  else if( 0 == fossil_strnicmp( zArg, "see\0", 4 ) ){
    rc = 1;
  }





#endif
  else if( 0 == fossil_strnicmp( zArg, "markdown\0", 9 ) ){
    rc = 1;
  }
  if( g.thTrace ){
    Th_Trace("[hasfeature %#h] => %d<br>\n", argl[1], zArg, rc);
  }
  Th_SetResultInt(interp, rc);
  return TH_OK;
}
























































/*
** TH1 command: tclReady
**
** Return true if the fossil binary has the Tcl integration feature
** enabled and it is currently available for use by TH1 scripts.







>
>
>
>
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
    rc = 1;
  }
#endif
#if defined(USE_SEE)
  else if( 0 == fossil_strnicmp( zArg, "see\0", 4 ) ){
    rc = 1;
  }
#endif
#if FOSSIL_HARDENED_SHA1
  else if( 0 == fossil_strnicmp( zArg, "hardenedSha1\0", 13 ) ){
    rc = 1;
  }
#endif
  else if( 0 == fossil_strnicmp( zArg, "markdown\0", 9 ) ){
    rc = 1;
  }
  if( g.thTrace ){
    Th_Trace("[hasfeature %#h] => %d<br>\n", argl[1], zArg, rc);
  }
  Th_SetResultInt(interp, rc);
  return TH_OK;
}

/*
** TH1 command: hash STRING ?ALGORITHM?
**
** Returns the cryptographic hash of the specified string.  Possible values
** for the ALGORITHM argument are:
**
** "md5"
** "sha1"
** "sha3-224"
** "sha3-256"
** "sha3-384"
** "sha3-512"
**
** The default algorithm is "sha3-256".  Specifying an unknown algorithm
** will raise a script error.
*/
static int hashCmd(
  Th_Interp *interp,
  void *p,
  int argc,
  const char **argv,
  int *argl
){
  Blob content;
  Blob cksum;
  const char *zAlgorithm = "sha3-256";
  if( argc<2 || argc>3 ){
    return Th_WrongNumArgs(interp, "hash STRING ?ALGORITHM?");
  }
  blob_init(&content, argv[1], argl[1]);
  blob_zero(&cksum);
  if( argc>=3 ){
    zAlgorithm = argv[2];
  }
  if( 0 == fossil_strnicmp( zAlgorithm, "md5\0", 4 ) ){
    md5sum_blob(&content, &cksum);
  }else if( 0 == fossil_strnicmp( zAlgorithm, "sha1\0", 5 ) ){
    sha1sum_blob(&content, &cksum);
  }else if( 0 == fossil_strnicmp( zAlgorithm, "sha3-224\0", 9 ) ){
    sha3sum_blob(&content, 224, &cksum);
  }else if( 0 == fossil_strnicmp( zAlgorithm, "sha3-256\0", 9 ) ){
    sha3sum_blob(&content, 256, &cksum);
  }else if( 0 == fossil_strnicmp( zAlgorithm, "sha3-384\0", 9 ) ){
    sha3sum_blob(&content, 384, &cksum);
  }else if( 0 == fossil_strnicmp( zAlgorithm, "sha3-512\0", 9 ) ){
    sha3sum_blob(&content, 512, &cksum);
  }else{
    Th_SetResult(interp, "unknown hash algorithm", -1);
    return TH_ERROR;
  }
  Th_SetResult(interp, blob_str(&cksum), -1);
  return TH_OK;
}


/*
** TH1 command: tclReady
**
** Return true if the fossil binary has the Tcl integration feature
** enabled and it is currently available for use by TH1 scripts.
2339
2340
2341
2342
2343
2344
2345

2346
2347
2348
2349
2350
2351
2352
    {"encode64",      encode64Cmd,          0},
    {"getParameter",  getParameterCmd,      0},
    {"glob_match",    globMatchCmd,         0},
    {"globalState",   globalStateCmd,       0},
    {"httpize",       httpizeCmd,           0},
    {"hascap",        hascapCmd,            (void*)&zeroInt},
    {"hasfeature",    hasfeatureCmd,        0},

    {"html",          putsCmd,              (void*)&aFlags[0]},
    {"htmlize",       htmlizeCmd,           0},
    {"http",          httpCmd,              0},
    {"insertCsrf",    insertCsrfCmd,        0},
    {"linecount",     linecntCmd,           0},
    {"markdown",      markdownCmd,          0},
    {"nonce",         nonceCmd,             0},







>







2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
    {"encode64",      encode64Cmd,          0},
    {"getParameter",  getParameterCmd,      0},
    {"glob_match",    globMatchCmd,         0},
    {"globalState",   globalStateCmd,       0},
    {"httpize",       httpizeCmd,           0},
    {"hascap",        hascapCmd,            (void*)&zeroInt},
    {"hasfeature",    hasfeatureCmd,        0},
    {"hash",          hashCmd,              0},
    {"html",          putsCmd,              (void*)&aFlags[0]},
    {"htmlize",       htmlizeCmd,           0},
    {"http",          httpCmd,              0},
    {"insertCsrf",    insertCsrfCmd,        0},
    {"linecount",     linecntCmd,           0},
    {"markdown",      markdownCmd,          0},
    {"nonce",         nonceCmd,             0},

Changes to test/th1.test.

1694
1695
1696
1697
1698
1699
1700





















































1701
1702
1703
1704
test th1-unversioned-1 {[normalize_result] eq {ten.txt}}

# unversioned content
fossil test-th-eval --open-config \
      {string length [unversioned content ten.txt]}
test th1-unversioned-2 {$RESULT eq {10}}























































###############################################################################

test_cleanup







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
test th1-unversioned-1 {[normalize_result] eq {ten.txt}}

# unversioned content
fossil test-th-eval --open-config \
      {string length [unversioned content ten.txt]}
test th1-unversioned-2 {$RESULT eq {10}}


###############################################################################

fossil test-th-eval {hash foo}
test th1-hash-1 {$RESULT eq \
"76d3bc41c9f588f7fcd0d5bf4718f8f84b1c41b20882703100b9eb9413807c01"}

###############################################################################

fossil test-th-eval {hash foo bad}
test th1-hash-2 {$RESULT eq "TH_ERROR: unknown hash algorithm"}

###############################################################################

fossil test-th-eval {hash foo md5}
test th1-hash-3 {$RESULT eq "acbd18db4cc2f85cedef654fccc4a4d8"}

###############################################################################

fossil test-th-eval {hash foo md5 bad}
test th1-hash-4 {$RESULT eq \
"TH_ERROR: wrong # args: should be \"hash STRING ?ALGORITHM?\""}

###############################################################################

fossil test-th-eval {hash foo sha1}
test th1-hash-5 {$RESULT eq "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"}

###############################################################################

fossil test-th-eval {hash foo sha3-224}
test th1-hash-6 {$RESULT eq \
"f4f6779e153c391bbd29c95e72b0708e39d9166c7cea51d1f10ef58a"}

###############################################################################

fossil test-th-eval {hash foo sha3-256}
test th1-hash-7 {$RESULT eq \
"76d3bc41c9f588f7fcd0d5bf4718f8f84b1c41b20882703100b9eb9413807c01"}

###############################################################################

fossil test-th-eval {hash foo sha3-384}
test th1-hash-8 {$RESULT eq [appendArgs \
665551928d13b7d84ee02734502b018d896a0fb87eed5adb4c87ba91bbd6489410e11b0fbcc06 \
ed7d0ebad559e5d3bb5]}

###############################################################################

fossil test-th-eval {hash foo sha3-512}
test th1-hash-9 {$RESULT eq [appendArgs \
4bca2b137edc580fe50a88983ef860ebaca36c857b1f492839d6d7392452a63c82cbebc68e3b7 \
0a2a1480b4bb5d437a7cba6ecf9d89f9ff3ccd14cd6146ea7e7]}

###############################################################################

test_cleanup

Changes to win/fossil.rc.

96
97
98
99
100
101
102







103
104
105
106
107
108
109
      VALUE "SQLiteVersion", "SQLite " SQLITE_VERSION " " SQLITE_SOURCE_ID "\0"
#if defined(FOSSIL_DYNAMIC_BUILD)
      VALUE "DynamicBuild", "Yes\0"
#else
      VALUE "DynamicBuild", "No\0"
#endif
      VALUE "ZlibVersion", "zlib " ZLIB_VERSION "\0"







#if defined(BROKEN_MINGW_CMDLINE)
      VALUE "CommandLineIsUnicode", "No\0"
#else
      VALUE "CommandLineIsUnicode", "Yes\0"
#endif /* defined(BROKEN_MINGW_CMDLINE) */
#if defined(FOSSIL_ENABLE_SSL)
      VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"







>
>
>
>
>
>
>







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
      VALUE "SQLiteVersion", "SQLite " SQLITE_VERSION " " SQLITE_SOURCE_ID "\0"
#if defined(FOSSIL_DYNAMIC_BUILD)
      VALUE "DynamicBuild", "Yes\0"
#else
      VALUE "DynamicBuild", "No\0"
#endif
      VALUE "ZlibVersion", "zlib " ZLIB_VERSION "\0"
#if FOSSIL_HARDENED_SHA1
      VALUE "Sha1", "Hardened-SHA1 by Marc Stevens and Dan Shumow\0"
#elif defined(FOSSIL_ENABLE_SSL)
      VALUE "Sha1", "OpenSSL-SHA1\0"
#else
      VALUE "Sha1", "Legacy-SHA1\0"
#endif /* FOSSIL_HARDENED_SHA1 */
#if defined(BROKEN_MINGW_CMDLINE)
      VALUE "CommandLineIsUnicode", "No\0"
#else
      VALUE "CommandLineIsUnicode", "Yes\0"
#endif /* defined(BROKEN_MINGW_CMDLINE) */
#if defined(FOSSIL_ENABLE_SSL)
      VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"

Changes to www/th1.md.

188
189
190
191
192
193
194

195
196
197
198
199
200
201
  *  [enable\_output](#enable_output)
  *  [encode64](#encode64)
  *  [getParameter](#getParameter)
  *  [glob\_match](#glob_match)
  *  [globalState](#globalState)
  *  [hascap](#hascap)
  *  [hasfeature](#hasfeature)

  *  [html](#html)
  *  [htmlize](#htmlize)
  *  [http](#http)
  *  [httpize](#httpize)
  *  [insertCsrf](#insertCsrf)
  *  [linecount](#linecount)
  *  [markdown](#markdown)







>







188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  *  [enable\_output](#enable_output)
  *  [encode64](#encode64)
  *  [getParameter](#getParameter)
  *  [glob\_match](#glob_match)
  *  [globalState](#globalState)
  *  [hascap](#hascap)
  *  [hasfeature](#hasfeature)
  *  [hash](#hash)
  *  [html](#html)
  *  [htmlize](#htmlize)
  *  [http](#http)
  *  [httpize](#httpize)
  *  [insertCsrf](#insertCsrf)
  *  [linecount](#linecount)
  *  [markdown](#markdown)
517
518
519
520
521
522
523

524
525
526


















527
528
529
530
531
532
533
  1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
  1. **json** -- _Support for the JSON APIs._
  1. **markdown** -- _Support for Markdown documentation format._
  1. **unicodeCmdLine** -- _The command line arguments are Unicode._
  1. **dynamicBuild** -- _Dynamically linked to libraries._
  1. **mman** -- _Uses POSIX memory APIs from "sys/mman.h"._
  1. **see** -- _Uses the SQLite Encryption Extension._


Specifying an unknown feature will return a value of false, it will not
raise a script error.



















<a id="html"></a>TH1 html Command
-----------------------------------

  *  html STRING

Outputs the STRING escaped for HTML.







>



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
  1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
  1. **json** -- _Support for the JSON APIs._
  1. **markdown** -- _Support for Markdown documentation format._
  1. **unicodeCmdLine** -- _The command line arguments are Unicode._
  1. **dynamicBuild** -- _Dynamically linked to libraries._
  1. **mman** -- _Uses POSIX memory APIs from "sys/mman.h"._
  1. **see** -- _Uses the SQLite Encryption Extension._
  1. **hardenedSha1** -- _Uses the <a href="https://github.com/cr-marcstevens/sha1collisiondetection">Hardened-SHA1</a> implementation._

Specifying an unknown feature will return a value of false, it will not
raise a script error.

<a id="hash"></a>TH1 hash Command
---------------------------------

  *  hash STRING ?ALGORITHM?

Returns the cryptographic hash of the specified string.  Possible values
for the ALGORITHM argument are:

  1. **md5**
  1. **sha1**
  1. **sha3-224**
  1. **sha3-256**
  1. **sha3-384**
  1. **sha3-512**

The default algorithm is "sha3-256".  Specifying an unknown algorithm
will raise a script error.

<a id="html"></a>TH1 html Command
-----------------------------------

  *  html STRING

Outputs the STRING escaped for HTML.