Index: src/main.mk ================================================================== --- src/main.mk +++ src/main.mk @@ -271,10 +271,11 @@ $(SRCDIR)/sounds/f.wav \ $(SRCDIR)/style.admin_log.css \ $(SRCDIR)/style.chat.css \ $(SRCDIR)/style.fileedit.css \ $(SRCDIR)/style.pikchrshow.css \ + $(SRCDIR)/style.uvlist.css \ $(SRCDIR)/style.wikiedit.css \ $(SRCDIR)/tree.js \ $(SRCDIR)/useredit.js \ $(SRCDIR)/wiki.wiki ADDED src/style.uvlist.css Index: src/style.uvlist.css ================================================================== --- /dev/null +++ src/style.uvlist.css @@ -0,0 +1,7 @@ +body.uvlist input { + margin: 0.5em; +} + +body.uvlist form { + display: block; +} Index: src/unversioned.c ================================================================== --- src/unversioned.c +++ src/unversioned.c @@ -520,10 +520,56 @@ db_end_transaction(0); }else{ usage("add|cat|edit|export|list|revert|remove|sync|touch"); } } + +/* +** Emit an HTML form for uploading a new unversioned file if +** the current user has WrUnver permissions, else this is +** a no-op. +** +** If this function detects that the form it emits has been submitted, +** it will add the uploaded file to the unversioned file list before +** returning. +** +** Intended only for use by /uvlist, and its form's action is that +** page. +*/ +static void uvlist_upload(void){ + const char * aContent; + if( !g.perm.WrUnver ) return; + aContent = P("f"); + if( aContent!=0 ){ + const char * const zName = P("f:filename"); + int const nContent = atoi(PD("f:bytes","0")); + const char * zError = 0; + Blob content; + if( zName[0]==0 ){ + zError = "be an empty string"; + }else if( contains_whitespace(zName) ){ + zError = "contain spaces"; + } + if( zError ){ + fossil_fatal("Unversioned filenames may not %s: %Q", + zError, zName); + } + unversioned_schema(); + db_begin_transaction(); + content_rcvid_init("#!fossil /uvlist upload"); + blob_init(&content, aContent, nContent); + unversioned_write(zName, &content, time(0)); + blob_reset(&content); + db_end_transaction(0); + CX("
Added: %s
", zName); + } + form_begin("enctype='multipart/form-data'", "%R/uvlist"); + CX(""); + CX(""); + CX(""); + CX(""); +} /* ** WEBPAGE: uvlist ** ** Display a list of all unversioned files in the repository. @@ -545,10 +591,11 @@ login_check_credentials(); if( !g.perm.Read ){ login_needed(g.anon.Read); return; } cgi_check_for_malice(); etag_check(ETAG_DATA,0); style_header("Unversioned Files"); + uvlist_upload(); if( !db_table_exists("repository","unversioned") ){ @ No unversioned files on this server style_finish_page(); return; } Index: win/Makefile.mingw ================================================================== --- win/Makefile.mingw +++ win/Makefile.mingw @@ -657,10 +657,11 @@ $(SRCDIR)/sounds/f.wav \ $(SRCDIR)/style.admin_log.css \ $(SRCDIR)/style.chat.css \ $(SRCDIR)/style.fileedit.css \ $(SRCDIR)/style.pikchrshow.css \ + $(SRCDIR)/style.uvlist.css \ $(SRCDIR)/style.wikiedit.css \ $(SRCDIR)/tree.js \ $(SRCDIR)/useredit.js \ $(SRCDIR)/wiki.wiki Index: win/Makefile.msc ================================================================== --- win/Makefile.msc +++ win/Makefile.msc @@ -615,10 +615,11 @@ "$(SRCDIR)\sounds\f.wav" \ "$(SRCDIR)\style.admin_log.css" \ "$(SRCDIR)\style.chat.css" \ "$(SRCDIR)\style.fileedit.css" \ "$(SRCDIR)\style.pikchrshow.css" \ + "$(SRCDIR)\style.uvlist.css" \ "$(SRCDIR)\style.wikiedit.css" \ "$(SRCDIR)\tree.js" \ "$(SRCDIR)\useredit.js" \ "$(SRCDIR)\wiki.wiki" @@ -1244,10 +1245,11 @@ echo "$(SRCDIR)\sounds/f.wav" >> $@ echo "$(SRCDIR)\style.admin_log.css" >> $@ echo "$(SRCDIR)\style.chat.css" >> $@ echo "$(SRCDIR)\style.fileedit.css" >> $@ echo "$(SRCDIR)\style.pikchrshow.css" >> $@ + echo "$(SRCDIR)\style.uvlist.css" >> $@ echo "$(SRCDIR)\style.wikiedit.css" >> $@ echo "$(SRCDIR)\tree.js" >> $@ echo "$(SRCDIR)\useredit.js" >> $@ echo "$(SRCDIR)\wiki.wiki" >> $@ Index: www/changes.wiki ================================================================== --- www/changes.wiki +++ www/changes.wiki @@ -11,11 +11,12 @@ which is more familiar to Git users. Retain the legacy name for compatibility. * Add new query parameters to the [/help?cmd=/timeline|/timeline page]: d2=, p2=, and dp2=. * Add options to the [/help?cmd=tag|fossil tag] command that will list tag values - + * Add ability to upload unversioned files via the [/help?cmd=/uvlist|/uvlist page]. +

Changes for version 2.24 (2024-04-23)

* Apache change work-around → As part of a security fix, the Apache webserver mod_cgi module has stopped relaying the Content-Length field of the HTTP