Fossil SCM
Have /attachadd_ajax_post disallow size-0 attachments to match historical behavior.
Commit
4a8a290676c9c14979e361870ef3e8832a8fb18440bd4ee719b3707581a64aa2
Parent
41823b0aeccb85f…
2 files changed
+2
-2
+4
+2
-2
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -725,13 +725,13 @@ | ||
| 725 | 725 | break; |
| 726 | 726 | } |
| 727 | 727 | sqlite3_snprintf(sizeof(aKeySize), aKeySize, "%s:bytes", |
| 728 | 728 | aKeyPrefix); |
| 729 | 729 | szContent = atoi(PD(aKeySize,"-1")); |
| 730 | - if( szContent<0 ){ | |
| 730 | + if( szContent<=0 ){ | |
| 731 | 731 | bRollback = 1; |
| 732 | - ajax_route_error(400,"Invalid file size."); | |
| 732 | + ajax_route_error(400,"Invalid file size: %d", szContent); | |
| 733 | 733 | }else if( szLimit>0 && szContent>szLimit ){ |
| 734 | 734 | bRollback = 1; |
| 735 | 735 | ajax_route_error(400, "File size limit is %d bytes.", szLimit); |
| 736 | 736 | break; |
| 737 | 737 | }else{ |
| 738 | 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."); |
| 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 |
+4
| --- src/fossil.attach.js | ||
| +++ src/fossil.attach.js | ||
| @@ -85,10 +85,11 @@ | ||
| 85 | 85 | 'attach-add-button' |
| 86 | 86 | ); |
| 87 | 87 | eBtnAdd.type = 'button'; |
| 88 | 88 | this.#e.err = D.addClass(D.div(), 'error', 'hidden'); |
| 89 | 89 | this.#e.body.append(this.#e.err); |
| 90 | + this.#e.err.addEventListener('dblclick',()=>this.reportError()); | |
| 90 | 91 | |
| 91 | 92 | const eControls = this.#e.controls = |
| 92 | 93 | D.addClass(D.div(), 'attach-controls'); |
| 93 | 94 | eControls.append(eBtnAdd); |
| 94 | 95 | opt.container.appendChild(this.#e.body); |
| @@ -423,10 +424,13 @@ | ||
| 423 | 424 | const eLink = D.a(F.repoUrl('help/attachment-size-limit'),'limit'); |
| 424 | 425 | eLink.addEventListener('click', ev=>ev.stopPropagation()); |
| 425 | 426 | this.#rowError(rowObj, "Too large: ", eLink, |
| 426 | 427 | " is ",F.config.attachmentSizeLimit," bytes"); |
| 427 | 428 | rowObj.ok = false; |
| 429 | + }else if( !file.size ){ | |
| 430 | + this.#rowError(rowObj, "Cannot attach zero-byte files."); | |
| 431 | + rowObj.ok = false; | |
| 428 | 432 | }else{ |
| 429 | 433 | rowObj.ok = true; |
| 430 | 434 | } |
| 431 | 435 | this.#events.dispatchEvent( |
| 432 | 436 | new CustomEvent('entry-populated',{ |
| 433 | 437 |
| --- 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 |