Fossil SCM

Merge trunk into test-suite-new branch

danshearer 2026-11-27 18:14 UTC test-suite-new merge
Commit 38699756432c1f40670ae52e52322facb2f6a5de0873176894ec398720fec4ff
--- skins/refined-dark/css.txt
+++ skins/refined-dark/css.txt
@@ -1009,5 +1009,42 @@
10091009
}
10101010
10111011
/* A message's header line (sender, number, time) may wrap. Fossil keeps it
10121012
on one line, so a long login made the message list scroll sideways. */
10131013
body.chat div.message-widget .message-widget-tab { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
1014
+
1015
+/* iOS Safari zooms into a focused field whose text is under 16px. Phones
1016
+ get .content at 0.95em, so the chat field (15.2px) zoomed the page and
1017
+ left it scrolling sideways; other fields default to about 13px. */
1018
+@media (pointer: coarse), (max-width: 600px) {
1019
+ body.chat .chat-input-field { font-size: max(16px, 1em) !important; }
1020
+ textarea, select,
1021
+ input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]) {
1022
+ font-size: max(16px, 1em);
1023
+ }
1024
+}
1025
+/* The input wrapper's border already shows focus; the field's own
1026
+ :focus-visible outline was drawn outside it. */
1027
+body.chat .chat-input-field:focus-visible { outline: none; }
1028
+/* In compact mode fossil stacks the field over the button row, so a border
1029
+ on the wrapper enclosed the buttons and the blank space beside them.
1030
+ Draw it on the field instead. */
1031
+body.chat #chat-input-line-wrapper.compact { border: none !important; background: transparent !important; gap: 4px; }
1032
+body.chat #chat-input-line-wrapper.compact .chat-input-field {
1033
+ border: 1px solid var(--border) !important; border-radius: 6px !important;
1034
+ background: var(--input-bg) !important; padding: 0.3em 0.45em !important;
1035
+}
1036
+body.chat #chat-input-line-wrapper.compact .chat-input-field:focus { border-color: var(--link) !important; }
1037
+/* Space the buttons so neighboring borders do not double up. */
1038
+body.chat #chat-buttons-wrapper { gap: 4px; }
1039
+/* Light-mode bubbles keep the sender's own color, on which the page link
1040
+ blue measured 4.0:1. Links in messages use the darker on-tint blue. */
1041
+body.chat .message-widget-content a, body.chat .message-widget-content a:visited { color: var(--link-on-tint) !important; }
1042
+
1043
+/* Chat bubbles take the sender's color, on which the --border gray of an
1044
+ <hr> nearly vanished (1.05:1 on a green bubble). Draw it in the message's
1045
+ text color at half strength; browsers give <hr> its own gray color, so
1046
+ inherit first. */
1047
+body.chat .message-widget-content hr {
1048
+ color: inherit;
1049
+ border-top-color: color-mix(in srgb, currentColor 50%, transparent);
1050
+}
10141051
--- skins/refined-dark/css.txt
+++ skins/refined-dark/css.txt
@@ -1009,5 +1009,42 @@
1009 }
1010
1011 /* A message's header line (sender, number, time) may wrap. Fossil keeps it
1012 on one line, so a long login made the message list scroll sideways. */
1013 body.chat div.message-widget .message-widget-tab { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1014
--- skins/refined-dark/css.txt
+++ skins/refined-dark/css.txt
@@ -1009,5 +1009,42 @@
1009 }
1010
1011 /* A message's header line (sender, number, time) may wrap. Fossil keeps it
1012 on one line, so a long login made the message list scroll sideways. */
1013 body.chat div.message-widget .message-widget-tab { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
1014
1015 /* iOS Safari zooms into a focused field whose text is under 16px. Phones
1016 get .content at 0.95em, so the chat field (15.2px) zoomed the page and
1017 left it scrolling sideways; other fields default to about 13px. */
1018 @media (pointer: coarse), (max-width: 600px) {
1019 body.chat .chat-input-field { font-size: max(16px, 1em) !important; }
1020 textarea, select,
1021 input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]) {
1022 font-size: max(16px, 1em);
1023 }
1024 }
1025 /* The input wrapper's border already shows focus; the field's own
1026 :focus-visible outline was drawn outside it. */
1027 body.chat .chat-input-field:focus-visible { outline: none; }
1028 /* In compact mode fossil stacks the field over the button row, so a border
1029 on the wrapper enclosed the buttons and the blank space beside them.
1030 Draw it on the field instead. */
1031 body.chat #chat-input-line-wrapper.compact { border: none !important; background: transparent !important; gap: 4px; }
1032 body.chat #chat-input-line-wrapper.compact .chat-input-field {
1033 border: 1px solid var(--border) !important; border-radius: 6px !important;
1034 background: var(--input-bg) !important; padding: 0.3em 0.45em !important;
1035 }
1036 body.chat #chat-input-line-wrapper.compact .chat-input-field:focus { border-color: var(--link) !important; }
1037 /* Space the buttons so neighboring borders do not double up. */
1038 body.chat #chat-buttons-wrapper { gap: 4px; }
1039 /* Light-mode bubbles keep the sender's own color, on which the page link
1040 blue measured 4.0:1. Links in messages use the darker on-tint blue. */
1041 body.chat .message-widget-content a, body.chat .message-widget-content a:visited { color: var(--link-on-tint) !important; }
1042
1043 /* Chat bubbles take the sender's color, on which the --border gray of an
1044 <hr> nearly vanished (1.05:1 on a green bubble). Draw it in the message's
1045 text color at half strength; browsers give <hr> its own gray color, so
1046 inherit first. */
1047 body.chat .message-widget-content hr {
1048 color: inherit;
1049 border-top-color: color-mix(in srgb, currentColor 50%, transparent);
1050 }
1051
--- skins/refined-light/css.txt
+++ skins/refined-light/css.txt
@@ -996,5 +996,42 @@
996996
}
997997
998998
/* A message's header line (sender, number, time) may wrap. Fossil keeps it
999999
on one line, so a long login made the message list scroll sideways. */
10001000
body.chat div.message-widget .message-widget-tab { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
1001
+
1002
+/* iOS Safari zooms into a focused field whose text is under 16px. Phones
1003
+ get .content at 0.95em, so the chat field (15.2px) zoomed the page and
1004
+ left it scrolling sideways; other fields default to about 13px. */
1005
+@media (pointer: coarse), (max-width: 600px) {
1006
+ body.chat .chat-input-field { font-size: max(16px, 1em) !important; }
1007
+ textarea, select,
1008
+ input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]) {
1009
+ font-size: max(16px, 1em);
1010
+ }
1011
+}
1012
+/* The input wrapper's border already shows focus; the field's own
1013
+ :focus-visible outline was drawn outside it. */
1014
+body.chat .chat-input-field:focus-visible { outline: none; }
1015
+/* In compact mode fossil stacks the field over the button row, so a border
1016
+ on the wrapper enclosed the buttons and the blank space beside them.
1017
+ Draw it on the field instead. */
1018
+body.chat #chat-input-line-wrapper.compact { border: none !important; background: transparent !important; gap: 4px; }
1019
+body.chat #chat-input-line-wrapper.compact .chat-input-field {
1020
+ border: 1px solid var(--border) !important; border-radius: 6px !important;
1021
+ background: var(--input-bg) !important; padding: 0.3em 0.45em !important;
1022
+}
1023
+body.chat #chat-input-line-wrapper.compact .chat-input-field:focus { border-color: var(--link) !important; }
1024
+/* Space the buttons so neighboring borders do not double up. */
1025
+body.chat #chat-buttons-wrapper { gap: 4px; }
1026
+/* Light-mode bubbles keep the sender's own color, on which the page link
1027
+ blue measured 4.0:1. Links in messages use the darker on-tint blue. */
1028
+body.chat .message-widget-content a, body.chat .message-widget-content a:visited { color: var(--link-on-tint) !important; }
1029
+
1030
+/* Chat bubbles take the sender's color, on which the --border gray of an
1031
+ <hr> nearly vanished (1.05:1 on a green bubble). Draw it in the message's
1032
+ text color at half strength; browsers give <hr> its own gray color, so
1033
+ inherit first. */
1034
+body.chat .message-widget-content hr {
1035
+ color: inherit;
1036
+ border-top-color: color-mix(in srgb, currentColor 50%, transparent);
1037
+}
10011038
--- skins/refined-light/css.txt
+++ skins/refined-light/css.txt
@@ -996,5 +996,42 @@
996 }
997
998 /* A message's header line (sender, number, time) may wrap. Fossil keeps it
999 on one line, so a long login made the message list scroll sideways. */
1000 body.chat div.message-widget .message-widget-tab { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1001
--- skins/refined-light/css.txt
+++ skins/refined-light/css.txt
@@ -996,5 +996,42 @@
996 }
997
998 /* A message's header line (sender, number, time) may wrap. Fossil keeps it
999 on one line, so a long login made the message list scroll sideways. */
1000 body.chat div.message-widget .message-widget-tab { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
1001
1002 /* iOS Safari zooms into a focused field whose text is under 16px. Phones
1003 get .content at 0.95em, so the chat field (15.2px) zoomed the page and
1004 left it scrolling sideways; other fields default to about 13px. */
1005 @media (pointer: coarse), (max-width: 600px) {
1006 body.chat .chat-input-field { font-size: max(16px, 1em) !important; }
1007 textarea, select,
1008 input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=reset]):not([type=file]) {
1009 font-size: max(16px, 1em);
1010 }
1011 }
1012 /* The input wrapper's border already shows focus; the field's own
1013 :focus-visible outline was drawn outside it. */
1014 body.chat .chat-input-field:focus-visible { outline: none; }
1015 /* In compact mode fossil stacks the field over the button row, so a border
1016 on the wrapper enclosed the buttons and the blank space beside them.
1017 Draw it on the field instead. */
1018 body.chat #chat-input-line-wrapper.compact { border: none !important; background: transparent !important; gap: 4px; }
1019 body.chat #chat-input-line-wrapper.compact .chat-input-field {
1020 border: 1px solid var(--border) !important; border-radius: 6px !important;
1021 background: var(--input-bg) !important; padding: 0.3em 0.45em !important;
1022 }
1023 body.chat #chat-input-line-wrapper.compact .chat-input-field:focus { border-color: var(--link) !important; }
1024 /* Space the buttons so neighboring borders do not double up. */
1025 body.chat #chat-buttons-wrapper { gap: 4px; }
1026 /* Light-mode bubbles keep the sender's own color, on which the page link
1027 blue measured 4.0:1. Links in messages use the darker on-tint blue. */
1028 body.chat .message-widget-content a, body.chat .message-widget-content a:visited { color: var(--link-on-tint) !important; }
1029
1030 /* Chat bubbles take the sender's color, on which the --border gray of an
1031 <hr> nearly vanished (1.05:1 on a green bubble). Draw it in the message's
1032 text color at half strength; browsers give <hr> its own gray color, so
1033 inherit first. */
1034 body.chat .message-widget-content hr {
1035 color: inherit;
1036 border-top-color: color-mix(in srgb, currentColor 50%, transparent);
1037 }
1038
+24 -12
--- src/builtin.c
+++ src/builtin.c
@@ -305,10 +305,28 @@
305305
default: {
306306
return "inline";
307307
}
308308
}
309309
}
310
+
311
+/*
312
+** Add the Javascript file named by zFilename to the queue of requested
313
+** javascript resources, if it is not there already. Return 0 on
314
+** success, 1 if there is no such built-in file, or 2 if the queue is
315
+** full.
316
+*/
317
+int builtin_try_request_js(const char *zFilename){
318
+ int i = builtin_file_index(zFilename);
319
+ int j;
320
+ if( i<0 ) return 1;
321
+ for(j=0; j<builtin.nReq; j++){
322
+ if( builtin.aReq[j]==i ) return 0; /* Already queued or sent */
323
+ }
324
+ if( builtin.nReq>=count(builtin.aReq) ) return 2;
325
+ builtin.aReq[builtin.nReq++] = i;
326
+ return 0;
327
+}
310328
311329
/*
312330
** The caller wants the Javascript file named by zFilename to be
313331
** included in the generated page. Add the file to the queue of
314332
** requested javascript resources, if it is not there already.
@@ -327,22 +345,16 @@
327345
** does not guarantee when the javascript will be included, and it
328346
** does not guarantee whether the javascript will be added inline or
329347
** delivered as a separate resource.
330348
*/
331349
void builtin_request_js(const char *zFilename){
332
- int i = builtin_file_index(zFilename);
333
- int j;
334
- if( i<0 ){
335
- fossil_panic("unknown javascript file: \"%s\"", zFilename);
336
- }
337
- for(j=0; j<builtin.nReq; j++){
338
- if( builtin.aReq[j]==i ) return; /* Already queued or sent */
339
- }
340
- if( builtin.nReq>=count(builtin.aReq) ){
341
- fossil_panic("too many javascript files requested");
342
- }
343
- builtin.aReq[builtin.nReq++] = i;
350
+ switch( builtin_try_request_js(zFilename) ){
351
+ case 1:
352
+ fossil_panic("unknown javascript file: \"%s\"", zFilename);
353
+ case 2:
354
+ fossil_panic("too many javascript files requested");
355
+ }
344356
}
345357
346358
/*
347359
** Fulfill all pending requests for javascript files.
348360
**
349361
--- src/builtin.c
+++ src/builtin.c
@@ -305,10 +305,28 @@
305 default: {
306 return "inline";
307 }
308 }
309 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
311 /*
312 ** The caller wants the Javascript file named by zFilename to be
313 ** included in the generated page. Add the file to the queue of
314 ** requested javascript resources, if it is not there already.
@@ -327,22 +345,16 @@
327 ** does not guarantee when the javascript will be included, and it
328 ** does not guarantee whether the javascript will be added inline or
329 ** delivered as a separate resource.
330 */
331 void builtin_request_js(const char *zFilename){
332 int i = builtin_file_index(zFilename);
333 int j;
334 if( i<0 ){
335 fossil_panic("unknown javascript file: \"%s\"", zFilename);
336 }
337 for(j=0; j<builtin.nReq; j++){
338 if( builtin.aReq[j]==i ) return; /* Already queued or sent */
339 }
340 if( builtin.nReq>=count(builtin.aReq) ){
341 fossil_panic("too many javascript files requested");
342 }
343 builtin.aReq[builtin.nReq++] = i;
344 }
345
346 /*
347 ** Fulfill all pending requests for javascript files.
348 **
349
--- src/builtin.c
+++ src/builtin.c
@@ -305,10 +305,28 @@
305 default: {
306 return "inline";
307 }
308 }
309 }
310
311 /*
312 ** Add the Javascript file named by zFilename to the queue of requested
313 ** javascript resources, if it is not there already. Return 0 on
314 ** success, 1 if there is no such built-in file, or 2 if the queue is
315 ** full.
316 */
317 int builtin_try_request_js(const char *zFilename){
318 int i = builtin_file_index(zFilename);
319 int j;
320 if( i<0 ) return 1;
321 for(j=0; j<builtin.nReq; j++){
322 if( builtin.aReq[j]==i ) return 0; /* Already queued or sent */
323 }
324 if( builtin.nReq>=count(builtin.aReq) ) return 2;
325 builtin.aReq[builtin.nReq++] = i;
326 return 0;
327 }
328
329 /*
330 ** The caller wants the Javascript file named by zFilename to be
331 ** included in the generated page. Add the file to the queue of
332 ** requested javascript resources, if it is not there already.
@@ -327,22 +345,16 @@
345 ** does not guarantee when the javascript will be included, and it
346 ** does not guarantee whether the javascript will be added inline or
347 ** delivered as a separate resource.
348 */
349 void builtin_request_js(const char *zFilename){
350 switch( builtin_try_request_js(zFilename) ){
351 case 1:
352 fossil_panic("unknown javascript file: \"%s\"", zFilename);
353 case 2:
354 fossil_panic("too many javascript files requested");
355 }
 
 
 
 
 
 
356 }
357
358 /*
359 ** Fulfill all pending requests for javascript files.
360 **
361
+61 -20
--- src/cgi.c
+++ src/cgi.c
@@ -78,10 +78,11 @@
7878
# include <arpa/inet.h>
7979
# include <sys/times.h>
8080
# include <sys/time.h>
8181
# include <sys/wait.h>
8282
# include <sys/select.h>
83
+# include <sys/stat.h>
8384
# include <errno.h>
8485
#endif
8586
#ifdef __EMX__
8687
typedef int socklen_t;
8788
#endif
@@ -490,14 +491,26 @@
490491
491492
if( g.fullHttpReply ){
492493
if( rangeEnd>0
493494
&& iReplyStatus==200
494495
&& fossil_strcmp(P("REQUEST_METHOD"),"GET")==0
496
+ && fossil_strcmp(zReplyMimeType,"application/x-fossil")!=0
495497
){
496
- iReplyStatus = 206;
497
- zReplyStatus = "Partial Content";
498
+ int nContent = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
499
+ if( rangeStart>=nContent ){
500
+ iReplyStatus = 416;
501
+ zReplyStatus = "Range Not Satisfiable";
502
+ rangeEnd = nContent;
503
+ blob_reset(&cgiContent[0]);
504
+ blob_reset(&cgiContent[1]);
505
+ }else{
506
+ iReplyStatus = 206;
507
+ zReplyStatus = "Partial Content";
508
+ if( rangeEnd>nContent ) rangeEnd = nContent;
509
+ }
498510
}
511
+ if( iReplyStatus!=206 ) rangeStart = 0;
499512
blob_appendf(&hdr, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus);
500513
blob_appendf(&hdr, "Date: %s\r\n", cgi_rfc822_datestamp(time(0)));
501514
blob_appendf(&hdr, "Connection: close\r\n");
502515
blob_appendf(&hdr, "X-UA-Compatible: IE=edge\r\n");
503516
}else{
@@ -553,11 +566,11 @@
553566
if( fossil_strcmp(zReplyMimeType,"application/x-fossil")==0 ){
554567
cgi_combine_header_and_body();
555568
blob_compress(&cgiContent[0], &cgiContent[0]);
556569
}
557570
558
- if( is_gzippable() && iReplyStatus!=206 ){
571
+ if( is_gzippable() && iReplyStatus!=206 && iReplyStatus!=416 ){
559572
int i;
560573
gzip_begin(0);
561574
for( i=0; i<2; i++ ){
562575
int size = blob_size(&cgiContent[i]);
563576
if( size>0 ) gzip_step(blob_buffer(&cgiContent[i]), size);
@@ -570,10 +583,12 @@
570583
total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
571584
if( iReplyStatus==206 ){
572585
blob_appendf(&hdr, "Content-Range: bytes %d-%d/%d\r\n",
573586
rangeStart, rangeEnd-1, total_size);
574587
total_size = rangeEnd - rangeStart;
588
+ }else if( iReplyStatus==416 ){
589
+ blob_appendf(&hdr, "Content-Range: bytes */%d\r\n", rangeEnd);
575590
}
576591
blob_appendf(&hdr, "Content-Length: %d\r\n", total_size);
577592
}else{
578593
total_size = 0;
579594
}
@@ -622,11 +637,18 @@
622637
const char *zURL,
623638
int iStat,
624639
const char *zStat
625640
){
626641
char *zLocation;
642
+ char *zCopy = 0;
643
+ int i;
627644
CGIDEBUG(("redirect to %s\n", zURL));
645
+ for(i=0; zURL[i] && (unsigned char)zURL[i]>=' '; i++){}
646
+ if( zURL[i] ){
647
+ zCopy = mprintf("%.*s", i, zURL);
648
+ zURL = zCopy;
649
+ }
628650
if( fossil_strncmp(zURL,"http:",5)==0
629651
|| fossil_strncmp(zURL,"https:",6)==0 ){
630652
zLocation = mprintf("Location: %s\r\n", zURL);
631653
}else if( *zURL=='/' ){
632654
int n1 = (int)strlen(g.zBaseURL);
@@ -634,10 +656,11 @@
634656
if( g.zBaseURL[n1-1]=='/' ) zURL++;
635657
zLocation = mprintf("Location: %.*s%s\r\n", n1-n2, g.zBaseURL, zURL);
636658
}else{
637659
zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
638660
}
661
+ fossil_free(zCopy);
639662
cgi_append_header(zLocation);
640663
cgi_reset_content();
641664
cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zLocation);
642665
cgi_set_status(iStat, zStat);
643666
free(zLocation);
@@ -1135,11 +1158,11 @@
11351158
*z = 0;
11361159
z++;
11371160
}else{
11381161
if( i<mxArg-1 ){ azArg[i++] = z; }
11391162
while( *z && !fossil_isspace(*z) && *z!=';' && *z!='"' ){ z++; }
1140
- if( *z && *z!='"' ){
1163
+ if( *z && (*z!='"' || z[1]==0) ){
11411164
*z = 0;
11421165
z++;
11431166
}
11441167
}
11451168
}
@@ -1263,10 +1286,11 @@
12631286
json_err( FSL_JSON_E_INVALID_REQUEST,
12641287
"Request envelope must be a JSON Object (not array).", 1 );
12651288
}else{ /* generic error message */
12661289
json_err( FSL_JSON_E_INVALID_REQUEST, NULL, 1 );
12671290
}
1291
+ if( g.isHTTP ) cgi_reply();
12681292
fossil_exit( g.isHTTP ? 0 : 1);
12691293
}
12701294
#endif /* FOSSIL_ENABLE_JSON */
12711295
12721296
/*
@@ -1273,26 +1297,29 @@
12731297
** Log HTTP traffic to a file. Begin the log on first use. Close the log
12741298
** when the argument is NULL.
12751299
*/
12761300
void cgi_trace(const char *z){
12771301
static FILE *pLog = 0;
1302
+ static char zFile[50];
12781303
if( g.fHttpTrace==0 ) return;
12791304
if( z==0 ){
12801305
if( pLog ) fclose(pLog);
12811306
pLog = 0;
12821307
return;
12831308
}
12841309
if( pLog==0 ){
1285
- char zFile[50];
1310
+ const char *zMode = zFile[0] ? "ab" : "wb";
1311
+ if( zFile[0]==0 ){
12861312
#if defined(_WIN32)
1287
- unsigned r;
1288
- sqlite3_randomness(sizeof(r), &r);
1289
- sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%08x.txt", r);
1313
+ unsigned r;
1314
+ sqlite3_randomness(sizeof(r), &r);
1315
+ sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%08x.txt", r);
12901316
#else
1291
- sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%05d.txt", getpid());
1317
+ sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%05d.txt", getpid());
12921318
#endif
1293
- pLog = fossil_fopen(zFile, "wb");
1319
+ }
1320
+ pLog = fossil_fopen(zFile, zMode);
12941321
if( pLog ){
12951322
fprintf(stderr, "# open log on %s\n", zFile);
12961323
}else{
12971324
fprintf(stderr, "# failed to open %s\n", zFile);
12981325
return;
@@ -1837,11 +1864,11 @@
18371864
int cgi_all(const char *z, ...){
18381865
va_list ap;
18391866
char *z2;
18401867
if( cgi_parameter(z,0)==0 ) return 0;
18411868
va_start(ap, z);
1842
- while( (z2 = va_arg(ap, char*))==0 ){
1869
+ while( (z2 = va_arg(ap, char*))!=0 ){
18431870
if( cgi_parameter(z2,0)==0 ) return 0;
18441871
}
18451872
va_end(ap);
18461873
return 1;
18471874
}
@@ -2267,15 +2294,21 @@
22672294
if( zIpAddr!=0 ){
22682295
g.zIpAddr = fossil_strdup(zIpAddr);
22692296
cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
22702297
}
22712298
}else if( fossil_strcmp(zFieldName,"range:")==0 ){
2272
- int x1 = 0;
2273
- int x2 = 0;
2274
- if( sscanf(zVal,"bytes=%d-%d",&x1,&x2)==2 && x1>=0 && x1<=x2 ){
2275
- rangeStart = x1;
2276
- rangeEnd = x2+1;
2299
+ sqlite3_int64 x1, x2;
2300
+ char *zEnd;
2301
+ if( strncmp(zVal,"bytes=",6)==0 && fossil_isdigit(zVal[6]) ){
2302
+ x1 = strtoll(&zVal[6], &zEnd, 10);
2303
+ if( zEnd[0]=='-' && fossil_isdigit(zEnd[1]) ){
2304
+ x2 = strtoll(&zEnd[1], 0, 10);
2305
+ if( x1<=x2 && x2<0x7fffffff ){
2306
+ rangeStart = (int)x1;
2307
+ rangeEnd = (int)x2 + 1;
2308
+ }
2309
+ }
22772310
}
22782311
}
22792312
}
22802313
cgi_setenv("REQUEST_SCHEME",zScheme);
22812314
cgi_init();
@@ -2618,10 +2651,12 @@
26182651
struct sockaddr_in6 inaddr6; /* Address for IPv6 */
26192652
struct sockaddr_in inaddr4; /* Address for IPv4 */
26202653
struct sockaddr_un uxaddr; /* The address for unix-domain sockets */
26212654
int opt = 1; /* setsockopt flag */
26222655
int rc; /* Result code from system calls */
2656
+ mode_t mSock = 0660; /* Permissions for a unix-domain socket */
2657
+ mode_t mOld; /* Saved umask */
26232658
int iPort = mnPort; /* Port to try to use */
26242659
const char *zRequestType; /* Type of requests to listen for */
26252660
26262661
26272662
if( flags & HTTP_SERVER_SCGI ){
@@ -2661,17 +2696,23 @@
26612696
mxListen = listen4;
26622697
listen6 = -1;
26632698
26642699
/* Set the access permission for the new socket. Default to 0660.
26652700
** But use an alternative specified by --socket-mode if available.
2666
- ** Do this before bind() to avoid a race condition. */
2701
+ ** Set it through the umask that bind() uses to avoid a race
2702
+ ** condition. */
26672703
if( g.zSockMode ){
2668
- file_set_mode(g.zSockName, listen4, g.zSockMode, 0);
2669
- }else{
2670
- file_set_mode(g.zSockName, listen4, "0660", 1);
2704
+ char *zEnd = 0;
2705
+ mSock = (mode_t)strtol(g.zSockMode, &zEnd, 0);
2706
+ if( zEnd[0] ){
2707
+ fossil_fatal("cannot change permissions on %s to \"%s\"",
2708
+ g.zSockName, g.zSockMode);
2709
+ }
26712710
}
2711
+ mOld = umask(~mSock & 0777);
26722712
rc = bind(listen4, (struct sockaddr*)&uxaddr, sizeof(uxaddr));
2713
+ umask(mOld);
26732714
/* Set the owner of the socket if requested by --socket-owner. This
26742715
** must wait until after bind(), after the filesystem object has been
26752716
** created. See https://lkml.org/lkml/2004/11/1/84 and
26762717
** https://fossil-scm.org/forum/forumpost/7517680ef9684c57 */
26772718
if( g.zSockOwner ){
26782719
--- src/cgi.c
+++ src/cgi.c
@@ -78,10 +78,11 @@
78 # include <arpa/inet.h>
79 # include <sys/times.h>
80 # include <sys/time.h>
81 # include <sys/wait.h>
82 # include <sys/select.h>
 
83 # include <errno.h>
84 #endif
85 #ifdef __EMX__
86 typedef int socklen_t;
87 #endif
@@ -490,14 +491,26 @@
490
491 if( g.fullHttpReply ){
492 if( rangeEnd>0
493 && iReplyStatus==200
494 && fossil_strcmp(P("REQUEST_METHOD"),"GET")==0
 
495 ){
496 iReplyStatus = 206;
497 zReplyStatus = "Partial Content";
 
 
 
 
 
 
 
 
 
 
498 }
 
499 blob_appendf(&hdr, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus);
500 blob_appendf(&hdr, "Date: %s\r\n", cgi_rfc822_datestamp(time(0)));
501 blob_appendf(&hdr, "Connection: close\r\n");
502 blob_appendf(&hdr, "X-UA-Compatible: IE=edge\r\n");
503 }else{
@@ -553,11 +566,11 @@
553 if( fossil_strcmp(zReplyMimeType,"application/x-fossil")==0 ){
554 cgi_combine_header_and_body();
555 blob_compress(&cgiContent[0], &cgiContent[0]);
556 }
557
558 if( is_gzippable() && iReplyStatus!=206 ){
559 int i;
560 gzip_begin(0);
561 for( i=0; i<2; i++ ){
562 int size = blob_size(&cgiContent[i]);
563 if( size>0 ) gzip_step(blob_buffer(&cgiContent[i]), size);
@@ -570,10 +583,12 @@
570 total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
571 if( iReplyStatus==206 ){
572 blob_appendf(&hdr, "Content-Range: bytes %d-%d/%d\r\n",
573 rangeStart, rangeEnd-1, total_size);
574 total_size = rangeEnd - rangeStart;
 
 
575 }
576 blob_appendf(&hdr, "Content-Length: %d\r\n", total_size);
577 }else{
578 total_size = 0;
579 }
@@ -622,11 +637,18 @@
622 const char *zURL,
623 int iStat,
624 const char *zStat
625 ){
626 char *zLocation;
 
 
627 CGIDEBUG(("redirect to %s\n", zURL));
 
 
 
 
 
628 if( fossil_strncmp(zURL,"http:",5)==0
629 || fossil_strncmp(zURL,"https:",6)==0 ){
630 zLocation = mprintf("Location: %s\r\n", zURL);
631 }else if( *zURL=='/' ){
632 int n1 = (int)strlen(g.zBaseURL);
@@ -634,10 +656,11 @@
634 if( g.zBaseURL[n1-1]=='/' ) zURL++;
635 zLocation = mprintf("Location: %.*s%s\r\n", n1-n2, g.zBaseURL, zURL);
636 }else{
637 zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
638 }
 
639 cgi_append_header(zLocation);
640 cgi_reset_content();
641 cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zLocation);
642 cgi_set_status(iStat, zStat);
643 free(zLocation);
@@ -1135,11 +1158,11 @@
1135 *z = 0;
1136 z++;
1137 }else{
1138 if( i<mxArg-1 ){ azArg[i++] = z; }
1139 while( *z && !fossil_isspace(*z) && *z!=';' && *z!='"' ){ z++; }
1140 if( *z && *z!='"' ){
1141 *z = 0;
1142 z++;
1143 }
1144 }
1145 }
@@ -1263,10 +1286,11 @@
1263 json_err( FSL_JSON_E_INVALID_REQUEST,
1264 "Request envelope must be a JSON Object (not array).", 1 );
1265 }else{ /* generic error message */
1266 json_err( FSL_JSON_E_INVALID_REQUEST, NULL, 1 );
1267 }
 
1268 fossil_exit( g.isHTTP ? 0 : 1);
1269 }
1270 #endif /* FOSSIL_ENABLE_JSON */
1271
1272 /*
@@ -1273,26 +1297,29 @@
1273 ** Log HTTP traffic to a file. Begin the log on first use. Close the log
1274 ** when the argument is NULL.
1275 */
1276 void cgi_trace(const char *z){
1277 static FILE *pLog = 0;
 
1278 if( g.fHttpTrace==0 ) return;
1279 if( z==0 ){
1280 if( pLog ) fclose(pLog);
1281 pLog = 0;
1282 return;
1283 }
1284 if( pLog==0 ){
1285 char zFile[50];
 
1286 #if defined(_WIN32)
1287 unsigned r;
1288 sqlite3_randomness(sizeof(r), &r);
1289 sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%08x.txt", r);
1290 #else
1291 sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%05d.txt", getpid());
1292 #endif
1293 pLog = fossil_fopen(zFile, "wb");
 
1294 if( pLog ){
1295 fprintf(stderr, "# open log on %s\n", zFile);
1296 }else{
1297 fprintf(stderr, "# failed to open %s\n", zFile);
1298 return;
@@ -1837,11 +1864,11 @@
1837 int cgi_all(const char *z, ...){
1838 va_list ap;
1839 char *z2;
1840 if( cgi_parameter(z,0)==0 ) return 0;
1841 va_start(ap, z);
1842 while( (z2 = va_arg(ap, char*))==0 ){
1843 if( cgi_parameter(z2,0)==0 ) return 0;
1844 }
1845 va_end(ap);
1846 return 1;
1847 }
@@ -2267,15 +2294,21 @@
2267 if( zIpAddr!=0 ){
2268 g.zIpAddr = fossil_strdup(zIpAddr);
2269 cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
2270 }
2271 }else if( fossil_strcmp(zFieldName,"range:")==0 ){
2272 int x1 = 0;
2273 int x2 = 0;
2274 if( sscanf(zVal,"bytes=%d-%d",&x1,&x2)==2 && x1>=0 && x1<=x2 ){
2275 rangeStart = x1;
2276 rangeEnd = x2+1;
 
 
 
 
 
 
2277 }
2278 }
2279 }
2280 cgi_setenv("REQUEST_SCHEME",zScheme);
2281 cgi_init();
@@ -2618,10 +2651,12 @@
2618 struct sockaddr_in6 inaddr6; /* Address for IPv6 */
2619 struct sockaddr_in inaddr4; /* Address for IPv4 */
2620 struct sockaddr_un uxaddr; /* The address for unix-domain sockets */
2621 int opt = 1; /* setsockopt flag */
2622 int rc; /* Result code from system calls */
 
 
2623 int iPort = mnPort; /* Port to try to use */
2624 const char *zRequestType; /* Type of requests to listen for */
2625
2626
2627 if( flags & HTTP_SERVER_SCGI ){
@@ -2661,17 +2696,23 @@
2661 mxListen = listen4;
2662 listen6 = -1;
2663
2664 /* Set the access permission for the new socket. Default to 0660.
2665 ** But use an alternative specified by --socket-mode if available.
2666 ** Do this before bind() to avoid a race condition. */
 
2667 if( g.zSockMode ){
2668 file_set_mode(g.zSockName, listen4, g.zSockMode, 0);
2669 }else{
2670 file_set_mode(g.zSockName, listen4, "0660", 1);
 
 
 
2671 }
 
2672 rc = bind(listen4, (struct sockaddr*)&uxaddr, sizeof(uxaddr));
 
2673 /* Set the owner of the socket if requested by --socket-owner. This
2674 ** must wait until after bind(), after the filesystem object has been
2675 ** created. See https://lkml.org/lkml/2004/11/1/84 and
2676 ** https://fossil-scm.org/forum/forumpost/7517680ef9684c57 */
2677 if( g.zSockOwner ){
2678
--- src/cgi.c
+++ src/cgi.c
@@ -78,10 +78,11 @@
78 # include <arpa/inet.h>
79 # include <sys/times.h>
80 # include <sys/time.h>
81 # include <sys/wait.h>
82 # include <sys/select.h>
83 # include <sys/stat.h>
84 # include <errno.h>
85 #endif
86 #ifdef __EMX__
87 typedef int socklen_t;
88 #endif
@@ -490,14 +491,26 @@
491
492 if( g.fullHttpReply ){
493 if( rangeEnd>0
494 && iReplyStatus==200
495 && fossil_strcmp(P("REQUEST_METHOD"),"GET")==0
496 && fossil_strcmp(zReplyMimeType,"application/x-fossil")!=0
497 ){
498 int nContent = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
499 if( rangeStart>=nContent ){
500 iReplyStatus = 416;
501 zReplyStatus = "Range Not Satisfiable";
502 rangeEnd = nContent;
503 blob_reset(&cgiContent[0]);
504 blob_reset(&cgiContent[1]);
505 }else{
506 iReplyStatus = 206;
507 zReplyStatus = "Partial Content";
508 if( rangeEnd>nContent ) rangeEnd = nContent;
509 }
510 }
511 if( iReplyStatus!=206 ) rangeStart = 0;
512 blob_appendf(&hdr, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus);
513 blob_appendf(&hdr, "Date: %s\r\n", cgi_rfc822_datestamp(time(0)));
514 blob_appendf(&hdr, "Connection: close\r\n");
515 blob_appendf(&hdr, "X-UA-Compatible: IE=edge\r\n");
516 }else{
@@ -553,11 +566,11 @@
566 if( fossil_strcmp(zReplyMimeType,"application/x-fossil")==0 ){
567 cgi_combine_header_and_body();
568 blob_compress(&cgiContent[0], &cgiContent[0]);
569 }
570
571 if( is_gzippable() && iReplyStatus!=206 && iReplyStatus!=416 ){
572 int i;
573 gzip_begin(0);
574 for( i=0; i<2; i++ ){
575 int size = blob_size(&cgiContent[i]);
576 if( size>0 ) gzip_step(blob_buffer(&cgiContent[i]), size);
@@ -570,10 +583,12 @@
583 total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
584 if( iReplyStatus==206 ){
585 blob_appendf(&hdr, "Content-Range: bytes %d-%d/%d\r\n",
586 rangeStart, rangeEnd-1, total_size);
587 total_size = rangeEnd - rangeStart;
588 }else if( iReplyStatus==416 ){
589 blob_appendf(&hdr, "Content-Range: bytes */%d\r\n", rangeEnd);
590 }
591 blob_appendf(&hdr, "Content-Length: %d\r\n", total_size);
592 }else{
593 total_size = 0;
594 }
@@ -622,11 +637,18 @@
637 const char *zURL,
638 int iStat,
639 const char *zStat
640 ){
641 char *zLocation;
642 char *zCopy = 0;
643 int i;
644 CGIDEBUG(("redirect to %s\n", zURL));
645 for(i=0; zURL[i] && (unsigned char)zURL[i]>=' '; i++){}
646 if( zURL[i] ){
647 zCopy = mprintf("%.*s", i, zURL);
648 zURL = zCopy;
649 }
650 if( fossil_strncmp(zURL,"http:",5)==0
651 || fossil_strncmp(zURL,"https:",6)==0 ){
652 zLocation = mprintf("Location: %s\r\n", zURL);
653 }else if( *zURL=='/' ){
654 int n1 = (int)strlen(g.zBaseURL);
@@ -634,10 +656,11 @@
656 if( g.zBaseURL[n1-1]=='/' ) zURL++;
657 zLocation = mprintf("Location: %.*s%s\r\n", n1-n2, g.zBaseURL, zURL);
658 }else{
659 zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
660 }
661 fossil_free(zCopy);
662 cgi_append_header(zLocation);
663 cgi_reset_content();
664 cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zLocation);
665 cgi_set_status(iStat, zStat);
666 free(zLocation);
@@ -1135,11 +1158,11 @@
1158 *z = 0;
1159 z++;
1160 }else{
1161 if( i<mxArg-1 ){ azArg[i++] = z; }
1162 while( *z && !fossil_isspace(*z) && *z!=';' && *z!='"' ){ z++; }
1163 if( *z && (*z!='"' || z[1]==0) ){
1164 *z = 0;
1165 z++;
1166 }
1167 }
1168 }
@@ -1263,10 +1286,11 @@
1286 json_err( FSL_JSON_E_INVALID_REQUEST,
1287 "Request envelope must be a JSON Object (not array).", 1 );
1288 }else{ /* generic error message */
1289 json_err( FSL_JSON_E_INVALID_REQUEST, NULL, 1 );
1290 }
1291 if( g.isHTTP ) cgi_reply();
1292 fossil_exit( g.isHTTP ? 0 : 1);
1293 }
1294 #endif /* FOSSIL_ENABLE_JSON */
1295
1296 /*
@@ -1273,26 +1297,29 @@
1297 ** Log HTTP traffic to a file. Begin the log on first use. Close the log
1298 ** when the argument is NULL.
1299 */
1300 void cgi_trace(const char *z){
1301 static FILE *pLog = 0;
1302 static char zFile[50];
1303 if( g.fHttpTrace==0 ) return;
1304 if( z==0 ){
1305 if( pLog ) fclose(pLog);
1306 pLog = 0;
1307 return;
1308 }
1309 if( pLog==0 ){
1310 const char *zMode = zFile[0] ? "ab" : "wb";
1311 if( zFile[0]==0 ){
1312 #if defined(_WIN32)
1313 unsigned r;
1314 sqlite3_randomness(sizeof(r), &r);
1315 sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%08x.txt", r);
1316 #else
1317 sqlite3_snprintf(sizeof(zFile), zFile, "httplog-%05d.txt", getpid());
1318 #endif
1319 }
1320 pLog = fossil_fopen(zFile, zMode);
1321 if( pLog ){
1322 fprintf(stderr, "# open log on %s\n", zFile);
1323 }else{
1324 fprintf(stderr, "# failed to open %s\n", zFile);
1325 return;
@@ -1837,11 +1864,11 @@
1864 int cgi_all(const char *z, ...){
1865 va_list ap;
1866 char *z2;
1867 if( cgi_parameter(z,0)==0 ) return 0;
1868 va_start(ap, z);
1869 while( (z2 = va_arg(ap, char*))!=0 ){
1870 if( cgi_parameter(z2,0)==0 ) return 0;
1871 }
1872 va_end(ap);
1873 return 1;
1874 }
@@ -2267,15 +2294,21 @@
2294 if( zIpAddr!=0 ){
2295 g.zIpAddr = fossil_strdup(zIpAddr);
2296 cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
2297 }
2298 }else if( fossil_strcmp(zFieldName,"range:")==0 ){
2299 sqlite3_int64 x1, x2;
2300 char *zEnd;
2301 if( strncmp(zVal,"bytes=",6)==0 && fossil_isdigit(zVal[6]) ){
2302 x1 = strtoll(&zVal[6], &zEnd, 10);
2303 if( zEnd[0]=='-' && fossil_isdigit(zEnd[1]) ){
2304 x2 = strtoll(&zEnd[1], 0, 10);
2305 if( x1<=x2 && x2<0x7fffffff ){
2306 rangeStart = (int)x1;
2307 rangeEnd = (int)x2 + 1;
2308 }
2309 }
2310 }
2311 }
2312 }
2313 cgi_setenv("REQUEST_SCHEME",zScheme);
2314 cgi_init();
@@ -2618,10 +2651,12 @@
2651 struct sockaddr_in6 inaddr6; /* Address for IPv6 */
2652 struct sockaddr_in inaddr4; /* Address for IPv4 */
2653 struct sockaddr_un uxaddr; /* The address for unix-domain sockets */
2654 int opt = 1; /* setsockopt flag */
2655 int rc; /* Result code from system calls */
2656 mode_t mSock = 0660; /* Permissions for a unix-domain socket */
2657 mode_t mOld; /* Saved umask */
2658 int iPort = mnPort; /* Port to try to use */
2659 const char *zRequestType; /* Type of requests to listen for */
2660
2661
2662 if( flags & HTTP_SERVER_SCGI ){
@@ -2661,17 +2696,23 @@
2696 mxListen = listen4;
2697 listen6 = -1;
2698
2699 /* Set the access permission for the new socket. Default to 0660.
2700 ** But use an alternative specified by --socket-mode if available.
2701 ** Set it through the umask that bind() uses to avoid a race
2702 ** condition. */
2703 if( g.zSockMode ){
2704 char *zEnd = 0;
2705 mSock = (mode_t)strtol(g.zSockMode, &zEnd, 0);
2706 if( zEnd[0] ){
2707 fossil_fatal("cannot change permissions on %s to \"%s\"",
2708 g.zSockName, g.zSockMode);
2709 }
2710 }
2711 mOld = umask(~mSock & 0777);
2712 rc = bind(listen4, (struct sockaddr*)&uxaddr, sizeof(uxaddr));
2713 umask(mOld);
2714 /* Set the owner of the socket if requested by --socket-owner. This
2715 ** must wait until after bind(), after the filesystem object has been
2716 ** created. See https://lkml.org/lkml/2004/11/1/84 and
2717 ** https://fossil-scm.org/forum/forumpost/7517680ef9684c57 */
2718 if( g.zSockOwner ){
2719
+16 -4
--- src/configure.c
+++ src/configure.c
@@ -828,10 +828,11 @@
828828
**
829829
** See also: [[settings]], [[unset]]
830830
*/
831831
void configuration_cmd(void){
832832
int n;
833
+ int nErr = 0;
833834
const char *zMethod;
834835
db_find_and_open_repository(0, 0);
835836
db_open_config(0, 0);
836837
if( g.argc<3 ){
837838
usage("SUBCOMMAND ...");
@@ -845,11 +846,11 @@
845846
if( g.argc!=5 ){
846847
usage("export AREA FILENAME");
847848
}
848849
mask = configure_name_to_mask(g.argv[3], 1);
849850
if( zSince ){
850
- iStart = db_multi_exec(
851
+ iStart = db_int64(0,
851852
"SELECT coalesce(strftime('%%s',%Q),strftime('%%s','now',%Q))+0",
852853
zSince, zSince
853854
);
854855
}else{
855856
iStart = 0;
@@ -897,17 +898,17 @@
897898
user_select();
898899
url_enable_proxy("via proxy: ");
899900
g.zHttpAuth = get_httpauth();
900901
if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
901902
if( strncmp(zMethod, "push", n)==0 ){
902
- client_sync(0,0,(unsigned)mask,0,0);
903
+ nErr = client_sync(0,0,(unsigned)mask,0,0);
903904
}else if( strncmp(zMethod, "pull", n)==0 ){
904905
if( overwriteFlag ) db_unprotect(PROTECT_USER);
905
- client_sync(0,(unsigned)mask,0,0,0);
906
+ nErr = client_sync(0,(unsigned)mask,0,0,0);
906907
if( overwriteFlag ) db_protect_pop();
907908
}else{
908
- client_sync(0,(unsigned)mask,(unsigned)mask,0,0);
909
+ nErr = client_sync(0,(unsigned)mask,(unsigned)mask,0,0);
909910
}
910911
}else
911912
if( strncmp(zMethod, "reset", n)==0 ){
912913
int mask, i;
913914
char *zBackup;
@@ -944,10 +945,18 @@
944945
}
945946
}else if( fossil_strcmp(zName,"@reportfmt")==0 ){
946947
db_multi_exec("DELETE FROM reportfmt");
947948
assert( strchr(zRepositorySchemaDefaultReports,'%')==0 );
948949
db_multi_exec(zRepositorySchemaDefaultReports /*works-like:""*/);
950
+ }else if( fossil_strcmp(zName,"@alias")==0 ){
951
+ db_unprotect(PROTECT_CONFIG);
952
+ db_multi_exec("DELETE FROM config WHERE name GLOB 'walias:/*'");
953
+ db_protect_pop();
954
+ }else if( fossil_strcmp(zName,"@interwiki")==0 ){
955
+ db_unprotect(PROTECT_CONFIG);
956
+ db_multi_exec("DELETE FROM config WHERE name GLOB 'interwiki:*'");
957
+ db_protect_pop();
949958
}
950959
}
951960
db_end_transaction(0);
952961
fossil_print("Configuration reset to factory defaults.\n");
953962
fossil_print("To recover, use: %s %s import %s\n",
@@ -957,10 +966,11 @@
957966
{
958967
fossil_fatal("METHOD should be one of:"
959968
" export import merge pull push reset");
960969
}
961970
configure_rebuild();
971
+ if( nErr ) fossil_exit(1);
962972
}
963973
964974
965975
/*
966976
** COMMAND: test-var-list
@@ -1055,11 +1065,13 @@
10551065
}
10561066
db_finalize(&q);
10571067
if( zPattern && doUnset ){
10581068
prompt_user("Delete all of the above? (y/N)? ", &ans);
10591069
if( blob_str(&ans)[0]=='y' || blob_str(&ans)[0]=='Y' ){
1070
+ db_unprotect(PROTECT_CONFIG);
10601071
db_multi_exec("DELETE FROM config WHERE name GLOB %Q", zPattern);
1072
+ db_protect_pop();
10611073
}
10621074
blob_reset(&ans);
10631075
}
10641076
}
10651077
10661078
--- src/configure.c
+++ src/configure.c
@@ -828,10 +828,11 @@
828 **
829 ** See also: [[settings]], [[unset]]
830 */
831 void configuration_cmd(void){
832 int n;
 
833 const char *zMethod;
834 db_find_and_open_repository(0, 0);
835 db_open_config(0, 0);
836 if( g.argc<3 ){
837 usage("SUBCOMMAND ...");
@@ -845,11 +846,11 @@
845 if( g.argc!=5 ){
846 usage("export AREA FILENAME");
847 }
848 mask = configure_name_to_mask(g.argv[3], 1);
849 if( zSince ){
850 iStart = db_multi_exec(
851 "SELECT coalesce(strftime('%%s',%Q),strftime('%%s','now',%Q))+0",
852 zSince, zSince
853 );
854 }else{
855 iStart = 0;
@@ -897,17 +898,17 @@
897 user_select();
898 url_enable_proxy("via proxy: ");
899 g.zHttpAuth = get_httpauth();
900 if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
901 if( strncmp(zMethod, "push", n)==0 ){
902 client_sync(0,0,(unsigned)mask,0,0);
903 }else if( strncmp(zMethod, "pull", n)==0 ){
904 if( overwriteFlag ) db_unprotect(PROTECT_USER);
905 client_sync(0,(unsigned)mask,0,0,0);
906 if( overwriteFlag ) db_protect_pop();
907 }else{
908 client_sync(0,(unsigned)mask,(unsigned)mask,0,0);
909 }
910 }else
911 if( strncmp(zMethod, "reset", n)==0 ){
912 int mask, i;
913 char *zBackup;
@@ -944,10 +945,18 @@
944 }
945 }else if( fossil_strcmp(zName,"@reportfmt")==0 ){
946 db_multi_exec("DELETE FROM reportfmt");
947 assert( strchr(zRepositorySchemaDefaultReports,'%')==0 );
948 db_multi_exec(zRepositorySchemaDefaultReports /*works-like:""*/);
 
 
 
 
 
 
 
 
949 }
950 }
951 db_end_transaction(0);
952 fossil_print("Configuration reset to factory defaults.\n");
953 fossil_print("To recover, use: %s %s import %s\n",
@@ -957,10 +966,11 @@
957 {
958 fossil_fatal("METHOD should be one of:"
959 " export import merge pull push reset");
960 }
961 configure_rebuild();
 
962 }
963
964
965 /*
966 ** COMMAND: test-var-list
@@ -1055,11 +1065,13 @@
1055 }
1056 db_finalize(&q);
1057 if( zPattern && doUnset ){
1058 prompt_user("Delete all of the above? (y/N)? ", &ans);
1059 if( blob_str(&ans)[0]=='y' || blob_str(&ans)[0]=='Y' ){
 
1060 db_multi_exec("DELETE FROM config WHERE name GLOB %Q", zPattern);
 
1061 }
1062 blob_reset(&ans);
1063 }
1064 }
1065
1066
--- src/configure.c
+++ src/configure.c
@@ -828,10 +828,11 @@
828 **
829 ** See also: [[settings]], [[unset]]
830 */
831 void configuration_cmd(void){
832 int n;
833 int nErr = 0;
834 const char *zMethod;
835 db_find_and_open_repository(0, 0);
836 db_open_config(0, 0);
837 if( g.argc<3 ){
838 usage("SUBCOMMAND ...");
@@ -845,11 +846,11 @@
846 if( g.argc!=5 ){
847 usage("export AREA FILENAME");
848 }
849 mask = configure_name_to_mask(g.argv[3], 1);
850 if( zSince ){
851 iStart = db_int64(0,
852 "SELECT coalesce(strftime('%%s',%Q),strftime('%%s','now',%Q))+0",
853 zSince, zSince
854 );
855 }else{
856 iStart = 0;
@@ -897,17 +898,17 @@
898 user_select();
899 url_enable_proxy("via proxy: ");
900 g.zHttpAuth = get_httpauth();
901 if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
902 if( strncmp(zMethod, "push", n)==0 ){
903 nErr = client_sync(0,0,(unsigned)mask,0,0);
904 }else if( strncmp(zMethod, "pull", n)==0 ){
905 if( overwriteFlag ) db_unprotect(PROTECT_USER);
906 nErr = client_sync(0,(unsigned)mask,0,0,0);
907 if( overwriteFlag ) db_protect_pop();
908 }else{
909 nErr = client_sync(0,(unsigned)mask,(unsigned)mask,0,0);
910 }
911 }else
912 if( strncmp(zMethod, "reset", n)==0 ){
913 int mask, i;
914 char *zBackup;
@@ -944,10 +945,18 @@
945 }
946 }else if( fossil_strcmp(zName,"@reportfmt")==0 ){
947 db_multi_exec("DELETE FROM reportfmt");
948 assert( strchr(zRepositorySchemaDefaultReports,'%')==0 );
949 db_multi_exec(zRepositorySchemaDefaultReports /*works-like:""*/);
950 }else if( fossil_strcmp(zName,"@alias")==0 ){
951 db_unprotect(PROTECT_CONFIG);
952 db_multi_exec("DELETE FROM config WHERE name GLOB 'walias:/*'");
953 db_protect_pop();
954 }else if( fossil_strcmp(zName,"@interwiki")==0 ){
955 db_unprotect(PROTECT_CONFIG);
956 db_multi_exec("DELETE FROM config WHERE name GLOB 'interwiki:*'");
957 db_protect_pop();
958 }
959 }
960 db_end_transaction(0);
961 fossil_print("Configuration reset to factory defaults.\n");
962 fossil_print("To recover, use: %s %s import %s\n",
@@ -957,10 +966,11 @@
966 {
967 fossil_fatal("METHOD should be one of:"
968 " export import merge pull push reset");
969 }
970 configure_rebuild();
971 if( nErr ) fossil_exit(1);
972 }
973
974
975 /*
976 ** COMMAND: test-var-list
@@ -1055,11 +1065,13 @@
1065 }
1066 db_finalize(&q);
1067 if( zPattern && doUnset ){
1068 prompt_user("Delete all of the above? (y/N)? ", &ans);
1069 if( blob_str(&ans)[0]=='y' || blob_str(&ans)[0]=='Y' ){
1070 db_unprotect(PROTECT_CONFIG);
1071 db_multi_exec("DELETE FROM config WHERE name GLOB %Q", zPattern);
1072 db_protect_pop();
1073 }
1074 blob_reset(&ans);
1075 }
1076 }
1077
1078
+8 -6
--- src/export.c
+++ src/export.c
@@ -309,14 +309,12 @@
309309
if( !cur_tok || strlen(cur_tok)<2 ){
310310
return -1;
311311
}
312312
mark->rid = atoi(&cur_tok[1]);
313313
type_ = cur_tok[0];
314
- if( type_!='c' && type_!='b' ){
315
- /* This is probably a blob mark */
316
- mark->name = NULL;
317
- return 0;
314
+ if( (type_!='c' && type_!='b') || mark->rid<=0 ){
315
+ return -1;
318316
}
319317
320318
cur_tok = strtok(NULL, " \t");
321319
if( !cur_tok ){
322320
/* This mark was generated by an older version of Fossil and doesn't
@@ -1718,11 +1716,13 @@
17181716
/* Optionally do a "git push" */
17191717
zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
17201718
if( zPushUrl ){
17211719
char *zPushCmd;
17221720
UrlData url;
1723
- if( sqlite3_strglob("http*", zPushUrl)==0 ){
1721
+ if( fossil_strnicmp(zPushUrl, "http://", 7)==0
1722
+ || fossil_strnicmp(zPushUrl, "https://", 8)==0
1723
+ ){
17241724
url_parse_local(zPushUrl, 0, &url);
17251725
zPushCmd = mprintf("git push --mirror %s", url.canonical);
17261726
}else{
17271727
zPushCmd = mprintf("git push --mirror %s", zPushUrl);
17281728
}
@@ -1801,11 +1801,13 @@
18011801
z = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
18021802
if( z==0 ){
18031803
fossil_print("Autopush: off\n");
18041804
}else{
18051805
UrlData url;
1806
- if( sqlite3_strglob("http*", z)==0 ){
1806
+ if( fossil_strnicmp(z, "http://", 7)==0
1807
+ || fossil_strnicmp(z, "https://", 8)==0
1808
+ ){
18071809
url_parse_local(z, 0, &url);
18081810
fossil_print("Autopush: %s\n", url.canonical);
18091811
}else{
18101812
fossil_print("Autopush: %s\n", z);
18111813
}
18121814
--- src/export.c
+++ src/export.c
@@ -309,14 +309,12 @@
309 if( !cur_tok || strlen(cur_tok)<2 ){
310 return -1;
311 }
312 mark->rid = atoi(&cur_tok[1]);
313 type_ = cur_tok[0];
314 if( type_!='c' && type_!='b' ){
315 /* This is probably a blob mark */
316 mark->name = NULL;
317 return 0;
318 }
319
320 cur_tok = strtok(NULL, " \t");
321 if( !cur_tok ){
322 /* This mark was generated by an older version of Fossil and doesn't
@@ -1718,11 +1716,13 @@
1718 /* Optionally do a "git push" */
1719 zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
1720 if( zPushUrl ){
1721 char *zPushCmd;
1722 UrlData url;
1723 if( sqlite3_strglob("http*", zPushUrl)==0 ){
 
 
1724 url_parse_local(zPushUrl, 0, &url);
1725 zPushCmd = mprintf("git push --mirror %s", url.canonical);
1726 }else{
1727 zPushCmd = mprintf("git push --mirror %s", zPushUrl);
1728 }
@@ -1801,11 +1801,13 @@
1801 z = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
1802 if( z==0 ){
1803 fossil_print("Autopush: off\n");
1804 }else{
1805 UrlData url;
1806 if( sqlite3_strglob("http*", z)==0 ){
 
 
1807 url_parse_local(z, 0, &url);
1808 fossil_print("Autopush: %s\n", url.canonical);
1809 }else{
1810 fossil_print("Autopush: %s\n", z);
1811 }
1812
--- src/export.c
+++ src/export.c
@@ -309,14 +309,12 @@
309 if( !cur_tok || strlen(cur_tok)<2 ){
310 return -1;
311 }
312 mark->rid = atoi(&cur_tok[1]);
313 type_ = cur_tok[0];
314 if( (type_!='c' && type_!='b') || mark->rid<=0 ){
315 return -1;
 
 
316 }
317
318 cur_tok = strtok(NULL, " \t");
319 if( !cur_tok ){
320 /* This mark was generated by an older version of Fossil and doesn't
@@ -1718,11 +1716,13 @@
1716 /* Optionally do a "git push" */
1717 zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
1718 if( zPushUrl ){
1719 char *zPushCmd;
1720 UrlData url;
1721 if( fossil_strnicmp(zPushUrl, "http://", 7)==0
1722 || fossil_strnicmp(zPushUrl, "https://", 8)==0
1723 ){
1724 url_parse_local(zPushUrl, 0, &url);
1725 zPushCmd = mprintf("git push --mirror %s", url.canonical);
1726 }else{
1727 zPushCmd = mprintf("git push --mirror %s", zPushUrl);
1728 }
@@ -1801,11 +1801,13 @@
1801 z = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
1802 if( z==0 ){
1803 fossil_print("Autopush: off\n");
1804 }else{
1805 UrlData url;
1806 if( fossil_strnicmp(z, "http://", 7)==0
1807 || fossil_strnicmp(z, "https://", 8)==0
1808 ){
1809 url_parse_local(z, 0, &url);
1810 fossil_print("Autopush: %s\n", url.canonical);
1811 }else{
1812 fossil_print("Autopush: %s\n", z);
1813 }
1814
-15
--- src/file.c
+++ src/file.c
@@ -765,25 +765,10 @@
765765
iMTime = file_mtime(zFile, RepoFILE);
766766
zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime);
767767
fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime);
768768
}
769769
770
-/*
771
-** Change access permissions on a file.
772
-*/
773
-void file_set_mode(const char *zFN, int fd, const char *zMode, int bNoErr){
774
-#if !defined(_WIN32)
775
- mode_t m;
776
- char *zEnd = 0;
777
- m = strtol(zMode, &zEnd, 0);
778
- if( (zEnd[0] || fchmod(fd, m)) && !bNoErr ){
779
- fossil_fatal("cannot change permissions on %s to \"%s\"",
780
- zFN, zMode);
781
- }
782
-#endif
783
-}
784
-
785770
/* Change the owner of a file to zOwner. zOwner can be of the form
786771
** USER:GROUP.
787772
*/
788773
void file_set_owner(const char *zFN, int fd, const char *zOwner){
789774
#if !defined(_WIN32)
790775
--- src/file.c
+++ src/file.c
@@ -765,25 +765,10 @@
765 iMTime = file_mtime(zFile, RepoFILE);
766 zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime);
767 fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime);
768 }
769
770 /*
771 ** Change access permissions on a file.
772 */
773 void file_set_mode(const char *zFN, int fd, const char *zMode, int bNoErr){
774 #if !defined(_WIN32)
775 mode_t m;
776 char *zEnd = 0;
777 m = strtol(zMode, &zEnd, 0);
778 if( (zEnd[0] || fchmod(fd, m)) && !bNoErr ){
779 fossil_fatal("cannot change permissions on %s to \"%s\"",
780 zFN, zMode);
781 }
782 #endif
783 }
784
785 /* Change the owner of a file to zOwner. zOwner can be of the form
786 ** USER:GROUP.
787 */
788 void file_set_owner(const char *zFN, int fd, const char *zOwner){
789 #if !defined(_WIN32)
790
--- src/file.c
+++ src/file.c
@@ -765,25 +765,10 @@
765 iMTime = file_mtime(zFile, RepoFILE);
766 zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime);
767 fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime);
768 }
769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770 /* Change the owner of a file to zOwner. zOwner can be of the form
771 ** USER:GROUP.
772 */
773 void file_set_owner(const char *zFN, int fd, const char *zOwner){
774 #if !defined(_WIN32)
775
+15 -6
--- src/http.c
+++ src/http.c
@@ -86,11 +86,13 @@
8686
if( g.url.passwd ){
8787
zPw = g.url.passwd;
8888
}else if( g.cgiOutput ){
8989
/* Password failure while doing a sync from the web interface */
9090
cgi_printf("*** incorrect or missing password for user %h\n", zLogin);
91
- zPw = 0;
91
+ blob_reset(&pw);
92
+ blob_reset(&nonce);
93
+ return;
9294
}else{
9395
/* Password failure while doing a sync from the command-line interface */
9496
url_prompt_for_password();
9597
zPw = g.url.passwd;
9698
}
@@ -437,17 +439,19 @@
437439
** It still might return a NULL pointer if for some reason it cannot
438440
** find and open the last http-reply-N.txt file.
439441
*/
440442
char *http_last_trace_reply(void){
441443
Blob x;
442
- int n;
443444
char *zFilename;
444445
if( g.fHttpTrace==0 ) return 0;
445446
zFilename = mprintf("http-reply-%d.txt", traceCnt);
446
- n = blob_read_from_file(&x, zFilename, ExtFILE);
447
+ if( file_size(zFilename, ExtFILE)<=0 ){
448
+ fossil_free(zFilename);
449
+ return 0;
450
+ }
451
+ blob_read_from_file(&x, zFilename, ExtFILE);
447452
fossil_free(zFilename);
448
- if( n<=0 ) return 0;
449453
return blob_str(&x);
450454
}
451455
452456
/*
453457
** Return true if z is a valud extension according to RFC 9112 s 7.1.1.
@@ -721,10 +725,11 @@
721725
}
722726
}else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
723727
fossil_strnicmp(zLine, "location:", 9)==0 ){
724728
int i, j;
725729
int wasHttps;
730
+ int wasProxy;
726731
int priorUrlFlags;
727732
728733
if ( --maxRedirect == 0){
729734
if( (mHttpFlags & HTTP_QUIET)==0 ){
730735
fossil_warning("redirect limit exceeded");
@@ -750,10 +755,11 @@
750755
&zLine[i]);
751756
}
752757
goto write_err;
753758
}
754759
wasHttps = g.url.isHttps;
760
+ wasProxy = g.url.useProxy;
755761
priorUrlFlags = g.url.flags;
756762
url_parse(&zLine[i], 0);
757763
if( wasHttps && !g.url.isHttps ){
758764
if( (mHttpFlags & HTTP_QUIET)==0 ){
759765
fossil_warning("cannot redirect from HTTPS to HTTP");
@@ -773,10 +779,11 @@
773779
g.zHttpAuth = get_httpauth();
774780
if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
775781
g.url.flags |= URL_REMEMBER;
776782
url_remember();
777783
}
784
+ if( wasProxy ) url_enable_proxy(0);
778785
return http_exchange(pSend, pReply, mHttpFlags,
779786
maxRedirect, zAltMimetype);
780787
}else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
781788
if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
782789
isCompressed = 0;
@@ -934,10 +941,11 @@
934941
iRecvLen = transport_receive(&g.url, blob_buffer(pReply), iLength);
935942
if( mHttpFlags & HTTP_VERBOSE ){
936943
fossil_print("Reply received: %d of %d bytes\n", iRecvLen, iLength);
937944
}
938945
if( iRecvLen != iLength ){
946
+ blob_resize(pReply, iRecvLen);
939947
if( mHttpFlags & HTTP_QUIET ) goto write_err;
940948
fossil_warning("response truncated: got %d bytes of %d",
941949
iRecvLen, iLength);
942950
goto write_err;
943951
}
@@ -960,16 +968,17 @@
960968
}
961969
if( isError ){
962970
char *z;
963971
int i, j;
964972
z = blob_str(pReply);
965
- for(i=j=0; z[i]; i++, j++){
973
+ for(i=j=0; z[i]; i++){
966974
if( z[i]=='<' ){
967975
while( z[i] && z[i]!='>' ) i++;
968976
if( z[i]==0 ) break;
977
+ }else{
978
+ z[j++] = z[i];
969979
}
970
- z[j] = z[i];
971980
}
972981
z[j] = 0;
973982
if( mHttpFlags & HTTP_QUIET ){
974983
/* no-op */
975984
}else if( mHttpFlags & HTTP_VERBOSE ){
976985
--- src/http.c
+++ src/http.c
@@ -86,11 +86,13 @@
86 if( g.url.passwd ){
87 zPw = g.url.passwd;
88 }else if( g.cgiOutput ){
89 /* Password failure while doing a sync from the web interface */
90 cgi_printf("*** incorrect or missing password for user %h\n", zLogin);
91 zPw = 0;
 
 
92 }else{
93 /* Password failure while doing a sync from the command-line interface */
94 url_prompt_for_password();
95 zPw = g.url.passwd;
96 }
@@ -437,17 +439,19 @@
437 ** It still might return a NULL pointer if for some reason it cannot
438 ** find and open the last http-reply-N.txt file.
439 */
440 char *http_last_trace_reply(void){
441 Blob x;
442 int n;
443 char *zFilename;
444 if( g.fHttpTrace==0 ) return 0;
445 zFilename = mprintf("http-reply-%d.txt", traceCnt);
446 n = blob_read_from_file(&x, zFilename, ExtFILE);
 
 
 
 
447 fossil_free(zFilename);
448 if( n<=0 ) return 0;
449 return blob_str(&x);
450 }
451
452 /*
453 ** Return true if z is a valud extension according to RFC 9112 s 7.1.1.
@@ -721,10 +725,11 @@
721 }
722 }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
723 fossil_strnicmp(zLine, "location:", 9)==0 ){
724 int i, j;
725 int wasHttps;
 
726 int priorUrlFlags;
727
728 if ( --maxRedirect == 0){
729 if( (mHttpFlags & HTTP_QUIET)==0 ){
730 fossil_warning("redirect limit exceeded");
@@ -750,10 +755,11 @@
750 &zLine[i]);
751 }
752 goto write_err;
753 }
754 wasHttps = g.url.isHttps;
 
755 priorUrlFlags = g.url.flags;
756 url_parse(&zLine[i], 0);
757 if( wasHttps && !g.url.isHttps ){
758 if( (mHttpFlags & HTTP_QUIET)==0 ){
759 fossil_warning("cannot redirect from HTTPS to HTTP");
@@ -773,10 +779,11 @@
773 g.zHttpAuth = get_httpauth();
774 if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
775 g.url.flags |= URL_REMEMBER;
776 url_remember();
777 }
 
778 return http_exchange(pSend, pReply, mHttpFlags,
779 maxRedirect, zAltMimetype);
780 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
781 if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
782 isCompressed = 0;
@@ -934,10 +941,11 @@
934 iRecvLen = transport_receive(&g.url, blob_buffer(pReply), iLength);
935 if( mHttpFlags & HTTP_VERBOSE ){
936 fossil_print("Reply received: %d of %d bytes\n", iRecvLen, iLength);
937 }
938 if( iRecvLen != iLength ){
 
939 if( mHttpFlags & HTTP_QUIET ) goto write_err;
940 fossil_warning("response truncated: got %d bytes of %d",
941 iRecvLen, iLength);
942 goto write_err;
943 }
@@ -960,16 +968,17 @@
960 }
961 if( isError ){
962 char *z;
963 int i, j;
964 z = blob_str(pReply);
965 for(i=j=0; z[i]; i++, j++){
966 if( z[i]=='<' ){
967 while( z[i] && z[i]!='>' ) i++;
968 if( z[i]==0 ) break;
 
 
969 }
970 z[j] = z[i];
971 }
972 z[j] = 0;
973 if( mHttpFlags & HTTP_QUIET ){
974 /* no-op */
975 }else if( mHttpFlags & HTTP_VERBOSE ){
976
--- src/http.c
+++ src/http.c
@@ -86,11 +86,13 @@
86 if( g.url.passwd ){
87 zPw = g.url.passwd;
88 }else if( g.cgiOutput ){
89 /* Password failure while doing a sync from the web interface */
90 cgi_printf("*** incorrect or missing password for user %h\n", zLogin);
91 blob_reset(&pw);
92 blob_reset(&nonce);
93 return;
94 }else{
95 /* Password failure while doing a sync from the command-line interface */
96 url_prompt_for_password();
97 zPw = g.url.passwd;
98 }
@@ -437,17 +439,19 @@
439 ** It still might return a NULL pointer if for some reason it cannot
440 ** find and open the last http-reply-N.txt file.
441 */
442 char *http_last_trace_reply(void){
443 Blob x;
 
444 char *zFilename;
445 if( g.fHttpTrace==0 ) return 0;
446 zFilename = mprintf("http-reply-%d.txt", traceCnt);
447 if( file_size(zFilename, ExtFILE)<=0 ){
448 fossil_free(zFilename);
449 return 0;
450 }
451 blob_read_from_file(&x, zFilename, ExtFILE);
452 fossil_free(zFilename);
 
453 return blob_str(&x);
454 }
455
456 /*
457 ** Return true if z is a valud extension according to RFC 9112 s 7.1.1.
@@ -721,10 +725,11 @@
725 }
726 }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
727 fossil_strnicmp(zLine, "location:", 9)==0 ){
728 int i, j;
729 int wasHttps;
730 int wasProxy;
731 int priorUrlFlags;
732
733 if ( --maxRedirect == 0){
734 if( (mHttpFlags & HTTP_QUIET)==0 ){
735 fossil_warning("redirect limit exceeded");
@@ -750,10 +755,11 @@
755 &zLine[i]);
756 }
757 goto write_err;
758 }
759 wasHttps = g.url.isHttps;
760 wasProxy = g.url.useProxy;
761 priorUrlFlags = g.url.flags;
762 url_parse(&zLine[i], 0);
763 if( wasHttps && !g.url.isHttps ){
764 if( (mHttpFlags & HTTP_QUIET)==0 ){
765 fossil_warning("cannot redirect from HTTPS to HTTP");
@@ -773,10 +779,11 @@
779 g.zHttpAuth = get_httpauth();
780 if( (rc==301 || rc==308) && (priorUrlFlags & URL_REMEMBER)!=0 ){
781 g.url.flags |= URL_REMEMBER;
782 url_remember();
783 }
784 if( wasProxy ) url_enable_proxy(0);
785 return http_exchange(pSend, pReply, mHttpFlags,
786 maxRedirect, zAltMimetype);
787 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
788 if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
789 isCompressed = 0;
@@ -934,10 +941,11 @@
941 iRecvLen = transport_receive(&g.url, blob_buffer(pReply), iLength);
942 if( mHttpFlags & HTTP_VERBOSE ){
943 fossil_print("Reply received: %d of %d bytes\n", iRecvLen, iLength);
944 }
945 if( iRecvLen != iLength ){
946 blob_resize(pReply, iRecvLen);
947 if( mHttpFlags & HTTP_QUIET ) goto write_err;
948 fossil_warning("response truncated: got %d bytes of %d",
949 iRecvLen, iLength);
950 goto write_err;
951 }
@@ -960,16 +968,17 @@
968 }
969 if( isError ){
970 char *z;
971 int i, j;
972 z = blob_str(pReply);
973 for(i=j=0; z[i]; i++){
974 if( z[i]=='<' ){
975 while( z[i] && z[i]!='>' ) i++;
976 if( z[i]==0 ) break;
977 }else{
978 z[j++] = z[i];
979 }
 
980 }
981 z[j] = 0;
982 if( mHttpFlags & HTTP_QUIET ){
983 /* no-op */
984 }else if( mHttpFlags & HTTP_VERBOSE ){
985
+94 -33
--- src/import.c
+++ src/import.c
@@ -569,10 +569,11 @@
569569
gg.xFinish();
570570
gg.xFinish = finish_blob;
571571
}else
572572
if( strncmp(zLine, "commit ", 7)==0 ){
573573
const char *zRefName;
574
+ int nRef;
574575
gg.xFinish();
575576
gg.xFinish = finish_commit;
576577
trim_newline(&zLine[7]);
577578
zRefName = &zLine[7];
578579
@@ -592,13 +593,15 @@
592593
** last commit that holds that tag.
593594
**
594595
** None of the above is explained in the git-fast-export
595596
** documentation. We had to figure it out via trial and error.
596597
*/
597
- for(i=5; i<(int)strlen(zRefName) && zRefName[i]!='/'; i++){}
598
- gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */
599
- if( zRefName[i+1]!=0 ) zRefName += i+1;
598
+ nRef = (int)strlen(zRefName);
599
+ for(i=5; i<nRef && zRefName[i]!='/'; i++){}
600
+ gg.tagCommit = nRef>=9
601
+ && strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */
602
+ if( i<nRef && zRefName[i+1]!=0 ) zRefName += i+1;
600603
if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
601604
gg.zBranch = fossil_strdup(zRefName);
602605
gg.fromLoaded = 0;
603606
}else
604607
if( strncmp(zLine, "tag ", 4)==0 ){
@@ -625,10 +628,13 @@
625628
fossil_print("%s\n", &zLine[9]);
626629
fflush(stdout);
627630
}else
628631
if( strncmp(zLine, "data ", 5)==0 ){
629632
fossil_free(gg.aData); gg.aData = 0;
633
+ if( !fossil_isdigit(zLine[5]) || strtoll(&zLine[5], 0, 10)>=0x7fffffff ){
634
+ goto malformed_line;
635
+ }
630636
gg.nData = atoi(&zLine[5]);
631637
if( gg.nData ){
632638
int got;
633639
gg.aData = fossil_malloc( gg.nData+1 );
634640
got = fread(gg.aData, 1, gg.nData, pIn);
@@ -666,10 +672,11 @@
666672
|| strncmp(zLine, "committer ",10)==0 ){
667673
sqlite3_int64 secSince1970;
668674
z = strchr(zLine, ' ');
669675
while( fossil_isspace(*z) ) z++;
670676
if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
677
+ if( zTo[1]!=' ' ) goto malformed_line;
671678
*(++zTo) = '\0';
672679
/*
673680
** If --attribute requested, lookup user in fx_ table by email address,
674681
** otherwise lookup Git {author,committer} contact info in user table. If
675682
** no matches, use email address as username for check-in attribution.
@@ -688,14 +695,16 @@
688695
gg.zUser = db_text(gg.zUser,
689696
"SELECT user FROM fx_git WHERE email=%Q", z);
690697
}
691698
secSince1970 = 0;
692699
for(zTo++; fossil_isdigit(*zTo); zTo++){
700
+ if( secSince1970>=100000000000LL ) goto malformed_line;
693701
secSince1970 = secSince1970*10 + *zTo - '0';
694702
}
695703
fossil_free(gg.zDate);
696704
gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')",secSince1970);
705
+ if( gg.zDate==0 || strlen(gg.zDate)<19 ) goto malformed_line;
697706
gg.zDate[10] = 'T';
698707
}else
699708
if( strncmp(zLine, "from ", 5)==0 ){
700709
trim_newline(&zLine[5]);
701710
fossil_free(gg.zFromMark);
@@ -860,10 +869,11 @@
860869
KeyVal *aHeaders;
861870
int nHeaders;
862871
char *pRawProps;
863872
KeyVal *aProps;
864873
int nProps;
874
+ int deletesExec; /* A property delta deletes svn:executable */
865875
Blob content;
866876
int contentFlag;
867877
} SvnRecord;
868878
869879
#define svn_find_header(rec, zHeader) \
@@ -892,20 +902,35 @@
892902
fossil_free(rec->aHeaders);
893903
fossil_free(rec->aProps);
894904
fossil_free(rec->pRawProps);
895905
blob_reset(&rec->content);
896906
}
907
+
908
+/*
909
+** Return the decimal number at z. It must be all digits up to the byte
910
+** cEnd and no more than 2147483647, or else the dump is broken.
911
+*/
912
+static int svn_number(const char *z, char cEnd){
913
+ i64 v = 0;
914
+ int i;
915
+ for(i=0; fossil_isdigit(z[i]) && v<=0x7fffffff; i++){
916
+ v = v*10 + z[i] - '0';
917
+ }
918
+ if( i==0 || z[i]!=cEnd || v>0x7fffffff ){
919
+ fossil_fatal("svn-dump data format broken");
920
+ }
921
+ return (int)v;
922
+}
897923
898924
static int svn_read_headers(FILE *pIn, SvnRecord *rec){
899925
char zLine[1000];
926
+ char *z;
900927
901928
rec->aHeaders = 0;
902929
rec->nHeaders = 0;
903
- while( fgets(zLine, sizeof(zLine), pIn) ){
904
- if( zLine[0]!='\n' ) break;
905
- }
906
- if( feof(pIn) ) return 0;
930
+ while( (z = fgets(zLine, sizeof(zLine), pIn))!=0 && zLine[0]=='\n' ){}
931
+ if( z==0 ) return 0;
907932
do{
908933
char *sep;
909934
if( zLine[0]=='\n' ) break;
910935
rec->nHeaders += 1;
911936
rec->aHeaders = fossil_realloc(rec->aHeaders,
@@ -917,10 +942,13 @@
917942
fossil_fatal("bad header line: [%s]", zLine);
918943
}
919944
*sep = 0;
920945
rec->aHeaders[rec->nHeaders-1].zVal = sep+1;
921946
sep = strchr(rec->aHeaders[rec->nHeaders-1].zVal, '\n');
947
+ if( !sep ){
948
+ fossil_fatal("svn-dump data format broken");
949
+ }
922950
*sep = 0;
923951
while(rec->aHeaders[rec->nHeaders-1].zVal
924952
&& fossil_isspace(*(rec->aHeaders[rec->nHeaders-1].zVal)) )
925953
{
926954
rec->aHeaders[rec->nHeaders-1].zVal++;
@@ -939,16 +967,14 @@
939967
const char *zLen;
940968
941969
rec->pRawProps = 0;
942970
rec->aProps = 0;
943971
rec->nProps = 0;
972
+ rec->deletesExec = 0;
944973
zLen = svn_find_header(*rec, "Prop-content-length");
945974
if( zLen ){
946
- nRawProps = atoi(zLen);
947
- if( nRawProps<0 ){
948
- fossil_fatal("svn-dump data format broken");
949
- }
975
+ nRawProps = svn_number(zLen, 0);
950976
}
951977
if( nRawProps ){
952978
int got;
953979
char *zLine;
954980
char *zEnd; /* Start of the PROPS-END marker */
@@ -964,27 +990,30 @@
964990
zEnd = pRawProps+nRawProps-10;
965991
while( zLine<zEnd ){
966992
char *eol;
967993
int propLen;
968994
if( zLine[0]=='D' ){
969
- propLen = atoi(&zLine[2]);
995
+ propLen = svn_number(&zLine[2], '\n');
970996
eol = strchr(zLine, '\n');
971
- if( eol==0 || eol>=zEnd || propLen<0 || propLen>zEnd-eol ){
997
+ if( eol==0 || eol>=zEnd || propLen>zEnd-eol ){
972998
fossil_fatal("svn-dump data format broken");
999
+ }
1000
+ if( propLen==14 && strncmp(eol+1, "svn:executable", 14)==0 ){
1001
+ rec->deletesExec = 1;
9731002
}
9741003
zLine = eol+1+propLen+1;
9751004
}else{
9761005
if( zLine[0]!='K' ){
9771006
fossil_fatal("svn-dump data format broken");
9781007
}
979
- propLen = atoi(&zLine[2]);
1008
+ propLen = svn_number(&zLine[2], '\n');
9801009
eol = strchr(zLine, '\n');
9811010
if( eol==0 || eol>=zEnd ){
9821011
fossil_fatal("svn-dump data format broken");
9831012
}
9841013
zLine = eol+1;
985
- if( propLen<0 || propLen>=zEnd-zLine ){
1014
+ if( propLen>=zEnd-zLine ){
9861015
fossil_fatal("svn-dump data format broken");
9871016
}
9881017
eol = zLine+propLen;
9891018
if( *eol!='\n' ){
9901019
fossil_fatal("svn-dump data format broken");
@@ -996,17 +1025,17 @@
9961025
rec->aProps[rec->nProps-1].zKey = zLine;
9971026
zLine = eol+1;
9981027
if( zLine[0]!='V' ){
9991028
fossil_fatal("svn-dump data format broken");
10001029
}
1001
- propLen = atoi(&zLine[2]);
1030
+ propLen = svn_number(&zLine[2], '\n');
10021031
eol = strchr(zLine, '\n');
10031032
if( eol==0 || eol>=zEnd ){
10041033
fossil_fatal("svn-dump data format broken");
10051034
}
10061035
zLine = eol+1;
1007
- if( propLen<0 || propLen>=zEnd-zLine ){
1036
+ if( propLen>=zEnd-zLine ){
10081037
fossil_fatal("svn-dump data format broken");
10091038
}
10101039
eol = zLine+propLen;
10111040
if( *eol!='\n' ){
10121041
fossil_fatal("svn-dump data format broken");
@@ -1026,11 +1055,11 @@
10261055
svn_read_props(pIn, rec);
10271056
blob_zero(&rec->content);
10281057
zLen = svn_find_header(*rec, "Text-content-length");
10291058
if( zLen ){
10301059
rec->contentFlag = 1;
1031
- nLen = atoi(zLen);
1060
+ nLen = svn_number(zLen, 0);
10321061
blob_read_from_channel(&rec->content, pIn, nLen);
10331062
if( (int)blob_size(&rec->content)!=nLen ){
10341063
fossil_fatal("short read: got %d of %d bytes",
10351064
blob_size(&rec->content), nLen
10361065
);
@@ -1203,17 +1232,17 @@
12031232
int rid = content_put(&manifest);
12041233
db_bind_int(&setRid, ":branch", branchId);
12051234
db_bind_int(&setRid, ":rid", rid);
12061235
db_step(&setRid);
12071236
db_reset(&setRid);
1208
- }else if( branchType==SVN_TAG ){
1237
+ }else if( branchType==SVN_TAG && parentRid>0 ){
12091238
content_put(&manifest);
12101239
db_bind_int(&setRid, ":branch", branchId);
12111240
db_bind_int(&setRid, ":rid", parentRid);
12121241
db_step(&setRid);
12131242
db_reset(&setRid);
1214
- }else if( mergeRid==MAX_INT_32 ){
1243
+ }else if( mergeRid==MAX_INT_32 && parentRid>0 ){
12151244
content_put(&manifest);
12161245
db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
12171246
branchId, gsvn.rev);
12181247
}else{
12191248
db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
@@ -1434,11 +1463,11 @@
14341463
Stmt revSrc;
14351464
14361465
/* version */
14371466
if( svn_read_rec(pIn, &rec)
14381467
&& (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
1439
- ver = atoi(zTemp);
1468
+ ver = svn_number(zTemp, 0);
14401469
if( ver!=2 && ver!=3 ){
14411470
fossil_fatal("Unknown svn-dump format version: %d", ver);
14421471
}
14431472
}else{
14441473
fossil_fatal("Input is not an svn-dump!");
@@ -1495,11 +1524,11 @@
14951524
fossil_free(gsvn.zComment);
14961525
fossil_free(gsvn.zDate);
14971526
bag_clear(&gsvn.newBranches);
14981527
}
14991528
/* start new revision */
1500
- gsvn.rev = atoi(zTemp);
1529
+ gsvn.rev = svn_number(zTemp, 0);
15011530
gsvn.zUser = fossil_strdup(svn_find_prop(rec, "svn:author"));
15021531
gsvn.zComment = fossil_strdup(svn_find_prop(rec, "svn:log"));
15031532
zDate = svn_find_prop(rec, "svn:date");
15041533
if( zDate ){
15051534
gsvn.zDate = date_in_standard_format(zDate);
@@ -1524,10 +1553,21 @@
15241553
}
15251554
if( branchId==0 ){
15261555
svn_free_rec(&rec);
15271556
continue;
15281557
}
1558
+ if( zAction==0 || gsvn.rev<0 ){
1559
+ fossil_fatal("svn-dump data format broken");
1560
+ }
1561
+ if( zFile[0]==0 ){
1562
+ if( zKind!=0 && strncmp(zKind, "dir", 3)!=0 ){
1563
+ svn_free_rec(&rec);
1564
+ continue;
1565
+ }
1566
+ }else if( !file_is_simple_pathname_nonstrict(zFile) ){
1567
+ fossil_fatal("svn path is not a valid file name: %s", zFile);
1568
+ }
15291569
if( (zTemp = svn_find_header(rec, "Text-delta")) ){
15301570
deltaFlag = strncmp(zTemp, "true", 4)==0;
15311571
}
15321572
if( strncmp(zAction, "delete", 6)==0
15331573
|| strncmp(zAction, "replace", 7)==0 )
@@ -1557,11 +1597,11 @@
15571597
int srcRid = 0;
15581598
if( zSrcPath ){
15591599
int srcBranch;
15601600
zTemp = svn_find_header(rec, "Node-copyfrom-rev");
15611601
if( zTemp ){
1562
- srcRev = atoi(zTemp);
1602
+ srcRev = svn_number(zTemp, 0);
15631603
}else{
15641604
fossil_fatal("Missing copyfrom-rev");
15651605
}
15661606
srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
15671607
if( srcBranch==0 ){
@@ -1568,14 +1608,16 @@
15681608
fossil_fatal("Copy from path outside the import paths");
15691609
}
15701610
srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
15711611
" WHERE trev<=%d AND tbranch=%d",
15721612
srcRev, srcBranch);
1573
- if( srcRid>0 && srcBranch!=branchId ){
1613
+ if( srcRid>0 ){
15741614
db_bind_int(&addRev, ":branch", branchId);
15751615
db_step(&addRev);
15761616
db_reset(&addRev);
1617
+ }
1618
+ if( srcRid>0 && (srcBranch!=branchId || zFile[0]==0) ){
15771619
db_bind_int(&revSrc, ":parent", srcRid);
15781620
db_bind_int(&revSrc, ":rev", gsvn.rev);
15791621
db_bind_int(&revSrc, ":branch", branchId);
15801622
db_step(&revSrc);
15811623
db_reset(&revSrc);
@@ -1621,10 +1663,23 @@
16211663
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
16221664
" SELECT uuid FROM xfoci"
16231665
" WHERE checkinID=%d AND filename=%Q"
16241666
")",
16251667
srcRid, zSrcFile);
1668
+ zTemp = svn_find_header(rec, "Prop-delta");
1669
+ if( zPerm==0
1670
+ && (svn_find_header(rec, "Prop-content-length")==0
1671
+ || (zTemp && strncmp(zTemp, "true", 4)==0)) ){
1672
+ zPerm = db_text(0, "SELECT perm FROM xfoci"
1673
+ " WHERE checkinID=%d AND filename=%Q"
1674
+ " AND perm<>''",
1675
+ srcRid, zSrcFile);
1676
+ if( zPerm && rec.deletesExec && strcmp(zPerm, "x")==0 ){
1677
+ fossil_free(zPerm);
1678
+ zPerm = 0;
1679
+ }
1680
+ }
16261681
}
16271682
if( deltaFlag ){
16281683
Blob deltaSrc;
16291684
Blob target;
16301685
if( rid!=0 ){
@@ -1636,16 +1691,13 @@
16361691
rid = svn_handle_symlinks(zPerm, &target);
16371692
blob_reset(&deltaSrc);
16381693
blob_reset(&target);
16391694
}else if( rec.contentFlag ){
16401695
rid = svn_handle_symlinks(zPerm, &rec.content);
1641
- }else if( zSrcPath ){
1642
- if ( zPerm==0 ){
1643
- zPerm = db_text(0, "SELECT tperm FROM xfiles"
1644
- " WHERE tpath=%Q AND tbranch=%d"
1645
- "", zSrcPath, branchId);
1646
- }
1696
+ }
1697
+ if( rid==0 ){
1698
+ fossil_fatal("svn file has no content and no source: %s", zFile);
16471699
}
16481700
db_bind_text(&addFile, ":path", zFile);
16491701
db_bind_int(&addFile, ":branch", branchId);
16501702
db_bind_int(&addFile, ":rid", rid);
16511703
db_bind_text(&addFile, ":perm", zPerm);
@@ -1793,11 +1845,10 @@
17931845
char *zPassword;
17941846
FILE *pIn;
17951847
Stmt q;
17961848
int forceFlag = find_option("force", "f", 0)!=0;
17971849
int svnFlag = find_option("svn", 0, 0)!=0;
1798
- int gitFlag = find_option("git", 0, 0)!=0;
17991850
int omitRebuild = find_option("no-rebuild",0,0)!=0;
18001851
int omitVacuum = find_option("no-vacuum",0,0)!=0;
18011852
const char *zDefaultUser = find_option("admin-user","A",1);
18021853
18031854
/* Options common to all input formats */
@@ -1843,10 +1894,11 @@
18431894
}
18441895
if( !(gimport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
18451896
gimport.zTrunkName = fossil_strdup(db_main_branch());
18461897
}
18471898
1899
+ find_option("git", 0, 0);
18481900
if( svnFlag ){
18491901
/* Get --svn related options here, so verify_all_options() fails when
18501902
* svn-only options are specified with --git
18511903
*/
18521904
const char *zIgnTree;
@@ -1864,11 +1916,11 @@
18641916
gsvn.zTrunk = find_option("trunk", 0, 1);
18651917
gsvn.zBranches = find_option("branches", 0, 1);
18661918
gsvn.zTags = find_option("tags", 0, 1);
18671919
gsvn.revFlag = find_option("rev-tags", 0, 0)
18681920
|| (incrFlag && !find_option("no-rev-tags", 0, 0));
1869
- }else if( gitFlag ){
1921
+ }else{
18701922
const char *zGitUser;
18711923
markfile_in = find_option("import-marks", 0, 1);
18721924
markfile_out = find_option("export-marks", 0, 1);
18731925
if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
18741926
ggit.zMasterName = "master";
@@ -1900,11 +1952,16 @@
19001952
}else{
19011953
pIn = stdin;
19021954
fossil_binary_mode(pIn);
19031955
}
19041956
if( !incrFlag ){
1905
- if( forceFlag ) file_delete(g.argv[2]);
1957
+ if( forceFlag ){
1958
+ file_delete(g.argv[2]);
1959
+ }else if( -1 != file_size(g.argv[2], ExtFILE) ){
1960
+ fossil_fatal("file already exists: %s (use --force to replace it)",
1961
+ g.argv[2]);
1962
+ }
19061963
db_create_repository(g.argv[2]);
19071964
}
19081965
db_open_repository(g.argv[2]);
19091966
db_open_config(0, 0);
19101967
db_unprotect(PROTECT_ALL);
@@ -1954,10 +2011,14 @@
19542011
gsvn.zBranches = mprintf("%s%s", zBase, gsvn.zBranches);
19552012
gsvn.zTags = mprintf("%s%s", zBase, gsvn.zTags);
19562013
gsvn.lenTrunk = strlen(gsvn.zTrunk);
19572014
gsvn.lenBranches = strlen(gsvn.zBranches);
19582015
gsvn.lenTags = strlen(gsvn.zTags);
2016
+ if( gsvn.lenTrunk==0 || gsvn.lenBranches==0 || gsvn.lenTags==0 ){
2017
+ fossil_fatal("--trunk, --branches and --tags may be empty only "
2018
+ "with a non-empty --base");
2019
+ }
19592020
if( gsvn.zTrunk[gsvn.lenTrunk-1]!='/' ){
19602021
gsvn.zTrunk = mprintf("%s/", gsvn.zTrunk);
19612022
gsvn.lenTrunk++;
19622023
}
19632024
if( gsvn.zBranches[gsvn.lenBranches-1]!='/' ){
19642025
--- src/import.c
+++ src/import.c
@@ -569,10 +569,11 @@
569 gg.xFinish();
570 gg.xFinish = finish_blob;
571 }else
572 if( strncmp(zLine, "commit ", 7)==0 ){
573 const char *zRefName;
 
574 gg.xFinish();
575 gg.xFinish = finish_commit;
576 trim_newline(&zLine[7]);
577 zRefName = &zLine[7];
578
@@ -592,13 +593,15 @@
592 ** last commit that holds that tag.
593 **
594 ** None of the above is explained in the git-fast-export
595 ** documentation. We had to figure it out via trial and error.
596 */
597 for(i=5; i<(int)strlen(zRefName) && zRefName[i]!='/'; i++){}
598 gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */
599 if( zRefName[i+1]!=0 ) zRefName += i+1;
 
 
600 if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
601 gg.zBranch = fossil_strdup(zRefName);
602 gg.fromLoaded = 0;
603 }else
604 if( strncmp(zLine, "tag ", 4)==0 ){
@@ -625,10 +628,13 @@
625 fossil_print("%s\n", &zLine[9]);
626 fflush(stdout);
627 }else
628 if( strncmp(zLine, "data ", 5)==0 ){
629 fossil_free(gg.aData); gg.aData = 0;
 
 
 
630 gg.nData = atoi(&zLine[5]);
631 if( gg.nData ){
632 int got;
633 gg.aData = fossil_malloc( gg.nData+1 );
634 got = fread(gg.aData, 1, gg.nData, pIn);
@@ -666,10 +672,11 @@
666 || strncmp(zLine, "committer ",10)==0 ){
667 sqlite3_int64 secSince1970;
668 z = strchr(zLine, ' ');
669 while( fossil_isspace(*z) ) z++;
670 if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
 
671 *(++zTo) = '\0';
672 /*
673 ** If --attribute requested, lookup user in fx_ table by email address,
674 ** otherwise lookup Git {author,committer} contact info in user table. If
675 ** no matches, use email address as username for check-in attribution.
@@ -688,14 +695,16 @@
688 gg.zUser = db_text(gg.zUser,
689 "SELECT user FROM fx_git WHERE email=%Q", z);
690 }
691 secSince1970 = 0;
692 for(zTo++; fossil_isdigit(*zTo); zTo++){
 
693 secSince1970 = secSince1970*10 + *zTo - '0';
694 }
695 fossil_free(gg.zDate);
696 gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')",secSince1970);
 
697 gg.zDate[10] = 'T';
698 }else
699 if( strncmp(zLine, "from ", 5)==0 ){
700 trim_newline(&zLine[5]);
701 fossil_free(gg.zFromMark);
@@ -860,10 +869,11 @@
860 KeyVal *aHeaders;
861 int nHeaders;
862 char *pRawProps;
863 KeyVal *aProps;
864 int nProps;
 
865 Blob content;
866 int contentFlag;
867 } SvnRecord;
868
869 #define svn_find_header(rec, zHeader) \
@@ -892,20 +902,35 @@
892 fossil_free(rec->aHeaders);
893 fossil_free(rec->aProps);
894 fossil_free(rec->pRawProps);
895 blob_reset(&rec->content);
896 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
897
898 static int svn_read_headers(FILE *pIn, SvnRecord *rec){
899 char zLine[1000];
 
900
901 rec->aHeaders = 0;
902 rec->nHeaders = 0;
903 while( fgets(zLine, sizeof(zLine), pIn) ){
904 if( zLine[0]!='\n' ) break;
905 }
906 if( feof(pIn) ) return 0;
907 do{
908 char *sep;
909 if( zLine[0]=='\n' ) break;
910 rec->nHeaders += 1;
911 rec->aHeaders = fossil_realloc(rec->aHeaders,
@@ -917,10 +942,13 @@
917 fossil_fatal("bad header line: [%s]", zLine);
918 }
919 *sep = 0;
920 rec->aHeaders[rec->nHeaders-1].zVal = sep+1;
921 sep = strchr(rec->aHeaders[rec->nHeaders-1].zVal, '\n');
 
 
 
922 *sep = 0;
923 while(rec->aHeaders[rec->nHeaders-1].zVal
924 && fossil_isspace(*(rec->aHeaders[rec->nHeaders-1].zVal)) )
925 {
926 rec->aHeaders[rec->nHeaders-1].zVal++;
@@ -939,16 +967,14 @@
939 const char *zLen;
940
941 rec->pRawProps = 0;
942 rec->aProps = 0;
943 rec->nProps = 0;
 
944 zLen = svn_find_header(*rec, "Prop-content-length");
945 if( zLen ){
946 nRawProps = atoi(zLen);
947 if( nRawProps<0 ){
948 fossil_fatal("svn-dump data format broken");
949 }
950 }
951 if( nRawProps ){
952 int got;
953 char *zLine;
954 char *zEnd; /* Start of the PROPS-END marker */
@@ -964,27 +990,30 @@
964 zEnd = pRawProps+nRawProps-10;
965 while( zLine<zEnd ){
966 char *eol;
967 int propLen;
968 if( zLine[0]=='D' ){
969 propLen = atoi(&zLine[2]);
970 eol = strchr(zLine, '\n');
971 if( eol==0 || eol>=zEnd || propLen<0 || propLen>zEnd-eol ){
972 fossil_fatal("svn-dump data format broken");
 
 
 
973 }
974 zLine = eol+1+propLen+1;
975 }else{
976 if( zLine[0]!='K' ){
977 fossil_fatal("svn-dump data format broken");
978 }
979 propLen = atoi(&zLine[2]);
980 eol = strchr(zLine, '\n');
981 if( eol==0 || eol>=zEnd ){
982 fossil_fatal("svn-dump data format broken");
983 }
984 zLine = eol+1;
985 if( propLen<0 || propLen>=zEnd-zLine ){
986 fossil_fatal("svn-dump data format broken");
987 }
988 eol = zLine+propLen;
989 if( *eol!='\n' ){
990 fossil_fatal("svn-dump data format broken");
@@ -996,17 +1025,17 @@
996 rec->aProps[rec->nProps-1].zKey = zLine;
997 zLine = eol+1;
998 if( zLine[0]!='V' ){
999 fossil_fatal("svn-dump data format broken");
1000 }
1001 propLen = atoi(&zLine[2]);
1002 eol = strchr(zLine, '\n');
1003 if( eol==0 || eol>=zEnd ){
1004 fossil_fatal("svn-dump data format broken");
1005 }
1006 zLine = eol+1;
1007 if( propLen<0 || propLen>=zEnd-zLine ){
1008 fossil_fatal("svn-dump data format broken");
1009 }
1010 eol = zLine+propLen;
1011 if( *eol!='\n' ){
1012 fossil_fatal("svn-dump data format broken");
@@ -1026,11 +1055,11 @@
1026 svn_read_props(pIn, rec);
1027 blob_zero(&rec->content);
1028 zLen = svn_find_header(*rec, "Text-content-length");
1029 if( zLen ){
1030 rec->contentFlag = 1;
1031 nLen = atoi(zLen);
1032 blob_read_from_channel(&rec->content, pIn, nLen);
1033 if( (int)blob_size(&rec->content)!=nLen ){
1034 fossil_fatal("short read: got %d of %d bytes",
1035 blob_size(&rec->content), nLen
1036 );
@@ -1203,17 +1232,17 @@
1203 int rid = content_put(&manifest);
1204 db_bind_int(&setRid, ":branch", branchId);
1205 db_bind_int(&setRid, ":rid", rid);
1206 db_step(&setRid);
1207 db_reset(&setRid);
1208 }else if( branchType==SVN_TAG ){
1209 content_put(&manifest);
1210 db_bind_int(&setRid, ":branch", branchId);
1211 db_bind_int(&setRid, ":rid", parentRid);
1212 db_step(&setRid);
1213 db_reset(&setRid);
1214 }else if( mergeRid==MAX_INT_32 ){
1215 content_put(&manifest);
1216 db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
1217 branchId, gsvn.rev);
1218 }else{
1219 db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
@@ -1434,11 +1463,11 @@
1434 Stmt revSrc;
1435
1436 /* version */
1437 if( svn_read_rec(pIn, &rec)
1438 && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
1439 ver = atoi(zTemp);
1440 if( ver!=2 && ver!=3 ){
1441 fossil_fatal("Unknown svn-dump format version: %d", ver);
1442 }
1443 }else{
1444 fossil_fatal("Input is not an svn-dump!");
@@ -1495,11 +1524,11 @@
1495 fossil_free(gsvn.zComment);
1496 fossil_free(gsvn.zDate);
1497 bag_clear(&gsvn.newBranches);
1498 }
1499 /* start new revision */
1500 gsvn.rev = atoi(zTemp);
1501 gsvn.zUser = fossil_strdup(svn_find_prop(rec, "svn:author"));
1502 gsvn.zComment = fossil_strdup(svn_find_prop(rec, "svn:log"));
1503 zDate = svn_find_prop(rec, "svn:date");
1504 if( zDate ){
1505 gsvn.zDate = date_in_standard_format(zDate);
@@ -1524,10 +1553,21 @@
1524 }
1525 if( branchId==0 ){
1526 svn_free_rec(&rec);
1527 continue;
1528 }
 
 
 
 
 
 
 
 
 
 
 
1529 if( (zTemp = svn_find_header(rec, "Text-delta")) ){
1530 deltaFlag = strncmp(zTemp, "true", 4)==0;
1531 }
1532 if( strncmp(zAction, "delete", 6)==0
1533 || strncmp(zAction, "replace", 7)==0 )
@@ -1557,11 +1597,11 @@
1557 int srcRid = 0;
1558 if( zSrcPath ){
1559 int srcBranch;
1560 zTemp = svn_find_header(rec, "Node-copyfrom-rev");
1561 if( zTemp ){
1562 srcRev = atoi(zTemp);
1563 }else{
1564 fossil_fatal("Missing copyfrom-rev");
1565 }
1566 srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
1567 if( srcBranch==0 ){
@@ -1568,14 +1608,16 @@
1568 fossil_fatal("Copy from path outside the import paths");
1569 }
1570 srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1571 " WHERE trev<=%d AND tbranch=%d",
1572 srcRev, srcBranch);
1573 if( srcRid>0 && srcBranch!=branchId ){
1574 db_bind_int(&addRev, ":branch", branchId);
1575 db_step(&addRev);
1576 db_reset(&addRev);
 
 
1577 db_bind_int(&revSrc, ":parent", srcRid);
1578 db_bind_int(&revSrc, ":rev", gsvn.rev);
1579 db_bind_int(&revSrc, ":branch", branchId);
1580 db_step(&revSrc);
1581 db_reset(&revSrc);
@@ -1621,10 +1663,23 @@
1621 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
1622 " SELECT uuid FROM xfoci"
1623 " WHERE checkinID=%d AND filename=%Q"
1624 ")",
1625 srcRid, zSrcFile);
 
 
 
 
 
 
 
 
 
 
 
 
 
1626 }
1627 if( deltaFlag ){
1628 Blob deltaSrc;
1629 Blob target;
1630 if( rid!=0 ){
@@ -1636,16 +1691,13 @@
1636 rid = svn_handle_symlinks(zPerm, &target);
1637 blob_reset(&deltaSrc);
1638 blob_reset(&target);
1639 }else if( rec.contentFlag ){
1640 rid = svn_handle_symlinks(zPerm, &rec.content);
1641 }else if( zSrcPath ){
1642 if ( zPerm==0 ){
1643 zPerm = db_text(0, "SELECT tperm FROM xfiles"
1644 " WHERE tpath=%Q AND tbranch=%d"
1645 "", zSrcPath, branchId);
1646 }
1647 }
1648 db_bind_text(&addFile, ":path", zFile);
1649 db_bind_int(&addFile, ":branch", branchId);
1650 db_bind_int(&addFile, ":rid", rid);
1651 db_bind_text(&addFile, ":perm", zPerm);
@@ -1793,11 +1845,10 @@
1793 char *zPassword;
1794 FILE *pIn;
1795 Stmt q;
1796 int forceFlag = find_option("force", "f", 0)!=0;
1797 int svnFlag = find_option("svn", 0, 0)!=0;
1798 int gitFlag = find_option("git", 0, 0)!=0;
1799 int omitRebuild = find_option("no-rebuild",0,0)!=0;
1800 int omitVacuum = find_option("no-vacuum",0,0)!=0;
1801 const char *zDefaultUser = find_option("admin-user","A",1);
1802
1803 /* Options common to all input formats */
@@ -1843,10 +1894,11 @@
1843 }
1844 if( !(gimport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
1845 gimport.zTrunkName = fossil_strdup(db_main_branch());
1846 }
1847
 
1848 if( svnFlag ){
1849 /* Get --svn related options here, so verify_all_options() fails when
1850 * svn-only options are specified with --git
1851 */
1852 const char *zIgnTree;
@@ -1864,11 +1916,11 @@
1864 gsvn.zTrunk = find_option("trunk", 0, 1);
1865 gsvn.zBranches = find_option("branches", 0, 1);
1866 gsvn.zTags = find_option("tags", 0, 1);
1867 gsvn.revFlag = find_option("rev-tags", 0, 0)
1868 || (incrFlag && !find_option("no-rev-tags", 0, 0));
1869 }else if( gitFlag ){
1870 const char *zGitUser;
1871 markfile_in = find_option("import-marks", 0, 1);
1872 markfile_out = find_option("export-marks", 0, 1);
1873 if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
1874 ggit.zMasterName = "master";
@@ -1900,11 +1952,16 @@
1900 }else{
1901 pIn = stdin;
1902 fossil_binary_mode(pIn);
1903 }
1904 if( !incrFlag ){
1905 if( forceFlag ) file_delete(g.argv[2]);
 
 
 
 
 
1906 db_create_repository(g.argv[2]);
1907 }
1908 db_open_repository(g.argv[2]);
1909 db_open_config(0, 0);
1910 db_unprotect(PROTECT_ALL);
@@ -1954,10 +2011,14 @@
1954 gsvn.zBranches = mprintf("%s%s", zBase, gsvn.zBranches);
1955 gsvn.zTags = mprintf("%s%s", zBase, gsvn.zTags);
1956 gsvn.lenTrunk = strlen(gsvn.zTrunk);
1957 gsvn.lenBranches = strlen(gsvn.zBranches);
1958 gsvn.lenTags = strlen(gsvn.zTags);
 
 
 
 
1959 if( gsvn.zTrunk[gsvn.lenTrunk-1]!='/' ){
1960 gsvn.zTrunk = mprintf("%s/", gsvn.zTrunk);
1961 gsvn.lenTrunk++;
1962 }
1963 if( gsvn.zBranches[gsvn.lenBranches-1]!='/' ){
1964
--- src/import.c
+++ src/import.c
@@ -569,10 +569,11 @@
569 gg.xFinish();
570 gg.xFinish = finish_blob;
571 }else
572 if( strncmp(zLine, "commit ", 7)==0 ){
573 const char *zRefName;
574 int nRef;
575 gg.xFinish();
576 gg.xFinish = finish_commit;
577 trim_newline(&zLine[7]);
578 zRefName = &zLine[7];
579
@@ -592,13 +593,15 @@
593 ** last commit that holds that tag.
594 **
595 ** None of the above is explained in the git-fast-export
596 ** documentation. We had to figure it out via trial and error.
597 */
598 nRef = (int)strlen(zRefName);
599 for(i=5; i<nRef && zRefName[i]!='/'; i++){}
600 gg.tagCommit = nRef>=9
601 && strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */
602 if( i<nRef && zRefName[i+1]!=0 ) zRefName += i+1;
603 if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
604 gg.zBranch = fossil_strdup(zRefName);
605 gg.fromLoaded = 0;
606 }else
607 if( strncmp(zLine, "tag ", 4)==0 ){
@@ -625,10 +628,13 @@
628 fossil_print("%s\n", &zLine[9]);
629 fflush(stdout);
630 }else
631 if( strncmp(zLine, "data ", 5)==0 ){
632 fossil_free(gg.aData); gg.aData = 0;
633 if( !fossil_isdigit(zLine[5]) || strtoll(&zLine[5], 0, 10)>=0x7fffffff ){
634 goto malformed_line;
635 }
636 gg.nData = atoi(&zLine[5]);
637 if( gg.nData ){
638 int got;
639 gg.aData = fossil_malloc( gg.nData+1 );
640 got = fread(gg.aData, 1, gg.nData, pIn);
@@ -666,10 +672,11 @@
672 || strncmp(zLine, "committer ",10)==0 ){
673 sqlite3_int64 secSince1970;
674 z = strchr(zLine, ' ');
675 while( fossil_isspace(*z) ) z++;
676 if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
677 if( zTo[1]!=' ' ) goto malformed_line;
678 *(++zTo) = '\0';
679 /*
680 ** If --attribute requested, lookup user in fx_ table by email address,
681 ** otherwise lookup Git {author,committer} contact info in user table. If
682 ** no matches, use email address as username for check-in attribution.
@@ -688,14 +695,16 @@
695 gg.zUser = db_text(gg.zUser,
696 "SELECT user FROM fx_git WHERE email=%Q", z);
697 }
698 secSince1970 = 0;
699 for(zTo++; fossil_isdigit(*zTo); zTo++){
700 if( secSince1970>=100000000000LL ) goto malformed_line;
701 secSince1970 = secSince1970*10 + *zTo - '0';
702 }
703 fossil_free(gg.zDate);
704 gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')",secSince1970);
705 if( gg.zDate==0 || strlen(gg.zDate)<19 ) goto malformed_line;
706 gg.zDate[10] = 'T';
707 }else
708 if( strncmp(zLine, "from ", 5)==0 ){
709 trim_newline(&zLine[5]);
710 fossil_free(gg.zFromMark);
@@ -860,10 +869,11 @@
869 KeyVal *aHeaders;
870 int nHeaders;
871 char *pRawProps;
872 KeyVal *aProps;
873 int nProps;
874 int deletesExec; /* A property delta deletes svn:executable */
875 Blob content;
876 int contentFlag;
877 } SvnRecord;
878
879 #define svn_find_header(rec, zHeader) \
@@ -892,20 +902,35 @@
902 fossil_free(rec->aHeaders);
903 fossil_free(rec->aProps);
904 fossil_free(rec->pRawProps);
905 blob_reset(&rec->content);
906 }
907
908 /*
909 ** Return the decimal number at z. It must be all digits up to the byte
910 ** cEnd and no more than 2147483647, or else the dump is broken.
911 */
912 static int svn_number(const char *z, char cEnd){
913 i64 v = 0;
914 int i;
915 for(i=0; fossil_isdigit(z[i]) && v<=0x7fffffff; i++){
916 v = v*10 + z[i] - '0';
917 }
918 if( i==0 || z[i]!=cEnd || v>0x7fffffff ){
919 fossil_fatal("svn-dump data format broken");
920 }
921 return (int)v;
922 }
923
924 static int svn_read_headers(FILE *pIn, SvnRecord *rec){
925 char zLine[1000];
926 char *z;
927
928 rec->aHeaders = 0;
929 rec->nHeaders = 0;
930 while( (z = fgets(zLine, sizeof(zLine), pIn))!=0 && zLine[0]=='\n' ){}
931 if( z==0 ) return 0;
 
 
932 do{
933 char *sep;
934 if( zLine[0]=='\n' ) break;
935 rec->nHeaders += 1;
936 rec->aHeaders = fossil_realloc(rec->aHeaders,
@@ -917,10 +942,13 @@
942 fossil_fatal("bad header line: [%s]", zLine);
943 }
944 *sep = 0;
945 rec->aHeaders[rec->nHeaders-1].zVal = sep+1;
946 sep = strchr(rec->aHeaders[rec->nHeaders-1].zVal, '\n');
947 if( !sep ){
948 fossil_fatal("svn-dump data format broken");
949 }
950 *sep = 0;
951 while(rec->aHeaders[rec->nHeaders-1].zVal
952 && fossil_isspace(*(rec->aHeaders[rec->nHeaders-1].zVal)) )
953 {
954 rec->aHeaders[rec->nHeaders-1].zVal++;
@@ -939,16 +967,14 @@
967 const char *zLen;
968
969 rec->pRawProps = 0;
970 rec->aProps = 0;
971 rec->nProps = 0;
972 rec->deletesExec = 0;
973 zLen = svn_find_header(*rec, "Prop-content-length");
974 if( zLen ){
975 nRawProps = svn_number(zLen, 0);
 
 
 
976 }
977 if( nRawProps ){
978 int got;
979 char *zLine;
980 char *zEnd; /* Start of the PROPS-END marker */
@@ -964,27 +990,30 @@
990 zEnd = pRawProps+nRawProps-10;
991 while( zLine<zEnd ){
992 char *eol;
993 int propLen;
994 if( zLine[0]=='D' ){
995 propLen = svn_number(&zLine[2], '\n');
996 eol = strchr(zLine, '\n');
997 if( eol==0 || eol>=zEnd || propLen>zEnd-eol ){
998 fossil_fatal("svn-dump data format broken");
999 }
1000 if( propLen==14 && strncmp(eol+1, "svn:executable", 14)==0 ){
1001 rec->deletesExec = 1;
1002 }
1003 zLine = eol+1+propLen+1;
1004 }else{
1005 if( zLine[0]!='K' ){
1006 fossil_fatal("svn-dump data format broken");
1007 }
1008 propLen = svn_number(&zLine[2], '\n');
1009 eol = strchr(zLine, '\n');
1010 if( eol==0 || eol>=zEnd ){
1011 fossil_fatal("svn-dump data format broken");
1012 }
1013 zLine = eol+1;
1014 if( propLen>=zEnd-zLine ){
1015 fossil_fatal("svn-dump data format broken");
1016 }
1017 eol = zLine+propLen;
1018 if( *eol!='\n' ){
1019 fossil_fatal("svn-dump data format broken");
@@ -996,17 +1025,17 @@
1025 rec->aProps[rec->nProps-1].zKey = zLine;
1026 zLine = eol+1;
1027 if( zLine[0]!='V' ){
1028 fossil_fatal("svn-dump data format broken");
1029 }
1030 propLen = svn_number(&zLine[2], '\n');
1031 eol = strchr(zLine, '\n');
1032 if( eol==0 || eol>=zEnd ){
1033 fossil_fatal("svn-dump data format broken");
1034 }
1035 zLine = eol+1;
1036 if( propLen>=zEnd-zLine ){
1037 fossil_fatal("svn-dump data format broken");
1038 }
1039 eol = zLine+propLen;
1040 if( *eol!='\n' ){
1041 fossil_fatal("svn-dump data format broken");
@@ -1026,11 +1055,11 @@
1055 svn_read_props(pIn, rec);
1056 blob_zero(&rec->content);
1057 zLen = svn_find_header(*rec, "Text-content-length");
1058 if( zLen ){
1059 rec->contentFlag = 1;
1060 nLen = svn_number(zLen, 0);
1061 blob_read_from_channel(&rec->content, pIn, nLen);
1062 if( (int)blob_size(&rec->content)!=nLen ){
1063 fossil_fatal("short read: got %d of %d bytes",
1064 blob_size(&rec->content), nLen
1065 );
@@ -1203,17 +1232,17 @@
1232 int rid = content_put(&manifest);
1233 db_bind_int(&setRid, ":branch", branchId);
1234 db_bind_int(&setRid, ":rid", rid);
1235 db_step(&setRid);
1236 db_reset(&setRid);
1237 }else if( branchType==SVN_TAG && parentRid>0 ){
1238 content_put(&manifest);
1239 db_bind_int(&setRid, ":branch", branchId);
1240 db_bind_int(&setRid, ":rid", parentRid);
1241 db_step(&setRid);
1242 db_reset(&setRid);
1243 }else if( mergeRid==MAX_INT_32 && parentRid>0 ){
1244 content_put(&manifest);
1245 db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
1246 branchId, gsvn.rev);
1247 }else{
1248 db_multi_exec("DELETE FROM xrevisions WHERE tbranch=%d AND trev=%d",
@@ -1434,11 +1463,11 @@
1463 Stmt revSrc;
1464
1465 /* version */
1466 if( svn_read_rec(pIn, &rec)
1467 && (zTemp = svn_find_header(rec, "SVN-fs-dump-format-version")) ){
1468 ver = svn_number(zTemp, 0);
1469 if( ver!=2 && ver!=3 ){
1470 fossil_fatal("Unknown svn-dump format version: %d", ver);
1471 }
1472 }else{
1473 fossil_fatal("Input is not an svn-dump!");
@@ -1495,11 +1524,11 @@
1524 fossil_free(gsvn.zComment);
1525 fossil_free(gsvn.zDate);
1526 bag_clear(&gsvn.newBranches);
1527 }
1528 /* start new revision */
1529 gsvn.rev = svn_number(zTemp, 0);
1530 gsvn.zUser = fossil_strdup(svn_find_prop(rec, "svn:author"));
1531 gsvn.zComment = fossil_strdup(svn_find_prop(rec, "svn:log"));
1532 zDate = svn_find_prop(rec, "svn:date");
1533 if( zDate ){
1534 gsvn.zDate = date_in_standard_format(zDate);
@@ -1524,10 +1553,21 @@
1553 }
1554 if( branchId==0 ){
1555 svn_free_rec(&rec);
1556 continue;
1557 }
1558 if( zAction==0 || gsvn.rev<0 ){
1559 fossil_fatal("svn-dump data format broken");
1560 }
1561 if( zFile[0]==0 ){
1562 if( zKind!=0 && strncmp(zKind, "dir", 3)!=0 ){
1563 svn_free_rec(&rec);
1564 continue;
1565 }
1566 }else if( !file_is_simple_pathname_nonstrict(zFile) ){
1567 fossil_fatal("svn path is not a valid file name: %s", zFile);
1568 }
1569 if( (zTemp = svn_find_header(rec, "Text-delta")) ){
1570 deltaFlag = strncmp(zTemp, "true", 4)==0;
1571 }
1572 if( strncmp(zAction, "delete", 6)==0
1573 || strncmp(zAction, "replace", 7)==0 )
@@ -1557,11 +1597,11 @@
1597 int srcRid = 0;
1598 if( zSrcPath ){
1599 int srcBranch;
1600 zTemp = svn_find_header(rec, "Node-copyfrom-rev");
1601 if( zTemp ){
1602 srcRev = svn_number(zTemp, 0);
1603 }else{
1604 fossil_fatal("Missing copyfrom-rev");
1605 }
1606 srcBranch = svn_parse_path(zSrcPath, &zSrcFile, &branchType);
1607 if( srcBranch==0 ){
@@ -1568,14 +1608,16 @@
1608 fossil_fatal("Copy from path outside the import paths");
1609 }
1610 srcRid = db_int(0, "SELECT trid, max(trev) FROM xrevisions"
1611 " WHERE trev<=%d AND tbranch=%d",
1612 srcRev, srcBranch);
1613 if( srcRid>0 ){
1614 db_bind_int(&addRev, ":branch", branchId);
1615 db_step(&addRev);
1616 db_reset(&addRev);
1617 }
1618 if( srcRid>0 && (srcBranch!=branchId || zFile[0]==0) ){
1619 db_bind_int(&revSrc, ":parent", srcRid);
1620 db_bind_int(&revSrc, ":rev", gsvn.rev);
1621 db_bind_int(&revSrc, ":branch", branchId);
1622 db_step(&revSrc);
1623 db_reset(&revSrc);
@@ -1621,10 +1663,23 @@
1663 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
1664 " SELECT uuid FROM xfoci"
1665 " WHERE checkinID=%d AND filename=%Q"
1666 ")",
1667 srcRid, zSrcFile);
1668 zTemp = svn_find_header(rec, "Prop-delta");
1669 if( zPerm==0
1670 && (svn_find_header(rec, "Prop-content-length")==0
1671 || (zTemp && strncmp(zTemp, "true", 4)==0)) ){
1672 zPerm = db_text(0, "SELECT perm FROM xfoci"
1673 " WHERE checkinID=%d AND filename=%Q"
1674 " AND perm<>''",
1675 srcRid, zSrcFile);
1676 if( zPerm && rec.deletesExec && strcmp(zPerm, "x")==0 ){
1677 fossil_free(zPerm);
1678 zPerm = 0;
1679 }
1680 }
1681 }
1682 if( deltaFlag ){
1683 Blob deltaSrc;
1684 Blob target;
1685 if( rid!=0 ){
@@ -1636,16 +1691,13 @@
1691 rid = svn_handle_symlinks(zPerm, &target);
1692 blob_reset(&deltaSrc);
1693 blob_reset(&target);
1694 }else if( rec.contentFlag ){
1695 rid = svn_handle_symlinks(zPerm, &rec.content);
1696 }
1697 if( rid==0 ){
1698 fossil_fatal("svn file has no content and no source: %s", zFile);
 
 
 
1699 }
1700 db_bind_text(&addFile, ":path", zFile);
1701 db_bind_int(&addFile, ":branch", branchId);
1702 db_bind_int(&addFile, ":rid", rid);
1703 db_bind_text(&addFile, ":perm", zPerm);
@@ -1793,11 +1845,10 @@
1845 char *zPassword;
1846 FILE *pIn;
1847 Stmt q;
1848 int forceFlag = find_option("force", "f", 0)!=0;
1849 int svnFlag = find_option("svn", 0, 0)!=0;
 
1850 int omitRebuild = find_option("no-rebuild",0,0)!=0;
1851 int omitVacuum = find_option("no-vacuum",0,0)!=0;
1852 const char *zDefaultUser = find_option("admin-user","A",1);
1853
1854 /* Options common to all input formats */
@@ -1843,10 +1894,11 @@
1894 }
1895 if( !(gimport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
1896 gimport.zTrunkName = fossil_strdup(db_main_branch());
1897 }
1898
1899 find_option("git", 0, 0);
1900 if( svnFlag ){
1901 /* Get --svn related options here, so verify_all_options() fails when
1902 * svn-only options are specified with --git
1903 */
1904 const char *zIgnTree;
@@ -1864,11 +1916,11 @@
1916 gsvn.zTrunk = find_option("trunk", 0, 1);
1917 gsvn.zBranches = find_option("branches", 0, 1);
1918 gsvn.zTags = find_option("tags", 0, 1);
1919 gsvn.revFlag = find_option("rev-tags", 0, 0)
1920 || (incrFlag && !find_option("no-rev-tags", 0, 0));
1921 }else{
1922 const char *zGitUser;
1923 markfile_in = find_option("import-marks", 0, 1);
1924 markfile_out = find_option("export-marks", 0, 1);
1925 if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
1926 ggit.zMasterName = "master";
@@ -1900,11 +1952,16 @@
1952 }else{
1953 pIn = stdin;
1954 fossil_binary_mode(pIn);
1955 }
1956 if( !incrFlag ){
1957 if( forceFlag ){
1958 file_delete(g.argv[2]);
1959 }else if( -1 != file_size(g.argv[2], ExtFILE) ){
1960 fossil_fatal("file already exists: %s (use --force to replace it)",
1961 g.argv[2]);
1962 }
1963 db_create_repository(g.argv[2]);
1964 }
1965 db_open_repository(g.argv[2]);
1966 db_open_config(0, 0);
1967 db_unprotect(PROTECT_ALL);
@@ -1954,10 +2011,14 @@
2011 gsvn.zBranches = mprintf("%s%s", zBase, gsvn.zBranches);
2012 gsvn.zTags = mprintf("%s%s", zBase, gsvn.zTags);
2013 gsvn.lenTrunk = strlen(gsvn.zTrunk);
2014 gsvn.lenBranches = strlen(gsvn.zBranches);
2015 gsvn.lenTags = strlen(gsvn.zTags);
2016 if( gsvn.lenTrunk==0 || gsvn.lenBranches==0 || gsvn.lenTags==0 ){
2017 fossil_fatal("--trunk, --branches and --tags may be empty only "
2018 "with a non-empty --base");
2019 }
2020 if( gsvn.zTrunk[gsvn.lenTrunk-1]!='/' ){
2021 gsvn.zTrunk = mprintf("%s/", gsvn.zTrunk);
2022 gsvn.lenTrunk++;
2023 }
2024 if( gsvn.zBranches[gsvn.lenBranches-1]!='/' ){
2025
+2
--- src/info.c
+++ src/info.c
@@ -3302,10 +3302,12 @@
33023302
int badRid = 0;
33033303
int rcvid;
33043304
int hashClr = PB("hclr");
33053305
const char *zDate;
33063306
3307
+ login_check_credentials();
3308
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
33073309
pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
33083310
if( pCluster==0 ){
33093311
artifact_page();
33103312
return;
33113313
}
33123314
--- src/info.c
+++ src/info.c
@@ -3302,10 +3302,12 @@
3302 int badRid = 0;
3303 int rcvid;
3304 int hashClr = PB("hclr");
3305 const char *zDate;
3306
 
 
3307 pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
3308 if( pCluster==0 ){
3309 artifact_page();
3310 return;
3311 }
3312
--- src/info.c
+++ src/info.c
@@ -3302,10 +3302,12 @@
3302 int badRid = 0;
3303 int rcvid;
3304 int hashClr = PB("hclr");
3305 const char *zDate;
3306
3307 login_check_credentials();
3308 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
3309 pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
3310 if( pCluster==0 ){
3311 artifact_page();
3312 return;
3313 }
3314
+9 -1
--- src/login.c
+++ src/login.c
@@ -122,12 +122,19 @@
122122
NORETURN void login_redirect_to_g(void){
123123
const char *zGoto = P("g");
124124
if( zGoto ){
125125
cgi_redirectf("%R/%s",zGoto);
126126
}else if( (zGoto = P("fossil-goto"))!=0 && zGoto[0]!=0 ){
127
+ int n = g.zBaseURL ? (int)strlen(g.zBaseURL) : 0;
127128
cgi_set_cookie("fossil-goto","",0,1);
128
- cgi_redirect(zGoto);
129
+ if( (fossil_strncmp(zGoto,"http:",5)!=0
130
+ && fossil_strncmp(zGoto,"https:",6)!=0)
131
+ || (n>0 && strncmp(zGoto, g.zBaseURL, n)==0
132
+ && (zGoto[n]==0 || zGoto[n]=='/')) ){
133
+ cgi_redirect(zGoto);
134
+ }
135
+ fossil_redirect_home();
129136
}else{
130137
fossil_redirect_home();
131138
}
132139
}
133140
@@ -1437,10 +1444,11 @@
14371444
char *zUser = 0;
14381445
int i, c;
14391446
for(i=0; (c = zHash[i])!=0; i++){
14401447
if( c=='/' ){
14411448
zHash[i++] = 0;
1449
+ if( zHash[i]==0 ) break;
14421450
if( zArg==0 ){
14431451
zArg = &zHash[i];
14441452
}else{
14451453
zUser = &zHash[i];
14461454
break;
14471455
--- src/login.c
+++ src/login.c
@@ -122,12 +122,19 @@
122 NORETURN void login_redirect_to_g(void){
123 const char *zGoto = P("g");
124 if( zGoto ){
125 cgi_redirectf("%R/%s",zGoto);
126 }else if( (zGoto = P("fossil-goto"))!=0 && zGoto[0]!=0 ){
 
127 cgi_set_cookie("fossil-goto","",0,1);
128 cgi_redirect(zGoto);
 
 
 
 
 
 
129 }else{
130 fossil_redirect_home();
131 }
132 }
133
@@ -1437,10 +1444,11 @@
1437 char *zUser = 0;
1438 int i, c;
1439 for(i=0; (c = zHash[i])!=0; i++){
1440 if( c=='/' ){
1441 zHash[i++] = 0;
 
1442 if( zArg==0 ){
1443 zArg = &zHash[i];
1444 }else{
1445 zUser = &zHash[i];
1446 break;
1447
--- src/login.c
+++ src/login.c
@@ -122,12 +122,19 @@
122 NORETURN void login_redirect_to_g(void){
123 const char *zGoto = P("g");
124 if( zGoto ){
125 cgi_redirectf("%R/%s",zGoto);
126 }else if( (zGoto = P("fossil-goto"))!=0 && zGoto[0]!=0 ){
127 int n = g.zBaseURL ? (int)strlen(g.zBaseURL) : 0;
128 cgi_set_cookie("fossil-goto","",0,1);
129 if( (fossil_strncmp(zGoto,"http:",5)!=0
130 && fossil_strncmp(zGoto,"https:",6)!=0)
131 || (n>0 && strncmp(zGoto, g.zBaseURL, n)==0
132 && (zGoto[n]==0 || zGoto[n]=='/')) ){
133 cgi_redirect(zGoto);
134 }
135 fossil_redirect_home();
136 }else{
137 fossil_redirect_home();
138 }
139 }
140
@@ -1437,10 +1444,11 @@
1444 char *zUser = 0;
1445 int i, c;
1446 for(i=0; (c = zHash[i])!=0; i++){
1447 if( c=='/' ){
1448 zHash[i++] = 0;
1449 if( zHash[i]==0 ) break;
1450 if( zArg==0 ){
1451 zArg = &zHash[i];
1452 }else{
1453 zUser = &zHash[i];
1454 break;
1455
+1 -1
--- src/main.c
+++ src/main.c
@@ -1455,11 +1455,11 @@
14551455
if( n==2 ) g.zTop = "";
14561456
if( g.zTop==g.zBaseURL ){
14571457
fossil_fatal("argument to --baseurl should be 'http://host/path'"
14581458
" or 'https://host/path'");
14591459
}
1460
- if( g.zTop[1]==0 ) g.zTop++;
1460
+ if( g.zTop[0] && g.zTop[1]==0 ) g.zTop++;
14611461
}else{
14621462
char *z;
14631463
zMode = PD("HTTPS","off");
14641464
zHost = PD("HTTP_HOST","");
14651465
z = fossil_strdup(zHost);
14661466
--- src/main.c
+++ src/main.c
@@ -1455,11 +1455,11 @@
1455 if( n==2 ) g.zTop = "";
1456 if( g.zTop==g.zBaseURL ){
1457 fossil_fatal("argument to --baseurl should be 'http://host/path'"
1458 " or 'https://host/path'");
1459 }
1460 if( g.zTop[1]==0 ) g.zTop++;
1461 }else{
1462 char *z;
1463 zMode = PD("HTTPS","off");
1464 zHost = PD("HTTP_HOST","");
1465 z = fossil_strdup(zHost);
1466
--- src/main.c
+++ src/main.c
@@ -1455,11 +1455,11 @@
1455 if( n==2 ) g.zTop = "";
1456 if( g.zTop==g.zBaseURL ){
1457 fossil_fatal("argument to --baseurl should be 'http://host/path'"
1458 " or 'https://host/path'");
1459 }
1460 if( g.zTop[0] && g.zTop[1]==0 ) g.zTop++;
1461 }else{
1462 char *z;
1463 zMode = PD("HTTPS","off");
1464 zHost = PD("HTTP_HOST","");
1465 z = fossil_strdup(zHost);
1466
+7 -5
--- src/manifest.c
+++ src/manifest.c
@@ -1209,10 +1209,11 @@
12091209
int manifest_is_well_formed(const char *zIn, int nIn){
12101210
int i;
12111211
int iRes;
12121212
Manifest *pManifest;
12131213
Blob copy, errmsg;
1214
+ if( nIn<1 || zIn[nIn-1]!='\n' ) return 0;
12141215
remove_pgp_signature(&zIn, &nIn);
12151216
12161217
/* Check to see that the file begins with a "card" */
12171218
if( nIn<3 ) return 0;
12181219
if( zIn[0]<'A' || zIn[0]>'M' || zIn[1]!=' ' ) return 0;
@@ -1219,11 +1220,12 @@
12191220
12201221
/* Check to see that the first card is followed by one more card */
12211222
for(i=2; i<nIn && zIn[i]!='\n'; i++){}
12221223
if( i>=nIn-3 ) return 0;
12231224
i++;
1224
- if( !fossil_isupper(zIn[i]) || zIn[i]<zIn[0] || zIn[i+1]!=' ' ) return 0;
1225
+ if( !fossil_isupper(zIn[i]) || zIn[i]<zIn[0] ) return 0;
1226
+ if( zIn[i+1]!=' ' && zIn[i+1]!='\n' ) return 0;
12251227
12261228
/* The checks above will eliminate most random inputs. If these
12271229
** quick checks pass, then we could be dealing with a well-formed
12281230
** control artifact. Make a copy, and run it through the official
12291231
** artifact parser. This is the slow path, but it is rarely taken.
@@ -1955,14 +1957,14 @@
19551957
if( mxParent<1 ) return;
19561958
zCopy = fossil_strdup(zValue);
19571959
azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
19581960
for(nParent=0, i=0; zCopy[i]; i++){
19591961
char *z = &zCopy[i];
1960
- azParent[nParent++] = z;
1961
- if( nParent>mxParent ) goto reparent_abort;
1962
- for(j=HNAME_MIN; z[j]>' '; j++){}
1962
+ if( nParent>=mxParent ) goto reparent_abort;
1963
+ for(j=0; z[j]>' '; j++){}
19631964
if( !hname_validate(z, j) ) goto reparent_abort;
1965
+ azParent[nParent++] = z;
19641966
if( z[j]==0 ) break;
19651967
z[j] = 0;
19661968
i += j;
19671969
}
19681970
p = manifest_get(rid, CFTYPE_MANIFEST, 0);
@@ -2633,11 +2635,11 @@
26332635
if( p->type==CFTYPE_ATTACHMENT ){
26342636
char *zComment = 0;
26352637
const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0;
26362638
char attachToType = 0;
26372639
db_multi_exec(
2638
- "INSERT INTO attachment(attachid, mtime, src, target,"
2640
+ "REPLACE INTO attachment(attachid, mtime, src, target,"
26392641
"filename, comment, user)"
26402642
"VALUES(%d,%.17g,%Q,%Q,%Q,%Q,%Q);",
26412643
rid, p->rDate, p->zAttachSrc, p->zAttachTarget, p->zAttachName,
26422644
(p->zComment ? p->zComment : ""), p->zUser
26432645
);
26442646
--- src/manifest.c
+++ src/manifest.c
@@ -1209,10 +1209,11 @@
1209 int manifest_is_well_formed(const char *zIn, int nIn){
1210 int i;
1211 int iRes;
1212 Manifest *pManifest;
1213 Blob copy, errmsg;
 
1214 remove_pgp_signature(&zIn, &nIn);
1215
1216 /* Check to see that the file begins with a "card" */
1217 if( nIn<3 ) return 0;
1218 if( zIn[0]<'A' || zIn[0]>'M' || zIn[1]!=' ' ) return 0;
@@ -1219,11 +1220,12 @@
1219
1220 /* Check to see that the first card is followed by one more card */
1221 for(i=2; i<nIn && zIn[i]!='\n'; i++){}
1222 if( i>=nIn-3 ) return 0;
1223 i++;
1224 if( !fossil_isupper(zIn[i]) || zIn[i]<zIn[0] || zIn[i+1]!=' ' ) return 0;
 
1225
1226 /* The checks above will eliminate most random inputs. If these
1227 ** quick checks pass, then we could be dealing with a well-formed
1228 ** control artifact. Make a copy, and run it through the official
1229 ** artifact parser. This is the slow path, but it is rarely taken.
@@ -1955,14 +1957,14 @@
1955 if( mxParent<1 ) return;
1956 zCopy = fossil_strdup(zValue);
1957 azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
1958 for(nParent=0, i=0; zCopy[i]; i++){
1959 char *z = &zCopy[i];
1960 azParent[nParent++] = z;
1961 if( nParent>mxParent ) goto reparent_abort;
1962 for(j=HNAME_MIN; z[j]>' '; j++){}
1963 if( !hname_validate(z, j) ) goto reparent_abort;
 
1964 if( z[j]==0 ) break;
1965 z[j] = 0;
1966 i += j;
1967 }
1968 p = manifest_get(rid, CFTYPE_MANIFEST, 0);
@@ -2633,11 +2635,11 @@
2633 if( p->type==CFTYPE_ATTACHMENT ){
2634 char *zComment = 0;
2635 const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0;
2636 char attachToType = 0;
2637 db_multi_exec(
2638 "INSERT INTO attachment(attachid, mtime, src, target,"
2639 "filename, comment, user)"
2640 "VALUES(%d,%.17g,%Q,%Q,%Q,%Q,%Q);",
2641 rid, p->rDate, p->zAttachSrc, p->zAttachTarget, p->zAttachName,
2642 (p->zComment ? p->zComment : ""), p->zUser
2643 );
2644
--- src/manifest.c
+++ src/manifest.c
@@ -1209,10 +1209,11 @@
1209 int manifest_is_well_formed(const char *zIn, int nIn){
1210 int i;
1211 int iRes;
1212 Manifest *pManifest;
1213 Blob copy, errmsg;
1214 if( nIn<1 || zIn[nIn-1]!='\n' ) return 0;
1215 remove_pgp_signature(&zIn, &nIn);
1216
1217 /* Check to see that the file begins with a "card" */
1218 if( nIn<3 ) return 0;
1219 if( zIn[0]<'A' || zIn[0]>'M' || zIn[1]!=' ' ) return 0;
@@ -1219,11 +1220,12 @@
1220
1221 /* Check to see that the first card is followed by one more card */
1222 for(i=2; i<nIn && zIn[i]!='\n'; i++){}
1223 if( i>=nIn-3 ) return 0;
1224 i++;
1225 if( !fossil_isupper(zIn[i]) || zIn[i]<zIn[0] ) return 0;
1226 if( zIn[i+1]!=' ' && zIn[i+1]!='\n' ) return 0;
1227
1228 /* The checks above will eliminate most random inputs. If these
1229 ** quick checks pass, then we could be dealing with a well-formed
1230 ** control artifact. Make a copy, and run it through the official
1231 ** artifact parser. This is the slow path, but it is rarely taken.
@@ -1955,14 +1957,14 @@
1957 if( mxParent<1 ) return;
1958 zCopy = fossil_strdup(zValue);
1959 azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
1960 for(nParent=0, i=0; zCopy[i]; i++){
1961 char *z = &zCopy[i];
1962 if( nParent>=mxParent ) goto reparent_abort;
1963 for(j=0; z[j]>' '; j++){}
 
1964 if( !hname_validate(z, j) ) goto reparent_abort;
1965 azParent[nParent++] = z;
1966 if( z[j]==0 ) break;
1967 z[j] = 0;
1968 i += j;
1969 }
1970 p = manifest_get(rid, CFTYPE_MANIFEST, 0);
@@ -2633,11 +2635,11 @@
2635 if( p->type==CFTYPE_ATTACHMENT ){
2636 char *zComment = 0;
2637 const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0;
2638 char attachToType = 0;
2639 db_multi_exec(
2640 "REPLACE INTO attachment(attachid, mtime, src, target,"
2641 "filename, comment, user)"
2642 "VALUES(%d,%.17g,%Q,%Q,%Q,%Q,%Q);",
2643 rid, p->rDate, p->zAttachSrc, p->zAttachTarget, p->zAttachName,
2644 (p->zComment ? p->zComment : ""), p->zUser
2645 );
2646
+59 -49
--- src/name.c
+++ src/name.c
@@ -78,11 +78,11 @@
7878
** the input string is a hash prefix and NULL is returned if it is. If the
7979
** bVerifyNotAHash flag is false, then the result is determined by syntax
8080
** of the input string only, without reference to the artifact table.
8181
*/
8282
char *fossil_expand_datetime(const char *zIn,int bVerifyNotAHash,int bRoundUp){
83
- static char zEDate[24];
83
+ static char zEDate[25];
8484
static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
8585
int n = (int)strlen(zIn);
8686
int i, j;
8787
int addZulu = 0;
8888
@@ -701,13 +701,14 @@
701701
702702
/* Undocumented: numeric tags get translated directly into the RID */
703703
if( strncmp(zTag, "rid:", 4)==0 ){
704704
zTag += 4;
705705
for(i=0; fossil_isdigit(zTag[i]); i++){}
706
- if( zTag[i]==0 ){
706
+ if( i>0 && zTag[i]==0 ){
707707
if( strcmp(zType,"*")==0 ){
708
- rid = atoi(zTag);
708
+ rid = db_int(0, "SELECT rid FROM blob WHERE rid=%s",
709
+ zTag /*safe-for-%s*/);
709710
}else{
710711
rid = db_int(0,
711712
"SELECT event.objid"
712713
" FROM event"
713714
" WHERE event.objid=%s"
@@ -1000,10 +1001,12 @@
10001001
Stmt q;
10011002
const char *zName = P("name");
10021003
const char *zSrc = PD("src","info");
10031004
char *z;
10041005
1006
+ login_check_credentials();
1007
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
10051008
if( zName==0 || zName[0]==0 || zSrc==0 || zSrc[0]==0 ){
10061009
fossil_redirect_home();
10071010
}
10081011
style_header("Ambiguous Artifact ID");
10091012
@ <p>The artifact hash prefix <b>%h(zName)</b> is ambiguous and might
@@ -1019,50 +1022,54 @@
10191022
@ %s(zUuid)</a> -
10201023
object_description(rid, 0, 0, 0);
10211024
@ </p></li>
10221025
}
10231026
db_finalize(&q);
1024
- db_prepare(&q,
1025
- " SELECT tkt_rid, tkt_uuid, title"
1026
- " FROM ticket, ticketchng"
1027
- " WHERE ticket.tkt_id = ticketchng.tkt_id"
1028
- " AND tkt_uuid GLOB '%q*'"
1029
- " GROUP BY tkt_uuid"
1030
- " ORDER BY tkt_ctime DESC", z);
1031
- while( db_step(&q)==SQLITE_ROW ){
1032
- int rid = db_column_int(&q, 0);
1033
- const char *zUuid = db_column_text(&q, 1);
1034
- const char *zTitle = db_column_text(&q, 2);
1035
- @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1036
- @ %s(zUuid)</a> -
1037
- @ <ul></ul>
1038
- @ Ticket
1039
- hyperlink_to_version(zUuid);
1040
- @ - %h(zTitle).
1041
- @ <ul><li>
1042
- object_description(rid, 0, 0, 0);
1043
- @ </li></ul>
1044
- @ </p></li>
1045
- }
1046
- db_finalize(&q);
1047
- db_prepare(&q,
1048
- "SELECT rid, uuid FROM"
1049
- " (SELECT tagxref.rid AS rid, substr(tagname, 7) AS uuid"
1050
- " FROM tagxref, tag WHERE tagxref.tagid = tag.tagid"
1051
- " AND tagname GLOB 'event-%q*') GROUP BY uuid", z);
1052
- while( db_step(&q)==SQLITE_ROW ){
1053
- int rid = db_column_int(&q, 0);
1054
- const char* zUuid = db_column_text(&q, 1);
1055
- @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1056
- @ %s(zUuid)</a> -
1057
- @ <ul><li>
1058
- object_description(rid, 0, 0, 0);
1059
- @ </li></ul>
1060
- @ </p></li>
1027
+ if( g.perm.RdTkt ){
1028
+ db_prepare(&q,
1029
+ " SELECT tkt_rid, tkt_uuid, title"
1030
+ " FROM ticket, ticketchng"
1031
+ " WHERE ticket.tkt_id = ticketchng.tkt_id"
1032
+ " AND tkt_uuid GLOB '%q*'"
1033
+ " GROUP BY tkt_uuid"
1034
+ " ORDER BY tkt_ctime DESC", z);
1035
+ while( db_step(&q)==SQLITE_ROW ){
1036
+ int rid = db_column_int(&q, 0);
1037
+ const char *zUuid = db_column_text(&q, 1);
1038
+ const char *zTitle = db_column_text(&q, 2);
1039
+ @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1040
+ @ %s(zUuid)</a> -
1041
+ @ <ul></ul>
1042
+ @ Ticket
1043
+ hyperlink_to_version(zUuid);
1044
+ @ - %h(zTitle).
1045
+ @ <ul><li>
1046
+ object_description(rid, 0, 0, 0);
1047
+ @ </li></ul>
1048
+ @ </p></li>
1049
+ }
1050
+ db_finalize(&q);
1051
+ }
1052
+ if( g.perm.RdWiki ){
1053
+ db_prepare(&q,
1054
+ "SELECT rid, uuid FROM"
1055
+ " (SELECT tagxref.rid AS rid, substr(tagname, 7) AS uuid"
1056
+ " FROM tagxref, tag WHERE tagxref.tagid = tag.tagid"
1057
+ " AND tagname GLOB 'event-%q*') GROUP BY uuid", z);
1058
+ while( db_step(&q)==SQLITE_ROW ){
1059
+ int rid = db_column_int(&q, 0);
1060
+ const char* zUuid = db_column_text(&q, 1);
1061
+ @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1062
+ @ %s(zUuid)</a> -
1063
+ @ <ul><li>
1064
+ object_description(rid, 0, 0, 0);
1065
+ @ </li></ul>
1066
+ @ </p></li>
1067
+ }
1068
+ db_finalize(&q);
10611069
}
10621070
@ </ol>
1063
- db_finalize(&q);
10641071
style_finish_page();
10651072
}
10661073
10671074
/*
10681075
** Convert the name in CGI parameter zParamName into a rid and return that
@@ -1239,11 +1246,11 @@
12391246
);
12401247
cnt = 0;
12411248
while( db_step(&q)==SQLITE_ROW ){
12421249
const char *zTag = (const char*)db_column_text(&q,0);
12431250
if( pOut ){
1244
- const char *zSep = cnt==0 ? ",tags:[" : ",";
1251
+ const char *zSep = cnt==0 ? ",\"tags\":[" : ",";
12451252
sqlite3_str_appendf(pOut, "%s%J", zSep, zTag);
12461253
}else{
12471254
const char *zPrefix = cnt ? ", " : "tags: ";
12481255
fossil_print("%s%s", zPrefix, db_column_text(&q,0));
12491256
}
@@ -1494,14 +1501,16 @@
14941501
" ORDER BY mtime LIMIT 1)"
14951502
" FROM tag WHERE tagname GLOB 'tkt-%q*'",
14961503
zC
14971504
);
14981505
while( db_step(&q)==SQLITE_ROW ){
1499
- if( pOut ){
1500
- sqlite3_str_append(pOut, ",", 1);
1501
- }else{
1502
- fossil_print("%12s---- meaning #%d ----\n", " ", cnt);
1506
+ if( cnt++ ){
1507
+ if( pOut ){
1508
+ sqlite3_str_append(pOut, ",", 1);
1509
+ }else{
1510
+ fossil_print("%12s---- meaning #%d ----\n", " ", cnt);
1511
+ }
15031512
}
15041513
whatis_rid(db_column_int(&q, 0), mFlags, pOut);
15051514
}
15061515
db_finalize(&q);
15071516
}
@@ -2036,10 +2045,11 @@
20362045
char *zSha3Bg;
20372046
20382047
login_check_credentials();
20392048
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
20402049
cgi_check_for_malice();
2050
+ if( n<1 ) n = 1;
20412051
style_header("List Of Artifacts");
20422052
style_submenu_element("250 Largest", "bigbloblist");
20432053
if( bRecent==0 || n!=250 ){
20442054
style_submenu_element("Recent","bloblist?n=250&recent");
20452055
}
@@ -2089,14 +2099,14 @@
20892099
}else if( bUnclst ){
20902100
@ <h2>Unclustered Artifacts</h2>
20912101
zRange = mprintf("IN unclustered");
20922102
}else if( bRecent ){
20932103
@ <h2>%d(n) Most Recent Artifacts</h2>
2094
- zRange = mprintf(">=(SELECT rid FROM blob"
2095
- " ORDER BY rid DESC LIMIT 1 OFFSET %d)",n);
2104
+ zRange = mprintf("IN (SELECT rid FROM blob"
2105
+ " ORDER BY rid DESC LIMIT %d)",n);
20962106
}else{
2097
- zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
2107
+ zRange = mprintf("BETWEEN %d AND %lld", s, (i64)s+n-1);
20982108
}
20992109
describe_artifacts(zRange);
21002110
fossil_free(zRange);
21012111
db_prepare(&q,
21022112
/* 0 1 2 3 4 5 6 */
21032113
--- src/name.c
+++ src/name.c
@@ -78,11 +78,11 @@
78 ** the input string is a hash prefix and NULL is returned if it is. If the
79 ** bVerifyNotAHash flag is false, then the result is determined by syntax
80 ** of the input string only, without reference to the artifact table.
81 */
82 char *fossil_expand_datetime(const char *zIn,int bVerifyNotAHash,int bRoundUp){
83 static char zEDate[24];
84 static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
85 int n = (int)strlen(zIn);
86 int i, j;
87 int addZulu = 0;
88
@@ -701,13 +701,14 @@
701
702 /* Undocumented: numeric tags get translated directly into the RID */
703 if( strncmp(zTag, "rid:", 4)==0 ){
704 zTag += 4;
705 for(i=0; fossil_isdigit(zTag[i]); i++){}
706 if( zTag[i]==0 ){
707 if( strcmp(zType,"*")==0 ){
708 rid = atoi(zTag);
 
709 }else{
710 rid = db_int(0,
711 "SELECT event.objid"
712 " FROM event"
713 " WHERE event.objid=%s"
@@ -1000,10 +1001,12 @@
1000 Stmt q;
1001 const char *zName = P("name");
1002 const char *zSrc = PD("src","info");
1003 char *z;
1004
 
 
1005 if( zName==0 || zName[0]==0 || zSrc==0 || zSrc[0]==0 ){
1006 fossil_redirect_home();
1007 }
1008 style_header("Ambiguous Artifact ID");
1009 @ <p>The artifact hash prefix <b>%h(zName)</b> is ambiguous and might
@@ -1019,50 +1022,54 @@
1019 @ %s(zUuid)</a> -
1020 object_description(rid, 0, 0, 0);
1021 @ </p></li>
1022 }
1023 db_finalize(&q);
1024 db_prepare(&q,
1025 " SELECT tkt_rid, tkt_uuid, title"
1026 " FROM ticket, ticketchng"
1027 " WHERE ticket.tkt_id = ticketchng.tkt_id"
1028 " AND tkt_uuid GLOB '%q*'"
1029 " GROUP BY tkt_uuid"
1030 " ORDER BY tkt_ctime DESC", z);
1031 while( db_step(&q)==SQLITE_ROW ){
1032 int rid = db_column_int(&q, 0);
1033 const char *zUuid = db_column_text(&q, 1);
1034 const char *zTitle = db_column_text(&q, 2);
1035 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1036 @ %s(zUuid)</a> -
1037 @ <ul></ul>
1038 @ Ticket
1039 hyperlink_to_version(zUuid);
1040 @ - %h(zTitle).
1041 @ <ul><li>
1042 object_description(rid, 0, 0, 0);
1043 @ </li></ul>
1044 @ </p></li>
1045 }
1046 db_finalize(&q);
1047 db_prepare(&q,
1048 "SELECT rid, uuid FROM"
1049 " (SELECT tagxref.rid AS rid, substr(tagname, 7) AS uuid"
1050 " FROM tagxref, tag WHERE tagxref.tagid = tag.tagid"
1051 " AND tagname GLOB 'event-%q*') GROUP BY uuid", z);
1052 while( db_step(&q)==SQLITE_ROW ){
1053 int rid = db_column_int(&q, 0);
1054 const char* zUuid = db_column_text(&q, 1);
1055 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1056 @ %s(zUuid)</a> -
1057 @ <ul><li>
1058 object_description(rid, 0, 0, 0);
1059 @ </li></ul>
1060 @ </p></li>
 
 
 
 
 
1061 }
1062 @ </ol>
1063 db_finalize(&q);
1064 style_finish_page();
1065 }
1066
1067 /*
1068 ** Convert the name in CGI parameter zParamName into a rid and return that
@@ -1239,11 +1246,11 @@
1239 );
1240 cnt = 0;
1241 while( db_step(&q)==SQLITE_ROW ){
1242 const char *zTag = (const char*)db_column_text(&q,0);
1243 if( pOut ){
1244 const char *zSep = cnt==0 ? ",tags:[" : ",";
1245 sqlite3_str_appendf(pOut, "%s%J", zSep, zTag);
1246 }else{
1247 const char *zPrefix = cnt ? ", " : "tags: ";
1248 fossil_print("%s%s", zPrefix, db_column_text(&q,0));
1249 }
@@ -1494,14 +1501,16 @@
1494 " ORDER BY mtime LIMIT 1)"
1495 " FROM tag WHERE tagname GLOB 'tkt-%q*'",
1496 zC
1497 );
1498 while( db_step(&q)==SQLITE_ROW ){
1499 if( pOut ){
1500 sqlite3_str_append(pOut, ",", 1);
1501 }else{
1502 fossil_print("%12s---- meaning #%d ----\n", " ", cnt);
 
 
1503 }
1504 whatis_rid(db_column_int(&q, 0), mFlags, pOut);
1505 }
1506 db_finalize(&q);
1507 }
@@ -2036,10 +2045,11 @@
2036 char *zSha3Bg;
2037
2038 login_check_credentials();
2039 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2040 cgi_check_for_malice();
 
2041 style_header("List Of Artifacts");
2042 style_submenu_element("250 Largest", "bigbloblist");
2043 if( bRecent==0 || n!=250 ){
2044 style_submenu_element("Recent","bloblist?n=250&recent");
2045 }
@@ -2089,14 +2099,14 @@
2089 }else if( bUnclst ){
2090 @ <h2>Unclustered Artifacts</h2>
2091 zRange = mprintf("IN unclustered");
2092 }else if( bRecent ){
2093 @ <h2>%d(n) Most Recent Artifacts</h2>
2094 zRange = mprintf(">=(SELECT rid FROM blob"
2095 " ORDER BY rid DESC LIMIT 1 OFFSET %d)",n);
2096 }else{
2097 zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
2098 }
2099 describe_artifacts(zRange);
2100 fossil_free(zRange);
2101 db_prepare(&q,
2102 /* 0 1 2 3 4 5 6 */
2103
--- src/name.c
+++ src/name.c
@@ -78,11 +78,11 @@
78 ** the input string is a hash prefix and NULL is returned if it is. If the
79 ** bVerifyNotAHash flag is false, then the result is determined by syntax
80 ** of the input string only, without reference to the artifact table.
81 */
82 char *fossil_expand_datetime(const char *zIn,int bVerifyNotAHash,int bRoundUp){
83 static char zEDate[25];
84 static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
85 int n = (int)strlen(zIn);
86 int i, j;
87 int addZulu = 0;
88
@@ -701,13 +701,14 @@
701
702 /* Undocumented: numeric tags get translated directly into the RID */
703 if( strncmp(zTag, "rid:", 4)==0 ){
704 zTag += 4;
705 for(i=0; fossil_isdigit(zTag[i]); i++){}
706 if( i>0 && zTag[i]==0 ){
707 if( strcmp(zType,"*")==0 ){
708 rid = db_int(0, "SELECT rid FROM blob WHERE rid=%s",
709 zTag /*safe-for-%s*/);
710 }else{
711 rid = db_int(0,
712 "SELECT event.objid"
713 " FROM event"
714 " WHERE event.objid=%s"
@@ -1000,10 +1001,12 @@
1001 Stmt q;
1002 const char *zName = P("name");
1003 const char *zSrc = PD("src","info");
1004 char *z;
1005
1006 login_check_credentials();
1007 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1008 if( zName==0 || zName[0]==0 || zSrc==0 || zSrc[0]==0 ){
1009 fossil_redirect_home();
1010 }
1011 style_header("Ambiguous Artifact ID");
1012 @ <p>The artifact hash prefix <b>%h(zName)</b> is ambiguous and might
@@ -1019,50 +1022,54 @@
1022 @ %s(zUuid)</a> -
1023 object_description(rid, 0, 0, 0);
1024 @ </p></li>
1025 }
1026 db_finalize(&q);
1027 if( g.perm.RdTkt ){
1028 db_prepare(&q,
1029 " SELECT tkt_rid, tkt_uuid, title"
1030 " FROM ticket, ticketchng"
1031 " WHERE ticket.tkt_id = ticketchng.tkt_id"
1032 " AND tkt_uuid GLOB '%q*'"
1033 " GROUP BY tkt_uuid"
1034 " ORDER BY tkt_ctime DESC", z);
1035 while( db_step(&q)==SQLITE_ROW ){
1036 int rid = db_column_int(&q, 0);
1037 const char *zUuid = db_column_text(&q, 1);
1038 const char *zTitle = db_column_text(&q, 2);
1039 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1040 @ %s(zUuid)</a> -
1041 @ <ul></ul>
1042 @ Ticket
1043 hyperlink_to_version(zUuid);
1044 @ - %h(zTitle).
1045 @ <ul><li>
1046 object_description(rid, 0, 0, 0);
1047 @ </li></ul>
1048 @ </p></li>
1049 }
1050 db_finalize(&q);
1051 }
1052 if( g.perm.RdWiki ){
1053 db_prepare(&q,
1054 "SELECT rid, uuid FROM"
1055 " (SELECT tagxref.rid AS rid, substr(tagname, 7) AS uuid"
1056 " FROM tagxref, tag WHERE tagxref.tagid = tag.tagid"
1057 " AND tagname GLOB 'event-%q*') GROUP BY uuid", z);
1058 while( db_step(&q)==SQLITE_ROW ){
1059 int rid = db_column_int(&q, 0);
1060 const char* zUuid = db_column_text(&q, 1);
1061 @ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
1062 @ %s(zUuid)</a> -
1063 @ <ul><li>
1064 object_description(rid, 0, 0, 0);
1065 @ </li></ul>
1066 @ </p></li>
1067 }
1068 db_finalize(&q);
1069 }
1070 @ </ol>
 
1071 style_finish_page();
1072 }
1073
1074 /*
1075 ** Convert the name in CGI parameter zParamName into a rid and return that
@@ -1239,11 +1246,11 @@
1246 );
1247 cnt = 0;
1248 while( db_step(&q)==SQLITE_ROW ){
1249 const char *zTag = (const char*)db_column_text(&q,0);
1250 if( pOut ){
1251 const char *zSep = cnt==0 ? ",\"tags\":[" : ",";
1252 sqlite3_str_appendf(pOut, "%s%J", zSep, zTag);
1253 }else{
1254 const char *zPrefix = cnt ? ", " : "tags: ";
1255 fossil_print("%s%s", zPrefix, db_column_text(&q,0));
1256 }
@@ -1494,14 +1501,16 @@
1501 " ORDER BY mtime LIMIT 1)"
1502 " FROM tag WHERE tagname GLOB 'tkt-%q*'",
1503 zC
1504 );
1505 while( db_step(&q)==SQLITE_ROW ){
1506 if( cnt++ ){
1507 if( pOut ){
1508 sqlite3_str_append(pOut, ",", 1);
1509 }else{
1510 fossil_print("%12s---- meaning #%d ----\n", " ", cnt);
1511 }
1512 }
1513 whatis_rid(db_column_int(&q, 0), mFlags, pOut);
1514 }
1515 db_finalize(&q);
1516 }
@@ -2036,10 +2045,11 @@
2045 char *zSha3Bg;
2046
2047 login_check_credentials();
2048 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2049 cgi_check_for_malice();
2050 if( n<1 ) n = 1;
2051 style_header("List Of Artifacts");
2052 style_submenu_element("250 Largest", "bigbloblist");
2053 if( bRecent==0 || n!=250 ){
2054 style_submenu_element("Recent","bloblist?n=250&recent");
2055 }
@@ -2089,14 +2099,14 @@
2099 }else if( bUnclst ){
2100 @ <h2>Unclustered Artifacts</h2>
2101 zRange = mprintf("IN unclustered");
2102 }else if( bRecent ){
2103 @ <h2>%d(n) Most Recent Artifacts</h2>
2104 zRange = mprintf("IN (SELECT rid FROM blob"
2105 " ORDER BY rid DESC LIMIT %d)",n);
2106 }else{
2107 zRange = mprintf("BETWEEN %d AND %lld", s, (i64)s+n-1);
2108 }
2109 describe_artifacts(zRange);
2110 fossil_free(zRange);
2111 db_prepare(&q,
2112 /* 0 1 2 3 4 5 6 */
2113
+1 -1
--- src/patch.c
+++ src/patch.c
@@ -1025,11 +1025,11 @@
10251025
}
10261026
zCmd = g.argv[2];
10271027
n = strlen(zCmd);
10281028
if( strncmp(zCmd, "alias", n)==0 ){
10291029
const char * zArg = g.argc>3 ? g.argv[3] : 0;
1030
- db_must_be_within_tree();
1030
+ db_find_and_open_repository(0, 0);
10311031
if( 0==zArg ){
10321032
goto usage_patch_alias;
10331033
}else if( 0==strcmp("ls",zArg) || 0==strcmp("list",zArg) ){
10341034
/* alias ls|list */
10351035
Stmt q;
10361036
--- src/patch.c
+++ src/patch.c
@@ -1025,11 +1025,11 @@
1025 }
1026 zCmd = g.argv[2];
1027 n = strlen(zCmd);
1028 if( strncmp(zCmd, "alias", n)==0 ){
1029 const char * zArg = g.argc>3 ? g.argv[3] : 0;
1030 db_must_be_within_tree();
1031 if( 0==zArg ){
1032 goto usage_patch_alias;
1033 }else if( 0==strcmp("ls",zArg) || 0==strcmp("list",zArg) ){
1034 /* alias ls|list */
1035 Stmt q;
1036
--- src/patch.c
+++ src/patch.c
@@ -1025,11 +1025,11 @@
1025 }
1026 zCmd = g.argv[2];
1027 n = strlen(zCmd);
1028 if( strncmp(zCmd, "alias", n)==0 ){
1029 const char * zArg = g.argc>3 ? g.argv[3] : 0;
1030 db_find_and_open_repository(0, 0);
1031 if( 0==zArg ){
1032 goto usage_patch_alias;
1033 }else if( 0==strcmp("ls",zArg) || 0==strcmp("list",zArg) ){
1034 /* alias ls|list */
1035 Stmt q;
1036
+1 -1
--- src/patch.c
+++ src/patch.c
@@ -1025,11 +1025,11 @@
10251025
}
10261026
zCmd = g.argv[2];
10271027
n = strlen(zCmd);
10281028
if( strncmp(zCmd, "alias", n)==0 ){
10291029
const char * zArg = g.argc>3 ? g.argv[3] : 0;
1030
- db_must_be_within_tree();
1030
+ db_find_and_open_repository(0, 0);
10311031
if( 0==zArg ){
10321032
goto usage_patch_alias;
10331033
}else if( 0==strcmp("ls",zArg) || 0==strcmp("list",zArg) ){
10341034
/* alias ls|list */
10351035
Stmt q;
10361036
--- src/patch.c
+++ src/patch.c
@@ -1025,11 +1025,11 @@
1025 }
1026 zCmd = g.argv[2];
1027 n = strlen(zCmd);
1028 if( strncmp(zCmd, "alias", n)==0 ){
1029 const char * zArg = g.argc>3 ? g.argv[3] : 0;
1030 db_must_be_within_tree();
1031 if( 0==zArg ){
1032 goto usage_patch_alias;
1033 }else if( 0==strcmp("ls",zArg) || 0==strcmp("list",zArg) ){
1034 /* alias ls|list */
1035 Stmt q;
1036
--- src/patch.c
+++ src/patch.c
@@ -1025,11 +1025,11 @@
1025 }
1026 zCmd = g.argv[2];
1027 n = strlen(zCmd);
1028 if( strncmp(zCmd, "alias", n)==0 ){
1029 const char * zArg = g.argc>3 ? g.argv[3] : 0;
1030 db_find_and_open_repository(0, 0);
1031 if( 0==zArg ){
1032 goto usage_patch_alias;
1033 }else if( 0==strcmp("ls",zArg) || 0==strcmp("list",zArg) ){
1034 /* alias ls|list */
1035 Stmt q;
1036
+4 -1
--- src/purge.c
+++ src/purge.c
@@ -356,11 +356,14 @@
356356
" WHERE piid=%d", piid);
357357
if( db_step(&q)!=SQLITE_ROW ){
358358
db_finalize(&q);
359359
fossil_fatal("missing purge-item %d", piid);
360360
}
361
- if( bag_find(&busy, piid) ) return 1;
361
+ if( bag_find(&busy, piid) ){
362
+ db_finalize(&q);
363
+ fossil_fatal("purge-item %d is part of a delta cycle", piid);
364
+ }
362365
srcid = db_column_int(&q, 1);
363366
blob_zero(pOut);
364367
blob_zero(&x);
365368
db_column_blob(&q, 2, &x);
366369
blob_uncompress(&x, pOut);
367370
--- src/purge.c
+++ src/purge.c
@@ -356,11 +356,14 @@
356 " WHERE piid=%d", piid);
357 if( db_step(&q)!=SQLITE_ROW ){
358 db_finalize(&q);
359 fossil_fatal("missing purge-item %d", piid);
360 }
361 if( bag_find(&busy, piid) ) return 1;
 
 
 
362 srcid = db_column_int(&q, 1);
363 blob_zero(pOut);
364 blob_zero(&x);
365 db_column_blob(&q, 2, &x);
366 blob_uncompress(&x, pOut);
367
--- src/purge.c
+++ src/purge.c
@@ -356,11 +356,14 @@
356 " WHERE piid=%d", piid);
357 if( db_step(&q)!=SQLITE_ROW ){
358 db_finalize(&q);
359 fossil_fatal("missing purge-item %d", piid);
360 }
361 if( bag_find(&busy, piid) ){
362 db_finalize(&q);
363 fossil_fatal("purge-item %d is part of a delta cycle", piid);
364 }
365 srcid = db_column_int(&q, 1);
366 blob_zero(pOut);
367 blob_zero(&x);
368 db_column_blob(&q, 2, &x);
369 blob_uncompress(&x, pOut);
370
+3 -2
--- src/rebuild.c
+++ src/rebuild.c
@@ -747,12 +747,12 @@
747747
/* We should be done with options.. */
748748
verify_all_options();
749749
750750
db_begin_transaction();
751751
db_unprotect(PROTECT_ALL);
752
+ if( !compressOnlyFlag || runReindex ) search_drop_index();
752753
if( !compressOnlyFlag ){
753
- search_drop_index();
754754
ttyOutput = 1;
755755
errCnt = rebuild_db(1, doClustering);
756756
reconstruct_private_table();
757757
}
758758
db_multi_exec(
@@ -1408,10 +1408,11 @@
14081408
/* Newer method: Import the list of private artifacts to the PRIVATE table. */
14091409
if( fKeepPrivate ){
14101410
char *zFnDotPrivate = mprintf("%s/.private", g.argv[3]);
14111411
private_import(zFnDotPrivate);
14121412
free(zFnDotPrivate);
1413
+ fix_private_blob_dependencies(0);
14131414
}
14141415
14151416
/* Skip the verify_before_commit() step on a reconstruct. Most artifacts
14161417
** will have been changed and verification therefore takes a really, really
14171418
** long time.
@@ -1478,11 +1479,11 @@
14781479
if( g.argc!=3 ){
14791480
usage ("?OPTIONS? DESTINATION");
14801481
}
14811482
/* get and check argument destination directory */
14821483
zDestDir = g.argv[g.argc-1];
1483
- if( !*zDestDir || !file_isdir(zDestDir, ExtFILE)) {
1484
+ if( !*zDestDir || file_isdir(zDestDir, ExtFILE)!=1) {
14841485
fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir);
14851486
}
14861487
#ifndef _WIN32
14871488
if( file_access(zDestDir, W_OK) ){
14881489
fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
14891490
--- src/rebuild.c
+++ src/rebuild.c
@@ -747,12 +747,12 @@
747 /* We should be done with options.. */
748 verify_all_options();
749
750 db_begin_transaction();
751 db_unprotect(PROTECT_ALL);
 
752 if( !compressOnlyFlag ){
753 search_drop_index();
754 ttyOutput = 1;
755 errCnt = rebuild_db(1, doClustering);
756 reconstruct_private_table();
757 }
758 db_multi_exec(
@@ -1408,10 +1408,11 @@
1408 /* Newer method: Import the list of private artifacts to the PRIVATE table. */
1409 if( fKeepPrivate ){
1410 char *zFnDotPrivate = mprintf("%s/.private", g.argv[3]);
1411 private_import(zFnDotPrivate);
1412 free(zFnDotPrivate);
 
1413 }
1414
1415 /* Skip the verify_before_commit() step on a reconstruct. Most artifacts
1416 ** will have been changed and verification therefore takes a really, really
1417 ** long time.
@@ -1478,11 +1479,11 @@
1478 if( g.argc!=3 ){
1479 usage ("?OPTIONS? DESTINATION");
1480 }
1481 /* get and check argument destination directory */
1482 zDestDir = g.argv[g.argc-1];
1483 if( !*zDestDir || !file_isdir(zDestDir, ExtFILE)) {
1484 fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir);
1485 }
1486 #ifndef _WIN32
1487 if( file_access(zDestDir, W_OK) ){
1488 fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
1489
--- src/rebuild.c
+++ src/rebuild.c
@@ -747,12 +747,12 @@
747 /* We should be done with options.. */
748 verify_all_options();
749
750 db_begin_transaction();
751 db_unprotect(PROTECT_ALL);
752 if( !compressOnlyFlag || runReindex ) search_drop_index();
753 if( !compressOnlyFlag ){
 
754 ttyOutput = 1;
755 errCnt = rebuild_db(1, doClustering);
756 reconstruct_private_table();
757 }
758 db_multi_exec(
@@ -1408,10 +1408,11 @@
1408 /* Newer method: Import the list of private artifacts to the PRIVATE table. */
1409 if( fKeepPrivate ){
1410 char *zFnDotPrivate = mprintf("%s/.private", g.argv[3]);
1411 private_import(zFnDotPrivate);
1412 free(zFnDotPrivate);
1413 fix_private_blob_dependencies(0);
1414 }
1415
1416 /* Skip the verify_before_commit() step on a reconstruct. Most artifacts
1417 ** will have been changed and verification therefore takes a really, really
1418 ** long time.
@@ -1478,11 +1479,11 @@
1479 if( g.argc!=3 ){
1480 usage ("?OPTIONS? DESTINATION");
1481 }
1482 /* get and check argument destination directory */
1483 zDestDir = g.argv[g.argc-1];
1484 if( !*zDestDir || file_isdir(zDestDir, ExtFILE)!=1) {
1485 fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir);
1486 }
1487 #ifndef _WIN32
1488 if( file_access(zDestDir, W_OK) ){
1489 fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
1490
--- src/robot.c
+++ src/robot.c
@@ -139,10 +139,16 @@
139139
/* Only do this computation once, then cache the results for future
140140
** use */
141141
if( robot.resultCache ){
142142
return robot.resultCache==MIGHT_BE_ROBOT;
143143
}
144
+
145
+ /* A command run from the command line has no web client. */
146
+ if( !g.isHTTP ){
147
+ robot.resultCache = KNOWN_NOT_ROBOT;
148
+ return 0;
149
+ }
144150
145151
/* Condition 1: Is there a valid login?
146152
*/
147153
if( g.userUid==0 ){
148154
login_check_credentials();
149155
--- src/robot.c
+++ src/robot.c
@@ -139,10 +139,16 @@
139 /* Only do this computation once, then cache the results for future
140 ** use */
141 if( robot.resultCache ){
142 return robot.resultCache==MIGHT_BE_ROBOT;
143 }
 
 
 
 
 
 
144
145 /* Condition 1: Is there a valid login?
146 */
147 if( g.userUid==0 ){
148 login_check_credentials();
149
--- src/robot.c
+++ src/robot.c
@@ -139,10 +139,16 @@
139 /* Only do this computation once, then cache the results for future
140 ** use */
141 if( robot.resultCache ){
142 return robot.resultCache==MIGHT_BE_ROBOT;
143 }
144
145 /* A command run from the command line has no web client. */
146 if( !g.isHTTP ){
147 robot.resultCache = KNOWN_NOT_ROBOT;
148 return 0;
149 }
150
151 /* Condition 1: Is there a valid login?
152 */
153 if( g.userUid==0 ){
154 login_check_credentials();
155
+1 -1
--- src/setupuser.c
+++ src/setupuser.c
@@ -518,11 +518,11 @@
518518
519519
/* If we have all the necessary information, write the new or
520520
** modified user record. After writing the user record, redirect
521521
** to the page that displays a list of users.
522522
*/
523
- if( !cgi_all("login","info","pw","apply") ){
523
+ if( !cgi_all("login","info","pw","apply",(char*)0) ){
524524
/* need all of the above properties to make a change. Since one or
525525
** more are missing, no-op */
526526
}else if( higherUser ){
527527
/* An Admin (a) user cannot edit a Superuser (s) */
528528
}else if( zDeleteVerify!=0 ){
529529
--- src/setupuser.c
+++ src/setupuser.c
@@ -518,11 +518,11 @@
518
519 /* If we have all the necessary information, write the new or
520 ** modified user record. After writing the user record, redirect
521 ** to the page that displays a list of users.
522 */
523 if( !cgi_all("login","info","pw","apply") ){
524 /* need all of the above properties to make a change. Since one or
525 ** more are missing, no-op */
526 }else if( higherUser ){
527 /* An Admin (a) user cannot edit a Superuser (s) */
528 }else if( zDeleteVerify!=0 ){
529
--- src/setupuser.c
+++ src/setupuser.c
@@ -518,11 +518,11 @@
518
519 /* If we have all the necessary information, write the new or
520 ** modified user record. After writing the user record, redirect
521 ** to the page that displays a list of users.
522 */
523 if( !cgi_all("login","info","pw","apply",(char*)0) ){
524 /* need all of the above properties to make a change. Since one or
525 ** more are missing, no-op */
526 }else if( higherUser ){
527 /* An Admin (a) user cannot edit a Superuser (s) */
528 }else if( zDeleteVerify!=0 ){
529
+39 -3
--- src/sha1hard.c
+++ src/sha1hard.c
@@ -441,15 +441,40 @@
441441
#define sha1_bswap32(x) \
442442
{x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);}
443443
444444
#define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
445445
446
-#if defined(BIGENDIAN)
447
- #define sha1_load(m, t) (m[t])
446
+/*
447
+** SHA1 message words are big-endian, so they must be byte-swapped on
448
+** little-endian hosts and loaded as-is on big-endian ones. Upstream
449
+** sha1dc has a large detection block for SHA1DC_BIGENDIAN. This is a
450
+** condensed form of it. SHA1DCInit() double-checks the result at
451
+** runtime so that a misdetection fails loudly instead of silently
452
+** producing wrong hashes.
453
+*/
454
+#if !defined(SHA1DC_BIGENDIAN) && !defined(SHA1DC_LITTLEENDIAN)
455
+# if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
456
+# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
457
+# define SHA1DC_BIGENDIAN 1
458
+# endif
459
+# elif defined(__BIG_ENDIAN__) || defined(__ARMEB__) \
460
+ || defined(__THUMBEB__) || defined(__AARCH64EB__) \
461
+ || defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) \
462
+ || defined(__ppc__) || defined(__powerpc__) || defined(_POWER) \
463
+ || defined(__sparc) || defined(__sparc__) || defined(__hppa__) \
464
+ || defined(__s390__) || defined(__m68k__)
465
+ /* __ppc__/__powerpc__ without __BYTE_ORDER__ means an old compiler,
466
+ ** which predates ppc64le, so big-endian is a safe assumption. */
467
+# define SHA1DC_BIGENDIAN 1
468
+# endif
469
+#endif
470
+
471
+#if defined(SHA1DC_BIGENDIAN)
472
+ #define sha1_load(m, t, temp) { temp = m[t]; }
448473
#else
449474
#define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
450
-#endif /*define(BIGENDIAN)*/
475
+#endif /*defined(SHA1DC_BIGENDIAN)*/
451476
452477
#define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
453478
454479
#define sha1_f1(b,c,d) ((d)^((b)&((c)^(d))))
455480
#define sha1_f2(b,c,d) ((b)^(c)^(d))
@@ -1324,10 +1349,21 @@
13241349
}
13251350
}
13261351
13271352
void SHA1DCInit(SHA1_CTX* ctx)
13281353
{
1354
+ static const union { unsigned char b[4]; uint32_t v; } e = {{0,1,2,3}};
1355
+#if defined(SHA1DC_BIGENDIAN)
1356
+ if( e.v!=0x00010203 )
1357
+#else
1358
+ if( e.v!=0x03020100 )
1359
+#endif
1360
+ {
1361
+ fprintf(stderr, "sha1hard.c: compile-time byte-order detection "
1362
+ "is wrong for this platform\n");
1363
+ abort();
1364
+ }
13291365
ctx->total = 0;
13301366
ctx->ihv[0] = 0x67452301;
13311367
ctx->ihv[1] = 0xEFCDAB89;
13321368
ctx->ihv[2] = 0x98BADCFE;
13331369
ctx->ihv[3] = 0x10325476;
13341370
--- src/sha1hard.c
+++ src/sha1hard.c
@@ -441,15 +441,40 @@
441 #define sha1_bswap32(x) \
442 {x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);}
443
444 #define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
445
446 #if defined(BIGENDIAN)
447 #define sha1_load(m, t) (m[t])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448 #else
449 #define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
450 #endif /*define(BIGENDIAN)*/
451
452 #define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
453
454 #define sha1_f1(b,c,d) ((d)^((b)&((c)^(d))))
455 #define sha1_f2(b,c,d) ((b)^(c)^(d))
@@ -1324,10 +1349,21 @@
1324 }
1325 }
1326
1327 void SHA1DCInit(SHA1_CTX* ctx)
1328 {
 
 
 
 
 
 
 
 
 
 
 
1329 ctx->total = 0;
1330 ctx->ihv[0] = 0x67452301;
1331 ctx->ihv[1] = 0xEFCDAB89;
1332 ctx->ihv[2] = 0x98BADCFE;
1333 ctx->ihv[3] = 0x10325476;
1334
--- src/sha1hard.c
+++ src/sha1hard.c
@@ -441,15 +441,40 @@
441 #define sha1_bswap32(x) \
442 {x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);}
443
444 #define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
445
446 /*
447 ** SHA1 message words are big-endian, so they must be byte-swapped on
448 ** little-endian hosts and loaded as-is on big-endian ones. Upstream
449 ** sha1dc has a large detection block for SHA1DC_BIGENDIAN. This is a
450 ** condensed form of it. SHA1DCInit() double-checks the result at
451 ** runtime so that a misdetection fails loudly instead of silently
452 ** producing wrong hashes.
453 */
454 #if !defined(SHA1DC_BIGENDIAN) && !defined(SHA1DC_LITTLEENDIAN)
455 # if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
456 # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
457 # define SHA1DC_BIGENDIAN 1
458 # endif
459 # elif defined(__BIG_ENDIAN__) || defined(__ARMEB__) \
460 || defined(__THUMBEB__) || defined(__AARCH64EB__) \
461 || defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) \
462 || defined(__ppc__) || defined(__powerpc__) || defined(_POWER) \
463 || defined(__sparc) || defined(__sparc__) || defined(__hppa__) \
464 || defined(__s390__) || defined(__m68k__)
465 /* __ppc__/__powerpc__ without __BYTE_ORDER__ means an old compiler,
466 ** which predates ppc64le, so big-endian is a safe assumption. */
467 # define SHA1DC_BIGENDIAN 1
468 # endif
469 #endif
470
471 #if defined(SHA1DC_BIGENDIAN)
472 #define sha1_load(m, t, temp) { temp = m[t]; }
473 #else
474 #define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
475 #endif /*defined(SHA1DC_BIGENDIAN)*/
476
477 #define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
478
479 #define sha1_f1(b,c,d) ((d)^((b)&((c)^(d))))
480 #define sha1_f2(b,c,d) ((b)^(c)^(d))
@@ -1324,10 +1349,21 @@
1349 }
1350 }
1351
1352 void SHA1DCInit(SHA1_CTX* ctx)
1353 {
1354 static const union { unsigned char b[4]; uint32_t v; } e = {{0,1,2,3}};
1355 #if defined(SHA1DC_BIGENDIAN)
1356 if( e.v!=0x00010203 )
1357 #else
1358 if( e.v!=0x03020100 )
1359 #endif
1360 {
1361 fprintf(stderr, "sha1hard.c: compile-time byte-order detection "
1362 "is wrong for this platform\n");
1363 abort();
1364 }
1365 ctx->total = 0;
1366 ctx->ihv[0] = 0x67452301;
1367 ctx->ihv[1] = 0xEFCDAB89;
1368 ctx->ihv[2] = 0x98BADCFE;
1369 ctx->ihv[3] = 0x10325476;
1370
+12 -4
--- src/stat.c
+++ src/stat.c
@@ -621,16 +621,24 @@
621621
UrlData x;
622622
if( cnt==0 ){
623623
@ <div class="section">Recently synced with these URLs</div>
624624
@ <table border='0' width='100%%'>
625625
}
626
- memset(&x, 0, sizeof(x));
627
- url_parse_local(zURL, URL_OMIT_USER, &x);
628
- @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a>
626
+ if( fossil_strnicmp(zURL, "http://", 7)==0
627
+ || fossil_strnicmp(zURL, "https://", 8)==0
628
+ ){
629
+ memset(&x, 0, sizeof(x));
630
+ url_parse_local(zURL, URL_OMIT_USER, &x);
631
+ @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a>
632
+ url_unparse(&x);
633
+ }else{
634
+ /* A gitpush address such as git@host:path is not a URL that
635
+ ** url_parse_local() understands. Show it as it is. */
636
+ @ <tr><td width='100%%'>%h(zURL)
637
+ }
629638
@ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
630639
cnt++;
631
- url_unparse(&x);
632640
}
633641
db_finalize(&q);
634642
if( cnt ){
635643
@ </table>
636644
total += cnt;
637645
--- src/stat.c
+++ src/stat.c
@@ -621,16 +621,24 @@
621 UrlData x;
622 if( cnt==0 ){
623 @ <div class="section">Recently synced with these URLs</div>
624 @ <table border='0' width='100%%'>
625 }
626 memset(&x, 0, sizeof(x));
627 url_parse_local(zURL, URL_OMIT_USER, &x);
628 @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a>
 
 
 
 
 
 
 
 
 
629 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
630 cnt++;
631 url_unparse(&x);
632 }
633 db_finalize(&q);
634 if( cnt ){
635 @ </table>
636 total += cnt;
637
--- src/stat.c
+++ src/stat.c
@@ -621,16 +621,24 @@
621 UrlData x;
622 if( cnt==0 ){
623 @ <div class="section">Recently synced with these URLs</div>
624 @ <table border='0' width='100%%'>
625 }
626 if( fossil_strnicmp(zURL, "http://", 7)==0
627 || fossil_strnicmp(zURL, "https://", 8)==0
628 ){
629 memset(&x, 0, sizeof(x));
630 url_parse_local(zURL, URL_OMIT_USER, &x);
631 @ <tr><td width='100%%'><a href='%h(x.canonical)'>%h(x.canonical)</a>
632 url_unparse(&x);
633 }else{
634 /* A gitpush address such as git@host:path is not a URL that
635 ** url_parse_local() understands. Show it as it is. */
636 @ <tr><td width='100%%'>%h(zURL)
637 }
638 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
639 cnt++;
 
640 }
641 db_finalize(&q);
642 if( cnt ){
643 @ </table>
644 total += cnt;
645
+2
--- src/sync.c
+++ src/sync.c
@@ -876,15 +876,17 @@
876876
|| sqlite3_strlike("https://%",zArg,0)==0
877877
|| sqlite3_strlike("ssh:%",zArg,0)==0
878878
|| sqlite3_strlike("file:%",zArg,0)==0
879879
|| db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
880880
){
881
+ db_begin_transaction();
881882
db_unset("last-sync-url", 0);
882883
db_unset("last-sync-pw", 0);
883884
url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|
884885
URL_USE_CONFIG|URL_ASK_REMEMBER_PW);
885886
url_remember();
887
+ db_commit_transaction();
886888
return;
887889
}
888890
fossil_fatal("unknown command \"%s\" - should be a URL or one of: "
889891
"add delete hyperlink list off scrub", zArg);
890892
}
891893
--- src/sync.c
+++ src/sync.c
@@ -876,15 +876,17 @@
876 || sqlite3_strlike("https://%",zArg,0)==0
877 || sqlite3_strlike("ssh:%",zArg,0)==0
878 || sqlite3_strlike("file:%",zArg,0)==0
879 || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
880 ){
 
881 db_unset("last-sync-url", 0);
882 db_unset("last-sync-pw", 0);
883 url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|
884 URL_USE_CONFIG|URL_ASK_REMEMBER_PW);
885 url_remember();
 
886 return;
887 }
888 fossil_fatal("unknown command \"%s\" - should be a URL or one of: "
889 "add delete hyperlink list off scrub", zArg);
890 }
891
--- src/sync.c
+++ src/sync.c
@@ -876,15 +876,17 @@
876 || sqlite3_strlike("https://%",zArg,0)==0
877 || sqlite3_strlike("ssh:%",zArg,0)==0
878 || sqlite3_strlike("file:%",zArg,0)==0
879 || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
880 ){
881 db_begin_transaction();
882 db_unset("last-sync-url", 0);
883 db_unset("last-sync-pw", 0);
884 url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|
885 URL_USE_CONFIG|URL_ASK_REMEMBER_PW);
886 url_remember();
887 db_commit_transaction();
888 return;
889 }
890 fossil_fatal("unknown command \"%s\" - should be a URL or one of: "
891 "add delete hyperlink list off scrub", zArg);
892 }
893
+52 -21
--- src/th_main.c
+++ src/th_main.c
@@ -427,10 +427,11 @@
427427
if( zFilename==0 ){
428428
Th_SetResult(interp, "invalid file name", -1);
429429
return 0;
430430
}
431431
cirid = th1_name_to_typed_rid(interp, zCI, "*");
432
+ if( cirid<0 ) return 0;
432433
blob_zero(&err);
433434
pManifest = manifest_get(cirid, CFTYPE_MANIFEST, &err);
434435
if( pManifest==0 ){
435436
if( blob_size(&err)>0 ){
436437
Th_SetResult(interp, blob_str(&err), blob_size(&err));
@@ -520,10 +521,18 @@
520521
){
521522
int withMethod = 0;
522523
if( argc!=2 && argc!=3 ){
523524
return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524525
}
526
+ if( g.httpOut==0
527
+ || (g.zBaseURL==0 && fossil_strncmp(argv[1],"http:",5)!=0
528
+ && fossil_strncmp(argv[1],"https:",6)!=0)
529
+ ){
530
+ Th_ErrorMessage(interp, "redirect is only allowed in a web request",
531
+ 0, 0);
532
+ return TH_ERROR;
533
+ }
525534
if( argc==3 ){
526535
if( Th_ToInt(interp, argv[2], argl[2], &withMethod) ){
527536
return TH_ERROR;
528537
}
529538
}
@@ -1124,11 +1133,14 @@
11241133
int *aszElem;
11251134
char **azElem;
11261135
int i;
11271136
11281137
if( Th_ToInt(interp, argv[3], argl[3], &height) ) return TH_ERROR;
1129
- Th_SplitList(interp, argv[2], TH1_LEN(argl[2]), &azElem, &aszElem, &nElem);
1138
+ if( Th_SplitList(interp, argv[2], TH1_LEN(argl[2]),
1139
+ &azElem, &aszElem, &nElem) ){
1140
+ return TH_ERROR;
1141
+ }
11301142
blob_init(&name, (char*)argv[1], TH1_LEN(argl[1]));
11311143
zValue = Th_Fetch(blob_str(&name), &nValue);
11321144
nValue = TH1_LEN(nValue);
11331145
zH = htmlize(blob_buffer(&name), blob_size(&name));
11341146
z = mprintf("<select id=\"%s\" name=\"%s\" size=\"%d\">", zH, zH, height);
@@ -1643,11 +1655,19 @@
16431655
int *argl
16441656
){
16451657
if( argc!=2 ){
16461658
return Th_WrongNumArgs(interp, "builtin_request_js NAME");
16471659
}
1648
- builtin_request_js(argv[1]);
1660
+ switch( builtin_try_request_js(argv[1]) ){
1661
+ case 1:
1662
+ Th_ErrorMessage(interp, "unknown javascript file:",
1663
+ argv[1], TH1_LEN(argl[1]));
1664
+ return TH_ERROR;
1665
+ case 2:
1666
+ Th_ErrorMessage(interp, "too many javascript files requested", 0, 0);
1667
+ return TH_ERROR;
1668
+ }
16491669
return TH_OK;
16501670
}
16511671
16521672
/*
16531673
** TH1 command: artifact ID ?FILENAME?
@@ -1672,11 +1692,11 @@
16721692
if( argc==3 ){
16731693
rid = th1_artifact_from_ci_and_filename(interp, argv[1], argv[2]);
16741694
}else{
16751695
rid = th1_name_to_typed_rid(interp, argv[1], "*");
16761696
}
1677
- if( rid!=0 && content_get(rid, &content) ){
1697
+ if( rid>0 && content_get(rid, &content) ){
16781698
Th_SetResult(interp, blob_str(&content), blob_size(&content));
16791699
blob_reset(&content);
16801700
return TH_OK;
16811701
}else{
16821702
return TH_ERROR;
@@ -1723,11 +1743,13 @@
17231743
if( argc!=3 ){
17241744
return Th_WrongNumArgs(interp, "unversioned content FILENAME");
17251745
}
17261746
if( Th_IsRepositoryOpen() ){
17271747
Blob content;
1728
- if( unversioned_content(argv[2], &content)!=0 ){
1748
+ if( db_table_exists("repository", "unversioned")
1749
+ && unversioned_content(argv[2], &content)!=0
1750
+ ){
17291751
Th_SetResult(interp, blob_str(&content), blob_size(&content));
17301752
blob_reset(&content);
17311753
return TH_OK;
17321754
}else{
17331755
return TH_ERROR;
@@ -1756,16 +1778,18 @@
17561778
}
17571779
if( Th_IsRepositoryOpen() ){
17581780
Stmt q;
17591781
char *zList = 0;
17601782
int nList = 0;
1761
- db_prepare(&q, "SELECT name FROM unversioned WHERE hash IS NOT NULL"
1762
- " ORDER BY name");
1763
- while( db_step(&q)==SQLITE_ROW ){
1764
- Th_ListAppend(interp, &zList, &nList, db_column_text(&q,0), -1);
1783
+ if( db_table_exists("repository", "unversioned") ){
1784
+ db_prepare(&q, "SELECT name FROM unversioned WHERE hash IS NOT NULL"
1785
+ " ORDER BY name");
1786
+ while( db_step(&q)==SQLITE_ROW ){
1787
+ Th_ListAppend(interp, &zList, &nList, db_column_text(&q,0), -1);
1788
+ }
1789
+ db_finalize(&q);
17651790
}
1766
- db_finalize(&q);
17671791
Th_SetResult(interp, zList, nList);
17681792
Th_Free(interp, zList);
17691793
return TH_OK;
17701794
}else{
17711795
Th_SetResult(interp, "repository unavailable", -1);
@@ -1882,13 +1906,13 @@
18821906
const char **argv,
18831907
int *argl
18841908
){
18851909
int n;
18861910
unsigned char aRand[50];
1887
- unsigned char zOut[100];
1911
+ unsigned char zOut[sizeof(aRand)*2+1];
18881912
if( argc!=1 && argc!=2 ){
1889
- return Th_WrongNumArgs(interp, "repository ?BOOLEAN?");
1913
+ return Th_WrongNumArgs(interp, "randhex ?N?");
18901914
}
18911915
if( argc==2 ){
18921916
if( Th_ToInt(interp, argv[1], argl[1], &n) ){
18931917
return TH_ERROR;
18941918
}
@@ -1970,11 +1994,11 @@
19701994
19711995
while( res==TH_OK && nSql>0 ){
19721996
zErr = 0;
19731997
report_restrict_sql(&zErr);
19741998
g.dbIgnoreErrors++;
1975
- rc = sqlite3_prepare_v2(g.db, argv[1], TH1_LEN(argl[1]), &pStmt, &zTail);
1999
+ rc = sqlite3_prepare_v2(g.db, zSql, nSql, &pStmt, &zTail);
19762000
g.dbIgnoreErrors--;
19772001
report_unrestrict_sql();
19782002
if( rc!=0 || zErr!=0 ){
19792003
if( noComplain ) return TH_OK;
19802004
Th_ErrorMessage(interp, "SQL error: ",
@@ -1982,11 +2006,14 @@
19822006
return TH_ERROR;
19832007
}
19842008
n = (int)(zTail - zSql);
19852009
zSql += n;
19862010
nSql -= n;
1987
- if( pStmt==0 ) continue;
2011
+ if( pStmt==0 ){
2012
+ if( n==0 ) break;
2013
+ continue;
2014
+ }
19882015
nVar = sqlite3_bind_parameter_count(pStmt);
19892016
for(i=1; i<=nVar; i++){
19902017
const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
19912018
int szVar = zVar ? th_strlen(zVar) : 0;
19922019
if( szVar>1 && zVar[0]=='$'
@@ -2048,11 +2075,11 @@
20482075
return Th_WrongNumArgs(interp, SETTING_WRONGNUMARGS);
20492076
}
20502077
if( fossil_strcmp(argv[nArg], "-strict")==0 ){
20512078
strict = 1; nArg++;
20522079
}
2053
- if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2080
+ if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
20542081
if( nArg+1!=argc ){
20552082
return Th_WrongNumArgs(interp, SETTING_WRONGNUMARGS);
20562083
}
20572084
zValue = db_get(argv[nArg], 0);
20582085
if( zValue!=0 ){
@@ -2187,23 +2214,27 @@
21872214
UrlData urlData;
21882215
21892216
if( argc<2 || argc>5 ){
21902217
return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
21912218
}
2192
- if( fossil_strnicmp(argv[nArg], "-asynchronous", TH1_LEN(argl[nArg]))==0 ){
2219
+ if( TH1_LEN(argl[nArg])>0
2220
+ && fossil_strnicmp(argv[nArg], "-asynchronous", TH1_LEN(argl[nArg]))==0
2221
+ ){
21932222
fAsynchronous = 1; nArg++;
21942223
}
2195
- if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2224
+ if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
21962225
if( nArg+1!=argc && nArg+2!=argc ){
2197
- return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
2226
+ return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
21982227
}
2199
- memset(&urlData, '\0', sizeof(urlData));
2200
- url_parse_local(argv[nArg], 0, &urlData);
2201
- if( urlData.isSsh || urlData.isFile ){
2228
+ if( fossil_strnicmp(argv[nArg], "http://", 7)!=0
2229
+ && fossil_strnicmp(argv[nArg], "https://", 8)!=0
2230
+ ){
22022231
Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
22032232
return TH_ERROR;
22042233
}
2234
+ memset(&urlData, '\0', sizeof(urlData));
2235
+ url_parse_local(argv[nArg], 0, &urlData);
22052236
zRegexp = db_get("th1-uri-regexp", 0);
22062237
if( zRegexp && zRegexp[0] ){
22072238
const char *zErr = fossil_re_compile(&pRe, zRegexp, 0);
22082239
if( zErr ){
22092240
Th_SetResult(interp, zErr, -1);
@@ -2971,11 +3002,11 @@
29713002
}
29723003
}
29733004
if( rc==TH_ERROR ){
29743005
zResult = (char*)Th_GetResult(g.interp, &n);
29753006
sendError(pOut,zResult, n, 1);
2976
- }else{
3007
+ }else if( rc==TH_OK ){
29773008
sendText(pOut,z, i, 0);
29783009
}
29793010
Th_SetOutputBlob(origOut);
29803011
return rc;
29813012
}
29823013
--- src/th_main.c
+++ src/th_main.c
@@ -427,10 +427,11 @@
427 if( zFilename==0 ){
428 Th_SetResult(interp, "invalid file name", -1);
429 return 0;
430 }
431 cirid = th1_name_to_typed_rid(interp, zCI, "*");
 
432 blob_zero(&err);
433 pManifest = manifest_get(cirid, CFTYPE_MANIFEST, &err);
434 if( pManifest==0 ){
435 if( blob_size(&err)>0 ){
436 Th_SetResult(interp, blob_str(&err), blob_size(&err));
@@ -520,10 +521,18 @@
520 ){
521 int withMethod = 0;
522 if( argc!=2 && argc!=3 ){
523 return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
524 }
 
 
 
 
 
 
 
 
525 if( argc==3 ){
526 if( Th_ToInt(interp, argv[2], argl[2], &withMethod) ){
527 return TH_ERROR;
528 }
529 }
@@ -1124,11 +1133,14 @@
1124 int *aszElem;
1125 char **azElem;
1126 int i;
1127
1128 if( Th_ToInt(interp, argv[3], argl[3], &height) ) return TH_ERROR;
1129 Th_SplitList(interp, argv[2], TH1_LEN(argl[2]), &azElem, &aszElem, &nElem);
 
 
 
1130 blob_init(&name, (char*)argv[1], TH1_LEN(argl[1]));
1131 zValue = Th_Fetch(blob_str(&name), &nValue);
1132 nValue = TH1_LEN(nValue);
1133 zH = htmlize(blob_buffer(&name), blob_size(&name));
1134 z = mprintf("<select id=\"%s\" name=\"%s\" size=\"%d\">", zH, zH, height);
@@ -1643,11 +1655,19 @@
1643 int *argl
1644 ){
1645 if( argc!=2 ){
1646 return Th_WrongNumArgs(interp, "builtin_request_js NAME");
1647 }
1648 builtin_request_js(argv[1]);
 
 
 
 
 
 
 
 
1649 return TH_OK;
1650 }
1651
1652 /*
1653 ** TH1 command: artifact ID ?FILENAME?
@@ -1672,11 +1692,11 @@
1672 if( argc==3 ){
1673 rid = th1_artifact_from_ci_and_filename(interp, argv[1], argv[2]);
1674 }else{
1675 rid = th1_name_to_typed_rid(interp, argv[1], "*");
1676 }
1677 if( rid!=0 && content_get(rid, &content) ){
1678 Th_SetResult(interp, blob_str(&content), blob_size(&content));
1679 blob_reset(&content);
1680 return TH_OK;
1681 }else{
1682 return TH_ERROR;
@@ -1723,11 +1743,13 @@
1723 if( argc!=3 ){
1724 return Th_WrongNumArgs(interp, "unversioned content FILENAME");
1725 }
1726 if( Th_IsRepositoryOpen() ){
1727 Blob content;
1728 if( unversioned_content(argv[2], &content)!=0 ){
 
 
1729 Th_SetResult(interp, blob_str(&content), blob_size(&content));
1730 blob_reset(&content);
1731 return TH_OK;
1732 }else{
1733 return TH_ERROR;
@@ -1756,16 +1778,18 @@
1756 }
1757 if( Th_IsRepositoryOpen() ){
1758 Stmt q;
1759 char *zList = 0;
1760 int nList = 0;
1761 db_prepare(&q, "SELECT name FROM unversioned WHERE hash IS NOT NULL"
1762 " ORDER BY name");
1763 while( db_step(&q)==SQLITE_ROW ){
1764 Th_ListAppend(interp, &zList, &nList, db_column_text(&q,0), -1);
 
 
 
1765 }
1766 db_finalize(&q);
1767 Th_SetResult(interp, zList, nList);
1768 Th_Free(interp, zList);
1769 return TH_OK;
1770 }else{
1771 Th_SetResult(interp, "repository unavailable", -1);
@@ -1882,13 +1906,13 @@
1882 const char **argv,
1883 int *argl
1884 ){
1885 int n;
1886 unsigned char aRand[50];
1887 unsigned char zOut[100];
1888 if( argc!=1 && argc!=2 ){
1889 return Th_WrongNumArgs(interp, "repository ?BOOLEAN?");
1890 }
1891 if( argc==2 ){
1892 if( Th_ToInt(interp, argv[1], argl[1], &n) ){
1893 return TH_ERROR;
1894 }
@@ -1970,11 +1994,11 @@
1970
1971 while( res==TH_OK && nSql>0 ){
1972 zErr = 0;
1973 report_restrict_sql(&zErr);
1974 g.dbIgnoreErrors++;
1975 rc = sqlite3_prepare_v2(g.db, argv[1], TH1_LEN(argl[1]), &pStmt, &zTail);
1976 g.dbIgnoreErrors--;
1977 report_unrestrict_sql();
1978 if( rc!=0 || zErr!=0 ){
1979 if( noComplain ) return TH_OK;
1980 Th_ErrorMessage(interp, "SQL error: ",
@@ -1982,11 +2006,14 @@
1982 return TH_ERROR;
1983 }
1984 n = (int)(zTail - zSql);
1985 zSql += n;
1986 nSql -= n;
1987 if( pStmt==0 ) continue;
 
 
 
1988 nVar = sqlite3_bind_parameter_count(pStmt);
1989 for(i=1; i<=nVar; i++){
1990 const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
1991 int szVar = zVar ? th_strlen(zVar) : 0;
1992 if( szVar>1 && zVar[0]=='$'
@@ -2048,11 +2075,11 @@
2048 return Th_WrongNumArgs(interp, SETTING_WRONGNUMARGS);
2049 }
2050 if( fossil_strcmp(argv[nArg], "-strict")==0 ){
2051 strict = 1; nArg++;
2052 }
2053 if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2054 if( nArg+1!=argc ){
2055 return Th_WrongNumArgs(interp, SETTING_WRONGNUMARGS);
2056 }
2057 zValue = db_get(argv[nArg], 0);
2058 if( zValue!=0 ){
@@ -2187,23 +2214,27 @@
2187 UrlData urlData;
2188
2189 if( argc<2 || argc>5 ){
2190 return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
2191 }
2192 if( fossil_strnicmp(argv[nArg], "-asynchronous", TH1_LEN(argl[nArg]))==0 ){
 
 
2193 fAsynchronous = 1; nArg++;
2194 }
2195 if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2196 if( nArg+1!=argc && nArg+2!=argc ){
2197 return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
2198 }
2199 memset(&urlData, '\0', sizeof(urlData));
2200 url_parse_local(argv[nArg], 0, &urlData);
2201 if( urlData.isSsh || urlData.isFile ){
2202 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
2203 return TH_ERROR;
2204 }
 
 
2205 zRegexp = db_get("th1-uri-regexp", 0);
2206 if( zRegexp && zRegexp[0] ){
2207 const char *zErr = fossil_re_compile(&pRe, zRegexp, 0);
2208 if( zErr ){
2209 Th_SetResult(interp, zErr, -1);
@@ -2971,11 +3002,11 @@
2971 }
2972 }
2973 if( rc==TH_ERROR ){
2974 zResult = (char*)Th_GetResult(g.interp, &n);
2975 sendError(pOut,zResult, n, 1);
2976 }else{
2977 sendText(pOut,z, i, 0);
2978 }
2979 Th_SetOutputBlob(origOut);
2980 return rc;
2981 }
2982
--- src/th_main.c
+++ src/th_main.c
@@ -427,10 +427,11 @@
427 if( zFilename==0 ){
428 Th_SetResult(interp, "invalid file name", -1);
429 return 0;
430 }
431 cirid = th1_name_to_typed_rid(interp, zCI, "*");
432 if( cirid<0 ) return 0;
433 blob_zero(&err);
434 pManifest = manifest_get(cirid, CFTYPE_MANIFEST, &err);
435 if( pManifest==0 ){
436 if( blob_size(&err)>0 ){
437 Th_SetResult(interp, blob_str(&err), blob_size(&err));
@@ -520,10 +521,18 @@
521 ){
522 int withMethod = 0;
523 if( argc!=2 && argc!=3 ){
524 return Th_WrongNumArgs(interp, "redirect URL ?withMethod?");
525 }
526 if( g.httpOut==0
527 || (g.zBaseURL==0 && fossil_strncmp(argv[1],"http:",5)!=0
528 && fossil_strncmp(argv[1],"https:",6)!=0)
529 ){
530 Th_ErrorMessage(interp, "redirect is only allowed in a web request",
531 0, 0);
532 return TH_ERROR;
533 }
534 if( argc==3 ){
535 if( Th_ToInt(interp, argv[2], argl[2], &withMethod) ){
536 return TH_ERROR;
537 }
538 }
@@ -1124,11 +1133,14 @@
1133 int *aszElem;
1134 char **azElem;
1135 int i;
1136
1137 if( Th_ToInt(interp, argv[3], argl[3], &height) ) return TH_ERROR;
1138 if( Th_SplitList(interp, argv[2], TH1_LEN(argl[2]),
1139 &azElem, &aszElem, &nElem) ){
1140 return TH_ERROR;
1141 }
1142 blob_init(&name, (char*)argv[1], TH1_LEN(argl[1]));
1143 zValue = Th_Fetch(blob_str(&name), &nValue);
1144 nValue = TH1_LEN(nValue);
1145 zH = htmlize(blob_buffer(&name), blob_size(&name));
1146 z = mprintf("<select id=\"%s\" name=\"%s\" size=\"%d\">", zH, zH, height);
@@ -1643,11 +1655,19 @@
1655 int *argl
1656 ){
1657 if( argc!=2 ){
1658 return Th_WrongNumArgs(interp, "builtin_request_js NAME");
1659 }
1660 switch( builtin_try_request_js(argv[1]) ){
1661 case 1:
1662 Th_ErrorMessage(interp, "unknown javascript file:",
1663 argv[1], TH1_LEN(argl[1]));
1664 return TH_ERROR;
1665 case 2:
1666 Th_ErrorMessage(interp, "too many javascript files requested", 0, 0);
1667 return TH_ERROR;
1668 }
1669 return TH_OK;
1670 }
1671
1672 /*
1673 ** TH1 command: artifact ID ?FILENAME?
@@ -1672,11 +1692,11 @@
1692 if( argc==3 ){
1693 rid = th1_artifact_from_ci_and_filename(interp, argv[1], argv[2]);
1694 }else{
1695 rid = th1_name_to_typed_rid(interp, argv[1], "*");
1696 }
1697 if( rid>0 && content_get(rid, &content) ){
1698 Th_SetResult(interp, blob_str(&content), blob_size(&content));
1699 blob_reset(&content);
1700 return TH_OK;
1701 }else{
1702 return TH_ERROR;
@@ -1723,11 +1743,13 @@
1743 if( argc!=3 ){
1744 return Th_WrongNumArgs(interp, "unversioned content FILENAME");
1745 }
1746 if( Th_IsRepositoryOpen() ){
1747 Blob content;
1748 if( db_table_exists("repository", "unversioned")
1749 && unversioned_content(argv[2], &content)!=0
1750 ){
1751 Th_SetResult(interp, blob_str(&content), blob_size(&content));
1752 blob_reset(&content);
1753 return TH_OK;
1754 }else{
1755 return TH_ERROR;
@@ -1756,16 +1778,18 @@
1778 }
1779 if( Th_IsRepositoryOpen() ){
1780 Stmt q;
1781 char *zList = 0;
1782 int nList = 0;
1783 if( db_table_exists("repository", "unversioned") ){
1784 db_prepare(&q, "SELECT name FROM unversioned WHERE hash IS NOT NULL"
1785 " ORDER BY name");
1786 while( db_step(&q)==SQLITE_ROW ){
1787 Th_ListAppend(interp, &zList, &nList, db_column_text(&q,0), -1);
1788 }
1789 db_finalize(&q);
1790 }
 
1791 Th_SetResult(interp, zList, nList);
1792 Th_Free(interp, zList);
1793 return TH_OK;
1794 }else{
1795 Th_SetResult(interp, "repository unavailable", -1);
@@ -1882,13 +1906,13 @@
1906 const char **argv,
1907 int *argl
1908 ){
1909 int n;
1910 unsigned char aRand[50];
1911 unsigned char zOut[sizeof(aRand)*2+1];
1912 if( argc!=1 && argc!=2 ){
1913 return Th_WrongNumArgs(interp, "randhex ?N?");
1914 }
1915 if( argc==2 ){
1916 if( Th_ToInt(interp, argv[1], argl[1], &n) ){
1917 return TH_ERROR;
1918 }
@@ -1970,11 +1994,11 @@
1994
1995 while( res==TH_OK && nSql>0 ){
1996 zErr = 0;
1997 report_restrict_sql(&zErr);
1998 g.dbIgnoreErrors++;
1999 rc = sqlite3_prepare_v2(g.db, zSql, nSql, &pStmt, &zTail);
2000 g.dbIgnoreErrors--;
2001 report_unrestrict_sql();
2002 if( rc!=0 || zErr!=0 ){
2003 if( noComplain ) return TH_OK;
2004 Th_ErrorMessage(interp, "SQL error: ",
@@ -1982,11 +2006,14 @@
2006 return TH_ERROR;
2007 }
2008 n = (int)(zTail - zSql);
2009 zSql += n;
2010 nSql -= n;
2011 if( pStmt==0 ){
2012 if( n==0 ) break;
2013 continue;
2014 }
2015 nVar = sqlite3_bind_parameter_count(pStmt);
2016 for(i=1; i<=nVar; i++){
2017 const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
2018 int szVar = zVar ? th_strlen(zVar) : 0;
2019 if( szVar>1 && zVar[0]=='$'
@@ -2048,11 +2075,11 @@
2075 return Th_WrongNumArgs(interp, SETTING_WRONGNUMARGS);
2076 }
2077 if( fossil_strcmp(argv[nArg], "-strict")==0 ){
2078 strict = 1; nArg++;
2079 }
2080 if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2081 if( nArg+1!=argc ){
2082 return Th_WrongNumArgs(interp, SETTING_WRONGNUMARGS);
2083 }
2084 zValue = db_get(argv[nArg], 0);
2085 if( zValue!=0 ){
@@ -2187,23 +2214,27 @@
2214 UrlData urlData;
2215
2216 if( argc<2 || argc>5 ){
2217 return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
2218 }
2219 if( TH1_LEN(argl[nArg])>0
2220 && fossil_strnicmp(argv[nArg], "-asynchronous", TH1_LEN(argl[nArg]))==0
2221 ){
2222 fAsynchronous = 1; nArg++;
2223 }
2224 if( nArg<argc && fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
2225 if( nArg+1!=argc && nArg+2!=argc ){
2226 return Th_WrongNumArgs(interp, HTTP_WRONGNUMARGS);
2227 }
2228 if( fossil_strnicmp(argv[nArg], "http://", 7)!=0
2229 && fossil_strnicmp(argv[nArg], "https://", 8)!=0
2230 ){
2231 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
2232 return TH_ERROR;
2233 }
2234 memset(&urlData, '\0', sizeof(urlData));
2235 url_parse_local(argv[nArg], 0, &urlData);
2236 zRegexp = db_get("th1-uri-regexp", 0);
2237 if( zRegexp && zRegexp[0] ){
2238 const char *zErr = fossil_re_compile(&pRe, zRegexp, 0);
2239 if( zErr ){
2240 Th_SetResult(interp, zErr, -1);
@@ -2971,11 +3002,11 @@
3002 }
3003 }
3004 if( rc==TH_ERROR ){
3005 zResult = (char*)Th_GetResult(g.interp, &n);
3006 sendError(pOut,zResult, n, 1);
3007 }else if( rc==TH_OK ){
3008 sendText(pOut,z, i, 0);
3009 }
3010 Th_SetOutputBlob(origOut);
3011 return rc;
3012 }
3013
+2 -1
--- src/timeline.c
+++ src/timeline.c
@@ -2558,11 +2558,12 @@
25582558
}
25592559
if( zFwdTo ){
25602560
double rStartDate = mtime_of_rid(d_rid, 0.0);
25612561
ridFwdTo = first_checkin_with_tag_after_date(zFwdTo, rStartDate);
25622562
if( ridFwdTo==0 ){
2563
- ridFwdTo = name_to_typed_rid(zBackTo,"ci");
2563
+ int rid = symbolic_name_to_rid(zFwdTo,"ci");
2564
+ if( rid>0 && mtime_of_rid(rid, 0.0)>rStartDate ) ridFwdTo = rid;
25642565
}
25652566
if( ridFwdTo ){
25662567
if( !haveParameterN ) nEntry = 0;
25672568
rStopTime = mtime_of_rid(ridFwdTo, 9e99);
25682569
}
25692570
--- src/timeline.c
+++ src/timeline.c
@@ -2558,11 +2558,12 @@
2558 }
2559 if( zFwdTo ){
2560 double rStartDate = mtime_of_rid(d_rid, 0.0);
2561 ridFwdTo = first_checkin_with_tag_after_date(zFwdTo, rStartDate);
2562 if( ridFwdTo==0 ){
2563 ridFwdTo = name_to_typed_rid(zBackTo,"ci");
 
2564 }
2565 if( ridFwdTo ){
2566 if( !haveParameterN ) nEntry = 0;
2567 rStopTime = mtime_of_rid(ridFwdTo, 9e99);
2568 }
2569
--- src/timeline.c
+++ src/timeline.c
@@ -2558,11 +2558,12 @@
2558 }
2559 if( zFwdTo ){
2560 double rStartDate = mtime_of_rid(d_rid, 0.0);
2561 ridFwdTo = first_checkin_with_tag_after_date(zFwdTo, rStartDate);
2562 if( ridFwdTo==0 ){
2563 int rid = symbolic_name_to_rid(zFwdTo,"ci");
2564 if( rid>0 && mtime_of_rid(rid, 0.0)>rStartDate ) ridFwdTo = rid;
2565 }
2566 if( ridFwdTo ){
2567 if( !haveParameterN ) nEntry = 0;
2568 rStopTime = mtime_of_rid(ridFwdTo, 9e99);
2569 }
2570
+17 -4
--- src/url.c
+++ src/url.c
@@ -157,11 +157,10 @@
157157
|| fossil_strnicmp(zUrl, "ssh://", 6)==0
158158
){
159159
int iStart;
160160
char *zLogin;
161161
char *zExe;
162
- char cQuerySep = '?';
163162
const char *zLb; /* "[" before an IPv6 address in a URL, else "" */
164163
const char *zRb; /* "]" after an IPv6 address in a URL, else "" */
165164
166165
if( zUrl[4]=='s' || zUrl[4]=='S' ){
167166
pUrlData->isHttps = 1;
@@ -235,10 +234,11 @@
235234
if( c==':' ){
236235
pUrlData->port = 0;
237236
i++;
238237
while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
239238
pUrlData->port = pUrlData->port*10 + c - '0';
239
+ if( pUrlData->port>65535 ) fossil_fatal("port number too large in url");
240240
i++;
241241
}
242242
if( c!=0 && c!='/' && c!='?' && c!='#' ){
243243
fossil_fatal("url missing '/' after port number");
244244
}
@@ -284,16 +284,17 @@
284284
if( pUrlData->path[i] ){
285285
pUrlData->path[i] = 0;
286286
i++;
287287
}
288288
if( fossil_strcmp(zName,"fossil")==0 ){
289
+ if( zExe && zExe[0] )
290
+ fossil_fatal("more than one fossil= query parameter");
289291
fossil_free(pUrlData->fossil);
290292
pUrlData->fossil = fossil_strdup(zValue);
291293
dehttpize(pUrlData->fossil);
292294
fossil_free(zExe);
293
- zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil);
294
- cQuerySep = '&';
295
+ zExe = mprintf("?fossil=%T", pUrlData->fossil);
295296
urlFlags |= URL_SSH_EXE;
296297
}
297298
}
298299
299300
dehttpize(pUrlData->path);
@@ -308,11 +309,11 @@
308309
"%s://%s%s%T%s:%d%T%z",
309310
pUrlData->protocol, zLogin, zLb, pUrlData->name, zRb,
310311
pUrlData->port, pUrlData->path, zExe
311312
);
312313
}
313
- if( pUrlData->isSsh && pUrlData->path[1] ){
314
+ if( pUrlData->isSsh && pUrlData->path[0] && pUrlData->path[1] ){
314315
char *zOld = pUrlData->path;
315316
pUrlData->path = fossil_strdup(zOld+1);
316317
fossil_free(zOld);
317318
}
318319
free(zLogin);
@@ -397,10 +398,14 @@
397398
blob_appendf(&x, "@");
398399
}
399400
url_append_host(&x, p->name);
400401
if( p->dfltPort!=p->port ){
401402
blob_appendf(&x, ":%d", p->port);
403
+ }
404
+ if( p->isSsh && p->path[0] && fossil_strcmp(p->path, "/")!=0 ){
405
+ /* The path of an ssh: URL is held without its first "/". */
406
+ blob_append_char(&x, '/');
402407
}
403408
blob_appendf(&x, "%T", p->path);
404409
(void)blob_str(&x);
405410
return x.aData;
406411
}
@@ -417,10 +422,14 @@
417422
}
418423
blob_appendf(&x, "%s://", p->protocol);
419424
url_append_host(&x, p->name);
420425
if( p->dfltPort!=p->port ){
421426
blob_appendf(&x, ":%d", p->port);
427
+ }
428
+ if( p->isSsh && p->path[0] && fossil_strcmp(p->path, "/")!=0 ){
429
+ /* The path of an ssh: URL is held without its first "/". */
430
+ blob_append_char(&x, '/');
422431
}
423432
blob_appendf(&x, "%T", p->path);
424433
(void)blob_str(&x);
425434
return x.aData;
426435
}
@@ -645,10 +654,14 @@
645654
int iOriginalPort = g.url.port;
646655
unsigned uOriginalFlags = g.url.flags;
647656
g.url.user = 0;
648657
g.url.passwd = "";
649658
url_parse(zProxy, 0);
659
+ if( g.url.isFile || g.url.isSsh ){
660
+ fossil_fatal("the proxy must be an http: or https: URL: %s",
661
+ g.url.canonical);
662
+ }
650663
if( zMsg ) fossil_print("%s%s\n", zMsg, g.url.canonical);
651664
g.url.path = zOriginalUrl;
652665
g.url.hostname = zOriginalHost;
653666
if( g.url.user ){
654667
char *zCredentials1 = mprintf("%s:%s", g.url.user, g.url.passwd);
655668
--- src/url.c
+++ src/url.c
@@ -157,11 +157,10 @@
157 || fossil_strnicmp(zUrl, "ssh://", 6)==0
158 ){
159 int iStart;
160 char *zLogin;
161 char *zExe;
162 char cQuerySep = '?';
163 const char *zLb; /* "[" before an IPv6 address in a URL, else "" */
164 const char *zRb; /* "]" after an IPv6 address in a URL, else "" */
165
166 if( zUrl[4]=='s' || zUrl[4]=='S' ){
167 pUrlData->isHttps = 1;
@@ -235,10 +234,11 @@
235 if( c==':' ){
236 pUrlData->port = 0;
237 i++;
238 while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
239 pUrlData->port = pUrlData->port*10 + c - '0';
 
240 i++;
241 }
242 if( c!=0 && c!='/' && c!='?' && c!='#' ){
243 fossil_fatal("url missing '/' after port number");
244 }
@@ -284,16 +284,17 @@
284 if( pUrlData->path[i] ){
285 pUrlData->path[i] = 0;
286 i++;
287 }
288 if( fossil_strcmp(zName,"fossil")==0 ){
 
 
289 fossil_free(pUrlData->fossil);
290 pUrlData->fossil = fossil_strdup(zValue);
291 dehttpize(pUrlData->fossil);
292 fossil_free(zExe);
293 zExe = mprintf("%cfossil=%T", cQuerySep, pUrlData->fossil);
294 cQuerySep = '&';
295 urlFlags |= URL_SSH_EXE;
296 }
297 }
298
299 dehttpize(pUrlData->path);
@@ -308,11 +309,11 @@
308 "%s://%s%s%T%s:%d%T%z",
309 pUrlData->protocol, zLogin, zLb, pUrlData->name, zRb,
310 pUrlData->port, pUrlData->path, zExe
311 );
312 }
313 if( pUrlData->isSsh && pUrlData->path[1] ){
314 char *zOld = pUrlData->path;
315 pUrlData->path = fossil_strdup(zOld+1);
316 fossil_free(zOld);
317 }
318 free(zLogin);
@@ -397,10 +398,14 @@
397 blob_appendf(&x, "@");
398 }
399 url_append_host(&x, p->name);
400 if( p->dfltPort!=p->port ){
401 blob_appendf(&x, ":%d", p->port);
 
 
 
 
402 }
403 blob_appendf(&x, "%T", p->path);
404 (void)blob_str(&x);
405 return x.aData;
406 }
@@ -417,10 +422,14 @@
417 }
418 blob_appendf(&x, "%s://", p->protocol);
419 url_append_host(&x, p->name);
420 if( p->dfltPort!=p->port ){
421 blob_appendf(&x, ":%d", p->port);
 
 
 
 
422 }
423 blob_appendf(&x, "%T", p->path);
424 (void)blob_str(&x);
425 return x.aData;
426 }
@@ -645,10 +654,14 @@
645 int iOriginalPort = g.url.port;
646 unsigned uOriginalFlags = g.url.flags;
647 g.url.user = 0;
648 g.url.passwd = "";
649 url_parse(zProxy, 0);
 
 
 
 
650 if( zMsg ) fossil_print("%s%s\n", zMsg, g.url.canonical);
651 g.url.path = zOriginalUrl;
652 g.url.hostname = zOriginalHost;
653 if( g.url.user ){
654 char *zCredentials1 = mprintf("%s:%s", g.url.user, g.url.passwd);
655
--- src/url.c
+++ src/url.c
@@ -157,11 +157,10 @@
157 || fossil_strnicmp(zUrl, "ssh://", 6)==0
158 ){
159 int iStart;
160 char *zLogin;
161 char *zExe;
 
162 const char *zLb; /* "[" before an IPv6 address in a URL, else "" */
163 const char *zRb; /* "]" after an IPv6 address in a URL, else "" */
164
165 if( zUrl[4]=='s' || zUrl[4]=='S' ){
166 pUrlData->isHttps = 1;
@@ -235,10 +234,11 @@
234 if( c==':' ){
235 pUrlData->port = 0;
236 i++;
237 while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
238 pUrlData->port = pUrlData->port*10 + c - '0';
239 if( pUrlData->port>65535 ) fossil_fatal("port number too large in url");
240 i++;
241 }
242 if( c!=0 && c!='/' && c!='?' && c!='#' ){
243 fossil_fatal("url missing '/' after port number");
244 }
@@ -284,16 +284,17 @@
284 if( pUrlData->path[i] ){
285 pUrlData->path[i] = 0;
286 i++;
287 }
288 if( fossil_strcmp(zName,"fossil")==0 ){
289 if( zExe && zExe[0] )
290 fossil_fatal("more than one fossil= query parameter");
291 fossil_free(pUrlData->fossil);
292 pUrlData->fossil = fossil_strdup(zValue);
293 dehttpize(pUrlData->fossil);
294 fossil_free(zExe);
295 zExe = mprintf("?fossil=%T", pUrlData->fossil);
 
296 urlFlags |= URL_SSH_EXE;
297 }
298 }
299
300 dehttpize(pUrlData->path);
@@ -308,11 +309,11 @@
309 "%s://%s%s%T%s:%d%T%z",
310 pUrlData->protocol, zLogin, zLb, pUrlData->name, zRb,
311 pUrlData->port, pUrlData->path, zExe
312 );
313 }
314 if( pUrlData->isSsh && pUrlData->path[0] && pUrlData->path[1] ){
315 char *zOld = pUrlData->path;
316 pUrlData->path = fossil_strdup(zOld+1);
317 fossil_free(zOld);
318 }
319 free(zLogin);
@@ -397,10 +398,14 @@
398 blob_appendf(&x, "@");
399 }
400 url_append_host(&x, p->name);
401 if( p->dfltPort!=p->port ){
402 blob_appendf(&x, ":%d", p->port);
403 }
404 if( p->isSsh && p->path[0] && fossil_strcmp(p->path, "/")!=0 ){
405 /* The path of an ssh: URL is held without its first "/". */
406 blob_append_char(&x, '/');
407 }
408 blob_appendf(&x, "%T", p->path);
409 (void)blob_str(&x);
410 return x.aData;
411 }
@@ -417,10 +422,14 @@
422 }
423 blob_appendf(&x, "%s://", p->protocol);
424 url_append_host(&x, p->name);
425 if( p->dfltPort!=p->port ){
426 blob_appendf(&x, ":%d", p->port);
427 }
428 if( p->isSsh && p->path[0] && fossil_strcmp(p->path, "/")!=0 ){
429 /* The path of an ssh: URL is held without its first "/". */
430 blob_append_char(&x, '/');
431 }
432 blob_appendf(&x, "%T", p->path);
433 (void)blob_str(&x);
434 return x.aData;
435 }
@@ -645,10 +654,14 @@
654 int iOriginalPort = g.url.port;
655 unsigned uOriginalFlags = g.url.flags;
656 g.url.user = 0;
657 g.url.passwd = "";
658 url_parse(zProxy, 0);
659 if( g.url.isFile || g.url.isSsh ){
660 fossil_fatal("the proxy must be an http: or https: URL: %s",
661 g.url.canonical);
662 }
663 if( zMsg ) fossil_print("%s%s\n", zMsg, g.url.canonical);
664 g.url.path = zOriginalUrl;
665 g.url.hostname = zOriginalHost;
666 if( g.url.user ){
667 char *zCredentials1 = mprintf("%s:%s", g.url.user, g.url.passwd);
668
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -234,10 +234,11 @@
234234
MARKUP_HTML5_ARTICLE,
235235
MARKUP_HTML5_ASIDE,
236236
MARKUP_B,
237237
MARKUP_BIG,
238238
MARKUP_BLOCKQUOTE,
239
+ MARKUP_BUTTON,
239240
MARKUP_BR,
240241
MARKUP_CAPTION,
241242
MARKUP_CENTER,
242243
MARKUP_CITE,
243244
MARKUP_CODE,
@@ -263,10 +264,11 @@
263264
MARKUP_H6,
264265
MARKUP_HTML5_HEADER,
265266
MARKUP_HR,
266267
MARKUP_I,
267268
MARKUP_IMG,
269
+ MARKUP_INPUT,
268270
MARKUP_INS,
269271
MARKUP_KBD,
270272
MARKUP_LABEL,
271273
MARKUP_LI,
272274
MARKUP_MARK,
@@ -353,10 +355,12 @@
353355
{ "aside", MARKUP_HTML5_ASIDE, MUTYPE_BLOCK,
354356
AMSK_ID|AMSK_CLASS|AMSK_STYLE },
355357
{ "b", MARKUP_B, MUTYPE_FONT, AMSK_STYLE },
356358
{ "big", MARKUP_BIG, MUTYPE_FONT, AMSK_STYLE },
357359
{ "blockquote", MARKUP_BLOCKQUOTE, MUTYPE_BLOCK, AMSK_STYLE },
360
+ { "button", MARKUP_BUTTON, MUTYPE_SINGLE,
361
+ AMSK_ID|AMSK_CLASS|AMSK_NAME|AMSK_VALUE },
358362
{ "br", MARKUP_BR, MUTYPE_SINGLE, AMSK_CLEAR },
359363
{ "caption", MARKUP_CAPTION, MUTYPE_BLOCK,
360364
AMSK_ID|AMSK_CLASS|AMSK_STYLE },
361365
{ "center", MARKUP_CENTER, MUTYPE_BLOCK, AMSK_STYLE },
362366
{ "cite", MARKUP_CITE, MUTYPE_FONT, AMSK_STYLE },
@@ -403,10 +407,12 @@
403407
AMSK_STYLE|AMSK_CLASS },
404408
{ "i", MARKUP_I, MUTYPE_FONT, AMSK_STYLE },
405409
{ "img", MARKUP_IMG, MUTYPE_SINGLE,
406410
AMSK_ALIGN|AMSK_ALT|AMSK_BORDER|AMSK_HEIGHT|
407411
AMSK_HSPACE|AMSK_SRC|AMSK_VSPACE|AMSK_WIDTH|AMSK_STYLE },
412
+ { "input", MARKUP_INPUT, MUTYPE_SINGLE,
413
+ AMSK_ID|AMSK_CLASS|AMSK_NAME|AMSK_SIZE|AMSK_TYPE|AMSK_VALUE },
408414
{ "ins", MARKUP_INS, MUTYPE_FONT, AMSK_STYLE },
409415
{ "kbd", MARKUP_KBD, MUTYPE_FONT, AMSK_STYLE },
410416
{ "label", MARKUP_LABEL, MUTYPE_FONT,
411417
AMSK_ID|AMSK_CLASS|AMSK_STYLE },
412418
{ "li", MARKUP_LI, MUTYPE_LI,
413419
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -234,10 +234,11 @@
234 MARKUP_HTML5_ARTICLE,
235 MARKUP_HTML5_ASIDE,
236 MARKUP_B,
237 MARKUP_BIG,
238 MARKUP_BLOCKQUOTE,
 
239 MARKUP_BR,
240 MARKUP_CAPTION,
241 MARKUP_CENTER,
242 MARKUP_CITE,
243 MARKUP_CODE,
@@ -263,10 +264,11 @@
263 MARKUP_H6,
264 MARKUP_HTML5_HEADER,
265 MARKUP_HR,
266 MARKUP_I,
267 MARKUP_IMG,
 
268 MARKUP_INS,
269 MARKUP_KBD,
270 MARKUP_LABEL,
271 MARKUP_LI,
272 MARKUP_MARK,
@@ -353,10 +355,12 @@
353 { "aside", MARKUP_HTML5_ASIDE, MUTYPE_BLOCK,
354 AMSK_ID|AMSK_CLASS|AMSK_STYLE },
355 { "b", MARKUP_B, MUTYPE_FONT, AMSK_STYLE },
356 { "big", MARKUP_BIG, MUTYPE_FONT, AMSK_STYLE },
357 { "blockquote", MARKUP_BLOCKQUOTE, MUTYPE_BLOCK, AMSK_STYLE },
 
 
358 { "br", MARKUP_BR, MUTYPE_SINGLE, AMSK_CLEAR },
359 { "caption", MARKUP_CAPTION, MUTYPE_BLOCK,
360 AMSK_ID|AMSK_CLASS|AMSK_STYLE },
361 { "center", MARKUP_CENTER, MUTYPE_BLOCK, AMSK_STYLE },
362 { "cite", MARKUP_CITE, MUTYPE_FONT, AMSK_STYLE },
@@ -403,10 +407,12 @@
403 AMSK_STYLE|AMSK_CLASS },
404 { "i", MARKUP_I, MUTYPE_FONT, AMSK_STYLE },
405 { "img", MARKUP_IMG, MUTYPE_SINGLE,
406 AMSK_ALIGN|AMSK_ALT|AMSK_BORDER|AMSK_HEIGHT|
407 AMSK_HSPACE|AMSK_SRC|AMSK_VSPACE|AMSK_WIDTH|AMSK_STYLE },
 
 
408 { "ins", MARKUP_INS, MUTYPE_FONT, AMSK_STYLE },
409 { "kbd", MARKUP_KBD, MUTYPE_FONT, AMSK_STYLE },
410 { "label", MARKUP_LABEL, MUTYPE_FONT,
411 AMSK_ID|AMSK_CLASS|AMSK_STYLE },
412 { "li", MARKUP_LI, MUTYPE_LI,
413
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -234,10 +234,11 @@
234 MARKUP_HTML5_ARTICLE,
235 MARKUP_HTML5_ASIDE,
236 MARKUP_B,
237 MARKUP_BIG,
238 MARKUP_BLOCKQUOTE,
239 MARKUP_BUTTON,
240 MARKUP_BR,
241 MARKUP_CAPTION,
242 MARKUP_CENTER,
243 MARKUP_CITE,
244 MARKUP_CODE,
@@ -263,10 +264,11 @@
264 MARKUP_H6,
265 MARKUP_HTML5_HEADER,
266 MARKUP_HR,
267 MARKUP_I,
268 MARKUP_IMG,
269 MARKUP_INPUT,
270 MARKUP_INS,
271 MARKUP_KBD,
272 MARKUP_LABEL,
273 MARKUP_LI,
274 MARKUP_MARK,
@@ -353,10 +355,12 @@
355 { "aside", MARKUP_HTML5_ASIDE, MUTYPE_BLOCK,
356 AMSK_ID|AMSK_CLASS|AMSK_STYLE },
357 { "b", MARKUP_B, MUTYPE_FONT, AMSK_STYLE },
358 { "big", MARKUP_BIG, MUTYPE_FONT, AMSK_STYLE },
359 { "blockquote", MARKUP_BLOCKQUOTE, MUTYPE_BLOCK, AMSK_STYLE },
360 { "button", MARKUP_BUTTON, MUTYPE_SINGLE,
361 AMSK_ID|AMSK_CLASS|AMSK_NAME|AMSK_VALUE },
362 { "br", MARKUP_BR, MUTYPE_SINGLE, AMSK_CLEAR },
363 { "caption", MARKUP_CAPTION, MUTYPE_BLOCK,
364 AMSK_ID|AMSK_CLASS|AMSK_STYLE },
365 { "center", MARKUP_CENTER, MUTYPE_BLOCK, AMSK_STYLE },
366 { "cite", MARKUP_CITE, MUTYPE_FONT, AMSK_STYLE },
@@ -403,10 +407,12 @@
407 AMSK_STYLE|AMSK_CLASS },
408 { "i", MARKUP_I, MUTYPE_FONT, AMSK_STYLE },
409 { "img", MARKUP_IMG, MUTYPE_SINGLE,
410 AMSK_ALIGN|AMSK_ALT|AMSK_BORDER|AMSK_HEIGHT|
411 AMSK_HSPACE|AMSK_SRC|AMSK_VSPACE|AMSK_WIDTH|AMSK_STYLE },
412 { "input", MARKUP_INPUT, MUTYPE_SINGLE,
413 AMSK_ID|AMSK_CLASS|AMSK_NAME|AMSK_SIZE|AMSK_TYPE|AMSK_VALUE },
414 { "ins", MARKUP_INS, MUTYPE_FONT, AMSK_STYLE },
415 { "kbd", MARKUP_KBD, MUTYPE_FONT, AMSK_STYLE },
416 { "label", MARKUP_LABEL, MUTYPE_FONT,
417 AMSK_ID|AMSK_CLASS|AMSK_STYLE },
418 { "li", MARKUP_LI, MUTYPE_LI,
419
+14 -7
--- src/xfer.c
+++ src/xfer.c
@@ -1304,11 +1304,15 @@
13041304
** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true.
13051305
*/
13061306
static void xfer_syncwith(const char *zUrl, int bSyncFrom){
13071307
UrlData x;
13081308
memset(&x, 0, sizeof(x));
1309
- url_parse_local(zUrl, URL_OMIT_USER, &x);
1309
+ if( fossil_strnicmp(zUrl, "http://", 7)==0
1310
+ || fossil_strnicmp(zUrl, "https://", 8)==0
1311
+ ){
1312
+ url_parse_local(zUrl, URL_OMIT_USER, &x);
1313
+ }
13101314
if( x.protocol && strncmp(x.protocol,"http",4)==0
13111315
&& x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
13121316
){
13131317
db_unprotect(PROTECT_CONFIG);
13141318
db_multi_exec("REPLACE INTO config(name,value,mtime)"
@@ -1633,12 +1637,11 @@
16331637
){
16341638
int seqno, max;
16351639
if( iVers>=3 ){
16361640
cgi_set_content_type("application/x-fossil-uncompressed");
16371641
}
1638
- blob_is_int(&xfer.aToken[2], &seqno);
1639
- if( seqno<=0 ){
1642
+ if( !blob_is_int(&xfer.aToken[2], &seqno) || seqno<=0 ){
16401643
xfer_fatal_error("invalid clone sequence number");
16411644
db_rollback_transaction();
16421645
return;
16431646
}
16441647
max = db_int(0, "SELECT max(rid) FROM blob");
@@ -2023,11 +2026,12 @@
20232026
" UNION ALL\n"
20242027
" SELECT mtime, substr(name,10), '{}' FROM config\n"
20252028
" WHERE name GLOB 'syncfrom:http*'\n"
20262029
" UNION ALL\n"
20272030
" SELECT mtime, substr(name,9), '{\"type\":\"git\"}' FROM config\n"
2028
- " WHERE name GLOB 'gitpush:*'\n"
2031
+ " WHERE name GLOB 'gitpush:http://*'\n"
2032
+ " OR name GLOB 'gitpush:https://*'\n"
20292033
")\n"
20302034
"SELECT url, json_insert(arg,'$.src',%Q), max(mtime)\n"
20312035
" FROM remote WHERE mtime>unixepoch('now','-1 month')\n"
20322036
" GROUP BY url;",
20332037
g.zBaseURL
@@ -2880,12 +2884,11 @@
28802884
** in sequence. This card indicates the sequence number of the next
28812885
** blob that needs to be sent. If N<=0 that indicates that all blobs
28822886
** have been sent.
28832887
*/
28842888
if( blob_eq(&xfer.aToken[0], "clone_seqno") && xfer.nToken==2 ){
2885
- blob_is_int(&xfer.aToken[1], &cloneSeqno);
2886
- if( cloneSeqno<0 ){
2889
+ if( !blob_is_int(&xfer.aToken[1], &cloneSeqno) ){
28872890
xfer_fatal_error("invalid clone_seqno");
28882891
return ++nErr;
28892892
}
28902893
}else
28912894
@@ -3000,11 +3003,15 @@
30003003
char *zArg = blob_str(&xfer.aToken[3]);
30013004
i64 iTime = strtoll(blob_str(&xfer.aToken[4]),0,0);
30023005
memset(&x, 0, sizeof(x));
30033006
defossilize(zUrl);
30043007
defossilize(zArg);
3005
- url_parse_local(zUrl, URL_OMIT_USER, &x);
3008
+ if( fossil_strnicmp(zUrl, "http://", 7)==0
3009
+ || fossil_strnicmp(zUrl, "https://", 8)==0
3010
+ ){
3011
+ url_parse_local(zUrl, URL_OMIT_USER, &x);
3012
+ }
30063013
if( x.protocol
30073014
&& strncmp(x.protocol,"http",4)==0
30083015
&& iTime>0
30093016
){
30103017
db_unprotect(PROTECT_CONFIG);
30113018
--- src/xfer.c
+++ src/xfer.c
@@ -1304,11 +1304,15 @@
1304 ** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true.
1305 */
1306 static void xfer_syncwith(const char *zUrl, int bSyncFrom){
1307 UrlData x;
1308 memset(&x, 0, sizeof(x));
1309 url_parse_local(zUrl, URL_OMIT_USER, &x);
 
 
 
 
1310 if( x.protocol && strncmp(x.protocol,"http",4)==0
1311 && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
1312 ){
1313 db_unprotect(PROTECT_CONFIG);
1314 db_multi_exec("REPLACE INTO config(name,value,mtime)"
@@ -1633,12 +1637,11 @@
1633 ){
1634 int seqno, max;
1635 if( iVers>=3 ){
1636 cgi_set_content_type("application/x-fossil-uncompressed");
1637 }
1638 blob_is_int(&xfer.aToken[2], &seqno);
1639 if( seqno<=0 ){
1640 xfer_fatal_error("invalid clone sequence number");
1641 db_rollback_transaction();
1642 return;
1643 }
1644 max = db_int(0, "SELECT max(rid) FROM blob");
@@ -2023,11 +2026,12 @@
2023 " UNION ALL\n"
2024 " SELECT mtime, substr(name,10), '{}' FROM config\n"
2025 " WHERE name GLOB 'syncfrom:http*'\n"
2026 " UNION ALL\n"
2027 " SELECT mtime, substr(name,9), '{\"type\":\"git\"}' FROM config\n"
2028 " WHERE name GLOB 'gitpush:*'\n"
 
2029 ")\n"
2030 "SELECT url, json_insert(arg,'$.src',%Q), max(mtime)\n"
2031 " FROM remote WHERE mtime>unixepoch('now','-1 month')\n"
2032 " GROUP BY url;",
2033 g.zBaseURL
@@ -2880,12 +2884,11 @@
2880 ** in sequence. This card indicates the sequence number of the next
2881 ** blob that needs to be sent. If N<=0 that indicates that all blobs
2882 ** have been sent.
2883 */
2884 if( blob_eq(&xfer.aToken[0], "clone_seqno") && xfer.nToken==2 ){
2885 blob_is_int(&xfer.aToken[1], &cloneSeqno);
2886 if( cloneSeqno<0 ){
2887 xfer_fatal_error("invalid clone_seqno");
2888 return ++nErr;
2889 }
2890 }else
2891
@@ -3000,11 +3003,15 @@
3000 char *zArg = blob_str(&xfer.aToken[3]);
3001 i64 iTime = strtoll(blob_str(&xfer.aToken[4]),0,0);
3002 memset(&x, 0, sizeof(x));
3003 defossilize(zUrl);
3004 defossilize(zArg);
3005 url_parse_local(zUrl, URL_OMIT_USER, &x);
 
 
 
 
3006 if( x.protocol
3007 && strncmp(x.protocol,"http",4)==0
3008 && iTime>0
3009 ){
3010 db_unprotect(PROTECT_CONFIG);
3011
--- src/xfer.c
+++ src/xfer.c
@@ -1304,11 +1304,15 @@
1304 ** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true.
1305 */
1306 static void xfer_syncwith(const char *zUrl, int bSyncFrom){
1307 UrlData x;
1308 memset(&x, 0, sizeof(x));
1309 if( fossil_strnicmp(zUrl, "http://", 7)==0
1310 || fossil_strnicmp(zUrl, "https://", 8)==0
1311 ){
1312 url_parse_local(zUrl, URL_OMIT_USER, &x);
1313 }
1314 if( x.protocol && strncmp(x.protocol,"http",4)==0
1315 && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
1316 ){
1317 db_unprotect(PROTECT_CONFIG);
1318 db_multi_exec("REPLACE INTO config(name,value,mtime)"
@@ -1633,12 +1637,11 @@
1637 ){
1638 int seqno, max;
1639 if( iVers>=3 ){
1640 cgi_set_content_type("application/x-fossil-uncompressed");
1641 }
1642 if( !blob_is_int(&xfer.aToken[2], &seqno) || seqno<=0 ){
 
1643 xfer_fatal_error("invalid clone sequence number");
1644 db_rollback_transaction();
1645 return;
1646 }
1647 max = db_int(0, "SELECT max(rid) FROM blob");
@@ -2023,11 +2026,12 @@
2026 " UNION ALL\n"
2027 " SELECT mtime, substr(name,10), '{}' FROM config\n"
2028 " WHERE name GLOB 'syncfrom:http*'\n"
2029 " UNION ALL\n"
2030 " SELECT mtime, substr(name,9), '{\"type\":\"git\"}' FROM config\n"
2031 " WHERE name GLOB 'gitpush:http://*'\n"
2032 " OR name GLOB 'gitpush:https://*'\n"
2033 ")\n"
2034 "SELECT url, json_insert(arg,'$.src',%Q), max(mtime)\n"
2035 " FROM remote WHERE mtime>unixepoch('now','-1 month')\n"
2036 " GROUP BY url;",
2037 g.zBaseURL
@@ -2880,12 +2884,11 @@
2884 ** in sequence. This card indicates the sequence number of the next
2885 ** blob that needs to be sent. If N<=0 that indicates that all blobs
2886 ** have been sent.
2887 */
2888 if( blob_eq(&xfer.aToken[0], "clone_seqno") && xfer.nToken==2 ){
2889 if( !blob_is_int(&xfer.aToken[1], &cloneSeqno) ){
 
2890 xfer_fatal_error("invalid clone_seqno");
2891 return ++nErr;
2892 }
2893 }else
2894
@@ -3000,11 +3003,15 @@
3003 char *zArg = blob_str(&xfer.aToken[3]);
3004 i64 iTime = strtoll(blob_str(&xfer.aToken[4]),0,0);
3005 memset(&x, 0, sizeof(x));
3006 defossilize(zUrl);
3007 defossilize(zArg);
3008 if( fossil_strnicmp(zUrl, "http://", 7)==0
3009 || fossil_strnicmp(zUrl, "https://", 8)==0
3010 ){
3011 url_parse_local(zUrl, URL_OMIT_USER, &x);
3012 }
3013 if( x.protocol
3014 && strncmp(x.protocol,"http",4)==0
3015 && iTime>0
3016 ){
3017 db_unprotect(PROTECT_CONFIG);
3018

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button