Compare commits

...
28 Commits
Author SHA1 Message Date
Henrique Dias 7970c26cbc chore(release): 2.63.2 2026-04-11 07:56:22 +02:00
Henrique Dias 29c73eaca6 chore(release): 2.63.1 2026-04-04 22:15:49 +02:00
f13c7c8cff fix: restrict default permissions for proxy-auth auto-provisioned users (#5890)
Co-authored-by: Henrique Dias <mail@hacdias.com>
2026-04-04 22:02:34 +02:00
kodareef5andGitHub 1e03feadb5 fix: check download permission in resource handler (#5891) 2026-04-04 21:58:17 +02:00
kodareef5andGitHub 8adf127c7d fix: enforce directory boundary in rule path matching (#5889) 2026-04-04 21:57:40 +02:00
kodareef5andGitHub 7dbf7a3528 fix: check share owner permissions on public share access (#5888) 2026-04-04 21:56:55 +02:00
Henrique Dias 65a837de49 chore(release): 2.63.0 2026-04-04 10:02:07 +02:00
Ariel LeyvaandGitHub 876cdb3426 feat: enable copy operation on drag‑and‑drop with ctrl key (#5882) 2026-04-04 09:54:19 +02:00
Henrique Dias 2f805de527 docs: update docker compose 2026-04-04 09:19:09 +02:00
Ariel LeyvaandGitHub 7a16129bfc fix(tus): reject negative upload-length to prevent inconsistent cache entry (#5876) 2026-04-04 09:11:50 +02:00
Ariel LeyvaandGitHub 0f39bd055e fix: check download permission when sharing permission is enabled (#5875) 2026-04-04 09:11:21 +02:00
Henrique Dias 860c19ddf5 chore(release): 2.62.2 2026-03-28 20:02:32 +01:00
Henrique Dias a8fc1657b7 fix: shares listing 2026-03-28 20:02:12 +01:00
Henrique Dias c406bda0c7 fix: json escaping 2026-03-28 19:54:21 +01:00
Henrique Dias d9f9460c1e fix: use html/template 2026-03-28 19:16:12 +01:00
Henrique Dias 126227bb27 fix: disable scripted content in epub 2026-03-28 19:14:02 +01:00
Henrique Dias b6a4fb1f27 fix: self-registered users don't get execute perms 2026-03-28 19:08:19 +01:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2368e468b9 chore(deps): update pnpm/action-setup action to v5 (#5869)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-28 19:07:00 +01:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
8d8cd26d7f chore(deps): update all non-major dependencies (#5838)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-28 19:04:25 +01:00
lifandGitHub 8f81b77cf2 fix: include filename in Content-Disposition header for inline downloads (#5860) 2026-03-28 19:03:07 +01:00
transifex-integration[bot]GitHubtransifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
0616f6811f chore: Updates for project File Browser (#5847)
Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
2026-03-28 18:59:51 +01:00
fabbandGitHub 432f3e60ff fix: double slash in TUS upload path when readEntries returns multiple batches (#5848) 2026-03-28 18:59:28 +01:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
ae72f93667 chore(deps): update actions/deploy-pages action to v5 (#5866)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-28 18:53:12 +01:00
ArranandGitHub 4812536555 fix: touch Redis upload cache key on GetLength to prevent TTL expiry (#5850) 2026-03-26 16:27:28 +01:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
6d44b3ae1d chore(deps): update pnpm/action-setup action to v5 (#5857)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-21 07:14:02 +01:00
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
811cf2dfe5 chore(deps): update go-task/setup-task action to v2 (#5856)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-21 07:13:58 +01:00
Henrique Dias b5f970731b chore(release): 2.62.1 2026-03-14 09:31:34 +01:00
Henrique Dias fc80f4f44c fix: base url/reverse proxy redirect 2026-03-14 09:30:35 +01:00
35 changed files with 1199 additions and 589 deletions
+23 -5
View File
@@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
with:
package_json_file: "frontend/package.json"
- uses: actions/setup-node@v6
@@ -27,6 +27,24 @@ jobs:
pnpm install --frozen-lockfile
pnpm run lint
test-frontend:
name: Test Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
with:
package_json_file: "frontend/package.json"
- uses: actions/setup-node@v6
with:
node-version: "24.x"
cache: "pnpm"
cache-dependency-path: "frontend/pnpm-lock.yaml"
- working-directory: frontend
run: |
pnpm install --frozen-lockfile
pnpm run test
lint-backend:
name: Lint Backend
runs-on: ubuntu-latest
@@ -59,7 +77,7 @@ jobs:
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
with:
package_json_file: "frontend/package.json"
- uses: actions/setup-node@v6
@@ -68,7 +86,7 @@ jobs:
cache: "pnpm"
cache-dependency-path: "frontend/pnpm-lock.yaml"
- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
- run: task build
release:
@@ -83,7 +101,7 @@ jobs:
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v5
with:
package_json_file: "frontend/package.json"
- uses: actions/setup-node@v6
@@ -96,7 +114,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
- run: task build:frontend
- name: Login to Docker Hub
uses: docker/login-action@v4
+3 -3
View File
@@ -20,7 +20,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
- name: Build site
run: task docs
@@ -41,7 +41,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
- name: Build site
run: task docs
- name: Upload static files as artifact
@@ -49,4 +49,4 @@ jobs:
with:
path: www/public
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
+46
View File
@@ -2,6 +2,52 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [2.63.2](https://github.com/filebrowser/filebrowser/compare/v2.63.1...v2.63.2) (2026-04-11)
## [2.63.1](https://github.com/filebrowser/filebrowser/compare/v2.63.0...v2.63.1) (2026-04-04)
### Bug Fixes
* check download permission in resource handler ([#5891](https://github.com/filebrowser/filebrowser/issues/5891)) ([1e03fea](https://github.com/filebrowser/filebrowser/commit/1e03feadb550e4414b5589a6a8df57f538efba15))
* check share owner permissions on public share access ([#5888](https://github.com/filebrowser/filebrowser/issues/5888)) ([7dbf7a3](https://github.com/filebrowser/filebrowser/commit/7dbf7a3528234b2a9ee9c4115e8ecf58d258ca51))
* enforce directory boundary in rule path matching ([#5889](https://github.com/filebrowser/filebrowser/issues/5889)) ([8adf127](https://github.com/filebrowser/filebrowser/commit/8adf127c7d33585333b8030869f6f318e6517179))
* restrict default permissions for proxy-auth auto-provisioned users ([#5890](https://github.com/filebrowser/filebrowser/issues/5890)) ([f13c7c8](https://github.com/filebrowser/filebrowser/commit/f13c7c8cffd6d58ff29c4a6763ced1385f69961e))
## [2.63.0](https://github.com/filebrowser/filebrowser/compare/v2.62.2...v2.63.0) (2026-04-04)
### Features
* enable copy operation on drag‑and‑drop with ctrl key ([#5882](https://github.com/filebrowser/filebrowser/issues/5882)) ([876cdb3](https://github.com/filebrowser/filebrowser/commit/876cdb34265b090c2a74a69509f4106f2c5e8726))
### Bug Fixes
* check download permission when sharing permission is enabled ([#5875](https://github.com/filebrowser/filebrowser/issues/5875)) ([0f39bd0](https://github.com/filebrowser/filebrowser/commit/0f39bd055efdadc15abd2f8146cf5da3793f8318))
* **tus:** reject negative upload-length to prevent inconsistent cache entry ([#5876](https://github.com/filebrowser/filebrowser/issues/5876)) ([7a16129](https://github.com/filebrowser/filebrowser/commit/7a16129bfc07dbdc2fa52b99d2985c1bc0ea12e2))
## [2.62.2](https://github.com/filebrowser/filebrowser/compare/v2.62.1...v2.62.2) (2026-03-28)
### Bug Fixes
* disable scripted content in epub ([126227b](https://github.com/filebrowser/filebrowser/commit/126227bb2754eee15cd7c722916c3bb8821084a2))
* double slash in TUS upload path when readEntries returns multiple batches ([#5848](https://github.com/filebrowser/filebrowser/issues/5848)) ([432f3e6](https://github.com/filebrowser/filebrowser/commit/432f3e60ffdf92af6f8f56119a1bac8084f52a60))
* include filename in Content-Disposition header for inline downloads ([#5860](https://github.com/filebrowser/filebrowser/issues/5860)) ([8f81b77](https://github.com/filebrowser/filebrowser/commit/8f81b77cf2a3da0a445f3700fbf4a0091ea46c07))
* json escaping ([c406bda](https://github.com/filebrowser/filebrowser/commit/c406bda0c73ac8b187e23a97c05521edc77efa84))
* self-registered users don't get execute perms ([b6a4fb1](https://github.com/filebrowser/filebrowser/commit/b6a4fb1f27f4d894b384c0f3acacda276d1338a5))
* shares listing ([a8fc165](https://github.com/filebrowser/filebrowser/commit/a8fc1657b796c5da7190466beff13e680721b6d3))
* touch Redis upload cache key on GetLength to prevent TTL expiry ([#5850](https://github.com/filebrowser/filebrowser/issues/5850)) ([4812536](https://github.com/filebrowser/filebrowser/commit/48125365551ce2b27790aaafd7594cf5ce52f1ba))
* use html/template ([d9f9460](https://github.com/filebrowser/filebrowser/commit/d9f9460c1e51d10a25065e10358c12d5ced66ad9))
## [2.62.1](https://github.com/filebrowser/filebrowser/compare/v2.62.0...v2.62.1) (2026-03-14)
### Bug Fixes
* base url/reverse proxy redirect ([fc80f4f](https://github.com/filebrowser/filebrowser/commit/fc80f4f44c856ddc19df3024c245990fffd55630))
## [2.62.0](https://github.com/filebrowser/filebrowser/compare/v2.61.2...v2.62.0) (2026-03-14)
+3
View File
@@ -46,6 +46,9 @@ func (a ProxyAuth) createUser(usr users.Store, setting *settings.Settings, srv *
LockPassword: true,
}
setting.Defaults.Apply(user)
user.Perm.Admin = false
user.Perm.Execute = false
user.Commands = []string{}
var userHome string
userHome, err = setting.MakeUserDir(user.Username, user.Scope, srv.Root)
+79
View File
@@ -0,0 +1,79 @@
package auth
import (
"net/http"
"testing"
fberrors "github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
type mockUserStore struct {
users map[string]*users.User
}
func (m *mockUserStore) Get(_ string, id interface{}) (*users.User, error) {
if v, ok := id.(string); ok {
if u, ok := m.users[v]; ok {
return u, nil
}
}
return nil, fberrors.ErrNotExist
}
func (m *mockUserStore) Gets(_ string) ([]*users.User, error) { return nil, nil }
func (m *mockUserStore) Update(_ *users.User, _ ...string) error { return nil }
func (m *mockUserStore) Save(user *users.User) error {
m.users[user.Username] = user
return nil
}
func (m *mockUserStore) Delete(_ interface{}) error { return nil }
func (m *mockUserStore) LastUpdate(_ uint) int64 { return 0 }
func TestProxyAuthCreateUserRestrictsDefaults(t *testing.T) {
t.Parallel()
store := &mockUserStore{users: make(map[string]*users.User)}
srv := &settings.Server{Root: t.TempDir()}
s := &settings.Settings{
Key: []byte("key"),
AuthMethod: MethodProxyAuth,
Defaults: settings.UserDefaults{
Perm: users.Permissions{
Admin: true,
Execute: true,
Create: true,
Rename: true,
Modify: true,
Delete: true,
Share: true,
Download: true,
},
Commands: []string{"git", "ls", "cat", "id"},
},
}
auth := ProxyAuth{Header: "X-Remote-User"}
req, _ := http.NewRequest(http.MethodGet, "/", http.NoBody)
req.Header.Set("X-Remote-User", "newproxyuser")
user, err := auth.Auth(req, store, s, srv)
if err != nil {
t.Fatalf("Auth() error: %v", err)
}
if user.Perm.Admin {
t.Error("auto-provisioned proxy user should not have Admin permission")
}
if user.Perm.Execute {
t.Error("auto-provisioned proxy user should not have Execute permission")
}
if len(user.Commands) != 0 {
t.Errorf("auto-provisioned proxy user should have empty Commands, got %v", user.Commands)
}
if !user.Perm.Create {
t.Error("auto-provisioned proxy user should retain Create permission from defaults")
}
}
-17
View File
@@ -1,17 +0,0 @@
# Run using:
# docker compose -f compose.yaml -f compose.redis.yaml up --build
services:
redis:
container_name: redis
image: redis:latest
networks:
- filebrowser
command:
- sh
- -c
- |
cat > /tmp/users.acl <<EOF
user default on >filebrowser ~* +@all
EOF
redis-server --aclfile /tmp/users.acl
+1 -6
View File
@@ -1,12 +1,7 @@
# Run using:
# docker compose up --build
services:
filebrowser:
container_name: filebrowser
build:
dockerfile: Dockerfile
context: .
image: filebrowser/filebrowser:latest
networks:
- filebrowser
ports:
+1
View File
@@ -23,6 +23,7 @@ var (
ErrSourceIsParent = errors.New("source is parent")
ErrRootUserDeletion = errors.New("the sole admin can't be deleted")
ErrCurrentPasswordIncorrect = errors.New("the current password is incorrect")
ErrShareRequiresDownload = errors.New("permission to share requires permission to download")
)
type ErrShortPassword struct {
+4 -2
View File
@@ -14,7 +14,8 @@
"typecheck": "vue-tsc -p ./tsconfig.app.json --noEmit",
"lint": "eslint src/",
"lint:fix": "eslint --fix src/",
"format": "prettier --write ."
"format": "prettier --write .",
"test": "vitest run"
},
"dependencies": {
"@chenfengyuan/vue-number-input": "^2.0.1",
@@ -70,7 +71,8 @@
"typescript": "^5.9.3",
"vite": "^8.0.0",
"vite-plugin-compression2": "^2.3.1",
"vitest": "^4.1.0",
"vue-tsc": "^3.1.3"
},
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319"
}
+705 -508
View File
File diff suppressed because it is too large Load Diff
@@ -194,8 +194,11 @@ const drop = async (event: Event) => {
const baseItems = (await api.fetch(path)).items;
const action = (overwrite?: boolean, rename?: boolean) => {
api
.move(items, overwrite, rename)
const action =
(event as KeyboardEvent).ctrlKey || (event as KeyboardEvent).metaKey
? api.copy
: api.move;
action(items, overwrite, rename)
.then(() => {
fileStore.reload = true;
})
@@ -17,7 +17,11 @@
{{ $t("settings.perm.delete") }}
</p>
<p>
<input type="checkbox" :disabled="admin" v-model="perm.download" />
<input
type="checkbox"
:disabled="admin || perm.share"
v-model="perm.download"
/>
{{ $t("settings.perm.download") }}
</p>
<p>
@@ -61,5 +65,15 @@ export default {
},
isExecEnabled: () => enableExec,
},
watch: {
perm: {
deep: true,
handler() {
if (this.perm.share === true) {
this.perm.download = true;
}
},
},
},
};
</script>
+1 -1
View File
@@ -245,7 +245,7 @@
"execute": "Execute commands",
"modify": "Edit files",
"rename": "Rename or move files and directories",
"share": "Share files"
"share": "Share files (require download permission)"
},
"permissions": "Permissions",
"permissionsHelp": "You can set the user to be an administrator or choose the permissions individually. If you select \"Administrator\", all of the other options will be automatically checked. The management of users remains a privilege of an administrator.\n",
+21 -21
View File
@@ -42,17 +42,17 @@
"update": "Ažuriraj",
"upload": "Prenesi",
"openFile": "Otvori datoteku",
"openDirect": "View raw",
"openDirect": "Pregled neobrađenog",
"discardChanges": "Odbaci",
"stopSearch": "Stop searching",
"stopSearch": "Prestanak pretraživanja",
"saveChanges": "Spremi promjene",
"editAsText": "Uredi kao tekst",
"increaseFontSize": "Povećaj veličinu fonta",
"decreaseFontSize": "Smanji veličinu fonta",
"overrideAll": "Replace all files in destination folder",
"skipAll": "Skip all conflicting files",
"renameAll": "Rename all files (create a copy)",
"singleDecision": "Decide for each conflicting file"
"overrideAll": "Zamijeni sve datoteke u destinacijskoj mapi",
"skipAll": "Preskoči sve konfliktirajuće datoteke",
"renameAll": "Preimenuj sve datoteke (stvori kopiju)",
"singleDecision": "Odluči za svaku konfliktirajuću datoteku"
},
"download": {
"downloadFile": "Preuzmi Datoteku",
@@ -94,7 +94,7 @@
"semicolon": "Točka zarez (;)",
"both": "I (,) i (;)"
},
"fileEncoding": "File Encoding"
"fileEncoding": "Kodiranje datoteka"
},
"help": {
"click": "odaberi datoteku ili mapu",
@@ -166,18 +166,18 @@
"optionalPassword": "Opcionalna lozinka",
"resolution": "Rezolucija",
"discardEditorChanges": "Jeste li sigurni da želite odbaciti promjene koje ste napravili?",
"replaceOrSkip": "Replace or skip files",
"resolveConflict": "Which files do you want to keep?",
"singleConflictResolve": "If you select both versions, a number will be added to the name of the copied file.",
"fastConflictResolve": "The destination folder there are {count} files with same name.",
"uploadingFiles": "Uploading files",
"filesInOrigin": "Files in origin",
"filesInDest": "Files in destination",
"override": "Overwrite",
"skip": "Skip",
"forbiddenError": "Forbidden Error",
"currentPassword": "Your password",
"currentPasswordMessage": "Enter your password to validate this action."
"replaceOrSkip": "Zamijeni ili preskoči datoteke",
"resolveConflict": "Koje datoteke želite sačuvati?",
"singleConflictResolve": "Ako odaberete obje verzije, u ime kopirane datoteke bit će dodan broj.",
"fastConflictResolve": "Destinacijska mapa sadrži {count} istoimenih datoteka.",
"uploadingFiles": "Prenošenje datoteka",
"filesInOrigin": "Datoteke u izvornoj mapi",
"filesInDest": "Datoteke u destinacijskoj mapi",
"override": "Prebrisivanje",
"skip": "Preskoči",
"forbiddenError": "Greška zabrane pristupa",
"currentPassword": "Vaša lozinka",
"currentPasswordMessage": "Unesite Vašu lozinku da biste validirali ovu akciju."
},
"search": {
"images": "Slike",
@@ -250,7 +250,7 @@
"permissions": "Dopuštenja",
"permissionsHelp": "Korisnika možete postaviti administratorom ili odabrati dopuštenja individualno. Odabirom na \"Administrator\", sve druge opcije bit će automatski odabrane. Upravljanje korisnicima ostaje privilegija administratora.\n",
"profileSettings": "Postavke profila",
"redirectAfterCopyMove": "Redirect to destination after copy/move",
"redirectAfterCopyMove": "Preusmjeri na destinaciju nakon kopiranja/premještanja",
"ruleExample1": "onemogućava pristup svakoj datoteci koja započinje točkom (poput .git, .gitignore) u svakoj mapi.\n",
"ruleExample2": "blokira pristup datoteci naziva Caddyfile na korijenu opsega.",
"rules": "Pravila",
@@ -278,7 +278,7 @@
"userUpdated": "Korisnik ažuriran!",
"username": "Korisničko ime",
"users": "Korisnici",
"currentPassword": "Your Current Password"
"currentPassword": "Vaša trenutna lozinka"
},
"sidebar": {
"help": "Pomoć",
+2 -2
View File
@@ -176,8 +176,8 @@
"override": "덮어쓰기",
"skip": "건너뛰기",
"forbiddenError": "권한 오류",
"currentPassword": "Your password",
"currentPasswordMessage": "Enter your password to validate this action."
"currentPassword": "기존 비밀번호",
"currentPasswordMessage": "기존 비밀번호를 입력해 이 동작을 확인하십시오."
},
"search": {
"images": "이미지",
+3 -3
View File
@@ -100,7 +100,7 @@
"click": "seleccionar ficheiro ou pasta",
"ctrl": {
"click": "seleccionar vários ficheiros e pastas",
"f": "opens search",
"f": "abre a pesquisa",
"s": "guarda um ficheiro ou descarrega a pasta onde estiver"
},
"del": "elimina os itens seleccionados",
@@ -145,7 +145,7 @@
"lastModified": "última modificação",
"move": "Mover",
"moveMessage": "Escolha uma nova casa para o(s) seu(s) ficheiro(s)/pasta(s):",
"newArchetype": "Escolha um novo post baseado no archetype. O seu ficheiro irá criado no conteúdo da pasta.",
"newArchetype": "Criar uma nova publicação baseado no archetype. O seu ficheiro irá ser criado no conteúdo da pasta.",
"newDir": "Nova pasta",
"newDirMessage": "Nomeie a sua nova pasta.",
"newFile": "Novo ficheiro",
@@ -157,7 +157,7 @@
"replace": "Substituir",
"replaceMessage": "Um dos ficheiros que está a tentar enviar tem um nome em conflito. Quer ignorar este ficheiro e continuar a enviar ou substituir o existente?\none?\n",
"schedule": "Agendar",
"scheduleMessage": "Escolha a data e hora para agendar a autenticação desta publicação.",
"scheduleMessage": "Escolha a data e hora para agendar a publicação desta publicação.",
"show": "Mostrar",
"size": "Tamanho",
"upload": "Enviar",
@@ -0,0 +1,80 @@
import { describe, it, expect } from "vitest";
/**
* Reproduces the path-building logic from scanFiles() in upload.ts (lines 118-138).
*
* readReaderContent() is called when traversing a dropped folder. The browser's
* FileSystemDirectoryReader.readEntries() returns entries in batches — you must
* call it repeatedly until it returns an empty array. Each recursive call in the
* current code appends "/" to the directory, so the second batch and beyond get
* double (or triple, etc.) slashes in the constructed fullPath.
*/
type Entry = { name: string; isFile: boolean; isDirectory: boolean };
function simulateScanFiles(
dirName: string,
entryBatches: Entry[][]
): string[] {
const paths: string[] = [];
let batchIndex = 0;
// Mirrors readEntry() for files — records fullPath as `${directory}${file.name}`
function readEntry(entry: Entry, directory = ""): void {
if (entry.isFile) {
paths.push(`${directory}${entry.name}`);
}
}
// Mirrors readReaderContent() from upload.ts lines 118-138
function readReaderContent(directory: string): void {
const entries = batchIndex < entryBatches.length ? entryBatches[batchIndex] : [];
batchIndex++;
if (entries.length > 0) {
const dirWithSlash = directory.endsWith("/")
? directory
: `${directory}/`;
for (const entry of entries) {
readEntry(entry, dirWithSlash);
}
readReaderContent(dirWithSlash);
}
}
// Initial call mirrors readEntry() for a directory — upload.ts line 111-114
readReaderContent(dirName);
return paths;
}
describe("scanFiles path construction", () => {
it("should not produce double slashes when readEntries returns multiple batches", () => {
// Two batches: simulates a large directory where the browser splits
// readEntries() results across multiple calls
const paths = simulateScanFiles("TestFolder", [
[
{ name: "file1.xlsx", isFile: true, isDirectory: false },
{ name: "file2.xlsx", isFile: true, isDirectory: false },
],
[
{ name: "file3.xlsx", isFile: true, isDirectory: false },
],
]);
expect(paths).toHaveLength(3);
for (const p of paths) {
expect(p, `path "${p}" contains double slash`).not.toContain("//");
}
});
it("single batch should work fine (no regression)", () => {
const paths = simulateScanFiles("TestFolder", [
[
{ name: "file1.xlsx", isFile: true, isDirectory: false },
],
]);
expect(paths).toEqual(["TestFolder/file1.xlsx"]);
});
});
+5 -2
View File
@@ -124,11 +124,14 @@ export function scanFiles(dt: DataTransfer): Promise<UploadList | FileList> {
reader.readEntries((entries) => {
reading--;
if (entries.length > 0) {
const dirWithSlash = directory.endsWith("/")
? directory
: `${directory}/`;
for (const entry of entries) {
readEntry(entry, `${directory}/`);
readEntry(entry, dirWithSlash);
}
readReaderContent(reader, `${directory}/`);
readReaderContent(reader, dirWithSlash);
}
if (reading === 0) {
-1
View File
@@ -84,7 +84,6 @@
}"
:epubOptions="{
allowPopups: true,
allowScriptedContent: true,
}"
@update:location="locationChange"
/>
+1 -1
View File
@@ -27,7 +27,7 @@ require (
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
go.etcd.io/bbolt v1.4.3
golang.org/x/crypto v0.49.0
golang.org/x/image v0.37.0
golang.org/x/image v0.38.0
golang.org/x/text v0.35.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
+2 -2
View File
@@ -296,8 +296,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.37.0 h1:ZiRjArKI8GwxZOoEtUfhrBtaCN+4b/7709dlT6SSnQA=
golang.org/x/image v0.37.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
golang.org/x/image v0.38.0 h1:5l+q+Y9JDC7mBOMjo4/aPhMDcxEptsX+Tt3GgRQRPuE=
golang.org/x/image v0.38.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+6
View File
@@ -171,6 +171,12 @@ var signupHandler = func(_ http.ResponseWriter, r *http.Request, d *data) (int,
// if that is the default permission.
user.Perm.Admin = false
// Self-registered users should not inherit execution capabilities from
// default settings, regardless of what the administrator has configured
// as the default. Execution rights must be explicitly granted by an admin.
user.Perm.Execute = false
user.Commands = []string{}
pwd, err := users.ValidateAndHashPwd(info.Password, d.settings.MinimumPasswordLength)
if err != nil {
return http.StatusBadRequest, err
+1 -1
View File
@@ -70,7 +70,7 @@ func NewHandler(
api.PathPrefix("/usage").Handler(monkey(diskUsage, "/api/usage")).Methods("GET")
api.Path("/shares").Handler(monkey(shareListHandler, "/api/shares")).Methods("GET")
api.Handle("/shares", monkey(shareListHandler, "")).Methods("GET")
api.PathPrefix("/share").Handler(monkey(shareGetsHandler, "/api/share")).Methods("GET")
api.PathPrefix("/share").Handler(monkey(sharePostHandler, "/api/share")).Methods("POST")
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
+4
View File
@@ -33,6 +33,10 @@ var withHashFile = func(fn handleFunc) handleFunc {
return errToStatus(err), err
}
if !user.Perm.Share || !user.Perm.Download {
return http.StatusForbidden, nil
}
d.user = user
file, err := files.NewFileInfo(&files.FileOptions{
+36 -1
View File
@@ -23,38 +23,66 @@ func TestPublicShareHandlerAuthentication(t *testing.T) {
testCases := map[string]struct {
share *share.Link
req *http.Request
sharePerm bool
downloadPerm bool
expectedStatusCode int
}{
"Public share, no auth required": {
share: &share.Link{Hash: "h", UserID: 1},
req: newHTTPRequest(t),
sharePerm: true,
downloadPerm: true,
expectedStatusCode: 200,
},
"Private share, no auth provided, 401": {
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
req: newHTTPRequest(t),
sharePerm: true,
downloadPerm: true,
expectedStatusCode: 401,
},
"Private share, authentication via token": {
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
req: newHTTPRequest(t, func(r *http.Request) { r.URL.RawQuery = "token=123" }),
sharePerm: true,
downloadPerm: true,
expectedStatusCode: 200,
},
"Private share, authentication via invalid token, 401": {
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
req: newHTTPRequest(t, func(r *http.Request) { r.URL.RawQuery = "token=1234" }),
sharePerm: true,
downloadPerm: true,
expectedStatusCode: 401,
},
"Private share, authentication via password": {
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
req: newHTTPRequest(t, func(r *http.Request) { r.Header.Set("X-SHARE-PASSWORD", "password") }),
sharePerm: true,
downloadPerm: true,
expectedStatusCode: 200,
},
"Private share, authentication via invalid password, 401": {
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
req: newHTTPRequest(t, func(r *http.Request) { r.Header.Set("X-SHARE-PASSWORD", "wrong-password") }),
sharePerm: true,
downloadPerm: true,
expectedStatusCode: 401,
},
"Share owner lost share permission, 403": {
share: &share.Link{Hash: "h", UserID: 1},
req: newHTTPRequest(t),
sharePerm: false,
downloadPerm: true,
expectedStatusCode: 403,
},
"Share owner lost download permission, 403": {
share: &share.Link{Hash: "h", UserID: 1},
req: newHTTPRequest(t),
sharePerm: true,
downloadPerm: false,
expectedStatusCode: 403,
},
}
for name, tc := range testCases {
@@ -82,7 +110,14 @@ func TestPublicShareHandlerAuthentication(t *testing.T) {
if err := storage.Share.Save(tc.share); err != nil {
t.Fatalf("failed to save share: %v", err)
}
if err := storage.Users.Save(&users.User{Username: "username", Password: "pw"}); err != nil {
if err := storage.Users.Save(&users.User{
Username: "username",
Password: "pw",
Perm: users.Permissions{
Share: tc.sharePerm,
Download: tc.downloadPerm,
},
}); err != nil {
t.Fatalf("failed to save user: %v", err)
}
if err := storage.Settings.Save(&settings.Settings{Key: []byte("key")}); err != nil {
+2 -1
View File
@@ -72,7 +72,8 @@ func parseQueryAlgorithm(r *http.Request) (string, archives.Archival, error) {
func setContentDisposition(w http.ResponseWriter, r *http.Request, file *files.FileInfo) {
if r.URL.Query().Get("inline") == "true" {
w.Header().Set("Content-Disposition", "inline")
// As per RFC6266 section 4.3
w.Header().Set("Content-Disposition", "inline; filename*=utf-8''"+url.PathEscape(file.Name))
} else {
// As per RFC6266 section 4.3
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(file.Name))
+75
View File
@@ -0,0 +1,75 @@
package fbhttp
import (
"net/http"
"net/http/httptest"
"net/url"
"testing"
"github.com/filebrowser/filebrowser/v2/files"
)
func TestSetContentDisposition(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
filename string
inline bool
expected string
}{
"inline simple filename": {
filename: "document.pdf",
inline: true,
expected: "inline; filename*=utf-8''" + url.PathEscape("document.pdf"),
},
"attachment simple filename": {
filename: "document.pdf",
inline: false,
expected: "attachment; filename*=utf-8''" + url.PathEscape("document.pdf"),
},
"inline non-ASCII filename": {
filename: "日本語.txt",
inline: true,
expected: "inline; filename*=utf-8''" + url.PathEscape("日本語.txt"),
},
"attachment non-ASCII filename": {
filename: "日本語.txt",
inline: false,
expected: "attachment; filename*=utf-8''" + url.PathEscape("日本語.txt"),
},
"inline filename with spaces": {
filename: "my file.txt",
inline: true,
expected: "inline; filename*=utf-8''" + url.PathEscape("my file.txt"),
},
"attachment filename with spaces": {
filename: "my file.txt",
inline: false,
expected: "attachment; filename*=utf-8''" + url.PathEscape("my file.txt"),
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()
recorder := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/test", http.NoBody)
if err != nil {
t.Fatalf("failed to create request: %v", err)
}
if tc.inline {
req.URL.RawQuery = "inline=true"
}
file := &files.FileInfo{Name: tc.filename}
setContentDisposition(recorder, req, file)
got := recorder.Header().Get("Content-Disposition")
if got != tc.expected {
t.Errorf("Content-Disposition = %q, want %q", got, tc.expected)
}
})
}
}
+4 -1
View File
@@ -30,7 +30,7 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
Expand: true,
ReadHeader: d.server.TypeDetectionByHeader,
Checker: d,
Content: true,
Content: d.user.Perm.Download,
})
if err != nil {
return errToStatus(err), err
@@ -42,6 +42,9 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
file.ApplySort()
return renderJSON(w, r, file)
} else if encoding == "true" {
if !d.user.Perm.Download {
return http.StatusAccepted, nil
}
if file.Type != "text" {
return renderJSON(w, r, file)
}
+6 -6
View File
@@ -1,19 +1,19 @@
package fbhttp
import (
"compress/gzip"
"encoding/json"
"errors"
"fmt"
"io/fs"
"html/template"
"io"
"compress/gzip"
"io/fs"
"log"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"text/template"
"github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/settings"
@@ -85,7 +85,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, fSys
return http.StatusInternalServerError, err
}
data["Json"] = strings.ReplaceAll(string(b), `'`, `\'`)
data["Json"] = template.JS(strings.ReplaceAll(string(b), `'`, `\'`))
fileContents, err := fs.ReadFile(fSys, file)
if err != nil {
@@ -153,7 +153,7 @@ func getStaticHandlers(store *storage.Storage, server *settings.Server, assetsFs
defer f.Close()
acceptEncoding := r.Header.Get("Accept-Encoding")
if strings.Contains(acceptEncoding, "gzip") {
if strings.Contains(acceptEncoding, "gzip") {
w.Header().Set("Content-Encoding", "gzip")
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
@@ -168,7 +168,7 @@ func getStaticHandlers(store *storage.Storage, server *settings.Server, assetsFs
defer gzReader.Close()
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
if _, err := io.Copy(w, gzReader); err != nil {
return http.StatusInternalServerError, err
}
+1 -1
View File
@@ -105,7 +105,7 @@ func tusPostHandler(cache UploadCache) handleFunc {
}
uploadLength, err := getUploadLength(r)
if err != nil {
if err != nil || uploadLength < 0 {
return http.StatusBadRequest, fmt.Errorf("invalid upload length: %w", err)
}
+2
View File
@@ -67,6 +67,8 @@ func (c *redisUploadCache) GetLength(filePath string) (int64, error) {
return 0, fmt.Errorf("invalid upload length in cache: %w", err)
}
c.Touch(filePath)
return size, nil
}
+12
View File
@@ -156,6 +156,10 @@ var userPostHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *
return http.StatusBadRequest, err
}
if req.Data.Perm.Share && !req.Data.Perm.Download {
return http.StatusBadRequest, fberrors.ErrShareRequiresDownload
}
userHome, err := d.settings.MakeUserDir(req.Data.Username, req.Data.Scope, d.server.Root)
if err != nil {
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
@@ -204,6 +208,14 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
return http.StatusBadRequest, nil
}
for _, field := range req.Which {
if strings.ToLower(field) == "perm" || strings.ToLower(field) == "all" {
if req.Data.Perm.Share && !req.Data.Perm.Download {
return http.StatusBadRequest, fberrors.ErrShareRequiresDownload
}
}
}
if len(req.Which) == 0 || (len(req.Which) == 1 && req.Which[0] == "all") {
if !d.user.Perm.Admin {
return http.StatusForbidden, nil
+9
View File
@@ -60,6 +60,15 @@ func stripPrefix(prefix string, h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
p := strings.TrimPrefix(r.URL.Path, prefix)
rp := strings.TrimPrefix(r.URL.RawPath, prefix)
// If the path is exactly the prefix (no trailing slash), redirect to
// the prefix with a trailing slash so the router receives "/" instead
// of "", which would otherwise cause a redirect to the site root.
if p == "" {
http.Redirect(w, r, prefix+"/", http.StatusMovedPermanently)
return
}
r2 := new(http.Request)
*r2 = *r
r2.URL = new(url.URL)
+10 -1
View File
@@ -31,7 +31,16 @@ func (r *Rule) Matches(path string) bool {
return r.Regexp.MatchString(path)
}
return strings.HasPrefix(path, r.Path)
if path == r.Path {
return true
}
prefix := r.Path
if prefix != "/" && !strings.HasSuffix(prefix, "/") {
prefix += "/"
}
return strings.HasPrefix(path, prefix)
}
// Regexp is a wrapper to the native regexp type where we
+31
View File
@@ -2,6 +2,37 @@ package rules
import "testing"
func TestRuleMatches(t *testing.T) {
t.Parallel()
cases := []struct {
name string
rulePath string
testPath string
want bool
}{
{"exact match", "/uploads", "/uploads", true},
{"child path", "/uploads", "/uploads/file.txt", true},
{"sibling prefix", "/uploads", "/uploads_backup/secret.txt", false},
{"root rule", "/", "/anything", true},
{"trailing slash rule", "/uploads/", "/uploads/file.txt", true},
{"trailing slash no sibling", "/uploads/", "/uploads_backup/file.txt", false},
{"nested child", "/data/shared", "/data/shared/docs/file.txt", true},
{"nested sibling", "/data/shared", "/data/shared_private/file.txt", false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
r := &Rule{Path: tc.rulePath}
got := r.Matches(tc.testPath)
if got != tc.want {
t.Errorf("Rule{Path: %q}.Matches(%q) = %v; want %v", tc.rulePath, tc.testPath, got, tc.want)
}
})
}
}
func TestMatchHidden(t *testing.T) {
cases := map[string]bool{
"/": false,