feat: allow dots in resource/folder names
This commit is contained in:
@@ -142,7 +142,7 @@ func (s *Server) handleFilesMkdir(w http.ResponseWriter, r *http.Request, root,
|
|||||||
}
|
}
|
||||||
name := strings.TrimSpace(r.PostForm.Get("name"))
|
name := strings.TrimSpace(r.PostForm.Get("name"))
|
||||||
if !resourceNameRe.MatchString(name) {
|
if !resourceNameRe.MatchString(name) {
|
||||||
http.Error(w, "name must be 1-64 letters, digits, '-' or '_'", http.StatusBadRequest)
|
http.Error(w, "name must be 1-64 letters, digits, dots, '-' or '_'", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import (
|
|||||||
|
|
||||||
// resourceNameRe restricts calendar/address book names to characters that
|
// resourceNameRe restricts calendar/address book names to characters that
|
||||||
// are safe as both a URL path segment and a filesystem directory name.
|
// are safe as both a URL path segment and a filesystem directory name.
|
||||||
var resourceNameRe = regexp.MustCompile(`^[a-zA-Z0-9_-]{1,64}$`)
|
// Includes dots for hidden files/folders (Unix convention).
|
||||||
|
var resourceNameRe = regexp.MustCompile(`^[a-zA-Z0-9._-]{1,64}$`)
|
||||||
|
|
||||||
// hexColorRe validates the 6-digit hex color format produced by an HTML
|
// hexColorRe validates the 6-digit hex color format produced by an HTML
|
||||||
// <input type="color">, e.g. "#3b82f6".
|
// <input type="color">, e.g. "#3b82f6".
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@
|
|||||||
void upload(Array.from(folderInput.files || []));
|
void upload(Array.from(folderInput.files || []));
|
||||||
folderInput.value = "";
|
folderInput.value = "";
|
||||||
});
|
});
|
||||||
const folderNameRe = /^[a-zA-Z0-9_-]{1,64}$/;
|
const folderNameRe = /^[a-zA-Z0-9._-]{1,64}$/;
|
||||||
newFolderButton?.addEventListener("click", async () => {
|
newFolderButton?.addEventListener("click", async () => {
|
||||||
const name = window.prompt("New folder name:");
|
const name = window.prompt("New folder name:");
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@
|
|||||||
folderInput.value = "";
|
folderInput.value = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
const folderNameRe = /^[a-zA-Z0-9_-]{1,64}$/;
|
const folderNameRe = /^[a-zA-Z0-9._-]{1,64}$/;
|
||||||
|
|
||||||
newFolderButton?.addEventListener("click", async () => {
|
newFolderButton?.addEventListener("click", async () => {
|
||||||
const name = window.prompt("New folder name:");
|
const name = window.prompt("New folder name:");
|
||||||
|
|||||||
Reference in New Issue
Block a user