Fossil SCM

Have /attachadd_ajax_post disallow size-0 attachments to match historical behavior.

stephan 2026-06-03 17:37 UTC attach-v2
Commit 4a8a290676c9c14979e361870ef3e8832a8fb18440bd4ee719b3707581a64aa2
+2 -2
--- src/attach.c
+++ src/attach.c
@@ -725,13 +725,13 @@
725725
break;
726726
}
727727
sqlite3_snprintf(sizeof(aKeySize), aKeySize, "%s:bytes",
728728
aKeyPrefix);
729729
szContent = atoi(PD(aKeySize,"-1"));
730
- if( szContent<0 ){
730
+ if( szContent<=0 ){
731731
bRollback = 1;
732
- ajax_route_error(400,"Invalid file size.");
732
+ ajax_route_error(400,"Invalid file size: %d", szContent);
733733
}else if( szLimit>0 && szContent>szLimit ){
734734
bRollback = 1;
735735
ajax_route_error(400, "File size limit is %d bytes.", szLimit);
736736
break;
737737
}else{
738738
--- src/attach.c
+++ src/attach.c
@@ -725,13 +725,13 @@
725 break;
726 }
727 sqlite3_snprintf(sizeof(aKeySize), aKeySize, "%s:bytes",
728 aKeyPrefix);
729 szContent = atoi(PD(aKeySize,"-1"));
730 if( szContent<0 ){
731 bRollback = 1;
732 ajax_route_error(400,"Invalid file size.");
733 }else if( szLimit>0 && szContent>szLimit ){
734 bRollback = 1;
735 ajax_route_error(400, "File size limit is %d bytes.", szLimit);
736 break;
737 }else{
738
--- src/attach.c
+++ src/attach.c
@@ -725,13 +725,13 @@
725 break;
726 }
727 sqlite3_snprintf(sizeof(aKeySize), aKeySize, "%s:bytes",
728 aKeyPrefix);
729 szContent = atoi(PD(aKeySize,"-1"));
730 if( szContent<=0 ){
731 bRollback = 1;
732 ajax_route_error(400,"Invalid file size: %d", szContent);
733 }else if( szLimit>0 && szContent>szLimit ){
734 bRollback = 1;
735 ajax_route_error(400, "File size limit is %d bytes.", szLimit);
736 break;
737 }else{
738
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -85,10 +85,11 @@
8585
'attach-add-button'
8686
);
8787
eBtnAdd.type = 'button';
8888
this.#e.err = D.addClass(D.div(), 'error', 'hidden');
8989
this.#e.body.append(this.#e.err);
90
+ this.#e.err.addEventListener('dblclick',()=>this.reportError());
9091
9192
const eControls = this.#e.controls =
9293
D.addClass(D.div(), 'attach-controls');
9394
eControls.append(eBtnAdd);
9495
opt.container.appendChild(this.#e.body);
@@ -423,10 +424,13 @@
423424
const eLink = D.a(F.repoUrl('help/attachment-size-limit'),'limit');
424425
eLink.addEventListener('click', ev=>ev.stopPropagation());
425426
this.#rowError(rowObj, "Too large: ", eLink,
426427
" is ",F.config.attachmentSizeLimit," bytes");
427428
rowObj.ok = false;
429
+ }else if( !file.size ){
430
+ this.#rowError(rowObj, "Cannot attach zero-byte files.");
431
+ rowObj.ok = false;
428432
}else{
429433
rowObj.ok = true;
430434
}
431435
this.#events.dispatchEvent(
432436
new CustomEvent('entry-populated',{
433437
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -85,10 +85,11 @@
85 'attach-add-button'
86 );
87 eBtnAdd.type = 'button';
88 this.#e.err = D.addClass(D.div(), 'error', 'hidden');
89 this.#e.body.append(this.#e.err);
 
90
91 const eControls = this.#e.controls =
92 D.addClass(D.div(), 'attach-controls');
93 eControls.append(eBtnAdd);
94 opt.container.appendChild(this.#e.body);
@@ -423,10 +424,13 @@
423 const eLink = D.a(F.repoUrl('help/attachment-size-limit'),'limit');
424 eLink.addEventListener('click', ev=>ev.stopPropagation());
425 this.#rowError(rowObj, "Too large: ", eLink,
426 " is ",F.config.attachmentSizeLimit," bytes");
427 rowObj.ok = false;
 
 
 
428 }else{
429 rowObj.ok = true;
430 }
431 this.#events.dispatchEvent(
432 new CustomEvent('entry-populated',{
433
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -85,10 +85,11 @@
85 'attach-add-button'
86 );
87 eBtnAdd.type = 'button';
88 this.#e.err = D.addClass(D.div(), 'error', 'hidden');
89 this.#e.body.append(this.#e.err);
90 this.#e.err.addEventListener('dblclick',()=>this.reportError());
91
92 const eControls = this.#e.controls =
93 D.addClass(D.div(), 'attach-controls');
94 eControls.append(eBtnAdd);
95 opt.container.appendChild(this.#e.body);
@@ -423,10 +424,13 @@
424 const eLink = D.a(F.repoUrl('help/attachment-size-limit'),'limit');
425 eLink.addEventListener('click', ev=>ev.stopPropagation());
426 this.#rowError(rowObj, "Too large: ", eLink,
427 " is ",F.config.attachmentSizeLimit," bytes");
428 rowObj.ok = false;
429 }else if( !file.size ){
430 this.#rowError(rowObj, "Cannot attach zero-byte files.");
431 rowObj.ok = false;
432 }else{
433 rowObj.ok = true;
434 }
435 this.#events.dispatchEvent(
436 new CustomEvent('entry-populated',{
437

Keyboard Shortcuts

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