Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7970c26cbc | ||
|
|
29c73eaca6 | ||
|
|
f13c7c8cff | ||
|
|
1e03feadb5 | ||
|
|
8adf127c7d | ||
|
|
7dbf7a3528 | ||
|
|
65a837de49 | ||
|
|
876cdb3426 | ||
|
|
2f805de527 | ||
|
|
7a16129bfc | ||
|
|
0f39bd055e | ||
|
|
860c19ddf5 | ||
|
|
a8fc1657b7 | ||
|
|
c406bda0c7 | ||
|
|
d9f9460c1e | ||
|
|
126227bb27 | ||
|
|
b6a4fb1f27 | ||
|
|
2368e468b9 | ||
|
|
8d8cd26d7f | ||
|
|
8f81b77cf2 | ||
|
|
0616f6811f | ||
|
|
432f3e60ff | ||
|
|
ae72f93667 | ||
|
|
4812536555 | ||
|
|
6d44b3ae1d | ||
|
|
811cf2dfe5 |
No files matched your search
@@ -14,7 +14,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v5
|
||||||
with:
|
with:
|
||||||
package_json_file: "frontend/package.json"
|
package_json_file: "frontend/package.json"
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
@@ -27,6 +27,24 @@ jobs:
|
|||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
pnpm run lint
|
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:
|
lint-backend:
|
||||||
name: Lint Backend
|
name: Lint Backend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -59,7 +77,7 @@ jobs:
|
|||||||
- uses: actions/setup-go@v6
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: '1.26'
|
go-version: '1.26'
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v5
|
||||||
with:
|
with:
|
||||||
package_json_file: "frontend/package.json"
|
package_json_file: "frontend/package.json"
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
@@ -68,7 +86,7 @@ jobs:
|
|||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
cache-dependency-path: "frontend/pnpm-lock.yaml"
|
cache-dependency-path: "frontend/pnpm-lock.yaml"
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: go-task/setup-task@v1
|
uses: go-task/setup-task@v2
|
||||||
- run: task build
|
- run: task build
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@@ -83,7 +101,7 @@ jobs:
|
|||||||
- uses: actions/setup-go@v6
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: '1.26'
|
go-version: '1.26'
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v5
|
||||||
with:
|
with:
|
||||||
package_json_file: "frontend/package.json"
|
package_json_file: "frontend/package.json"
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
@@ -96,7 +114,7 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: go-task/setup-task@v1
|
uses: go-task/setup-task@v2
|
||||||
- run: task build:frontend
|
- run: task build:frontend
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: go-task/setup-task@v1
|
uses: go-task/setup-task@v2
|
||||||
- name: Build site
|
- name: Build site
|
||||||
run: task docs
|
run: task docs
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: go-task/setup-task@v1
|
uses: go-task/setup-task@v2
|
||||||
- name: Build site
|
- name: Build site
|
||||||
run: task docs
|
run: task docs
|
||||||
- name: Upload static files as artifact
|
- name: Upload static files as artifact
|
||||||
@@ -49,4 +49,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
path: www/public
|
path: www/public
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
uses: actions/deploy-pages@v4
|
uses: actions/deploy-pages@v5
|
||||||
@@ -2,6 +2,45 @@
|
|||||||
|
|
||||||
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.
|
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)
|
## [2.62.1](https://github.com/filebrowser/filebrowser/compare/v2.62.0...v2.62.1) (2026-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ func (a ProxyAuth) createUser(usr users.Store, setting *settings.Settings, srv *
|
|||||||
LockPassword: true,
|
LockPassword: true,
|
||||||
}
|
}
|
||||||
setting.Defaults.Apply(user)
|
setting.Defaults.Apply(user)
|
||||||
|
user.Perm.Admin = false
|
||||||
|
user.Perm.Execute = false
|
||||||
|
user.Commands = []string{}
|
||||||
|
|
||||||
var userHome string
|
var userHome string
|
||||||
userHome, err = setting.MakeUserDir(user.Username, user.Scope, srv.Root)
|
userHome, err = setting.MakeUserDir(user.Username, user.Scope, srv.Root)
|
||||||
|
|||||||
@@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
@@ -1,12 +1,7 @@
|
|||||||
# Run using:
|
|
||||||
# docker compose up --build
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
filebrowser:
|
filebrowser:
|
||||||
container_name: filebrowser
|
container_name: filebrowser
|
||||||
build:
|
image: filebrowser/filebrowser:latest
|
||||||
dockerfile: Dockerfile
|
|
||||||
context: .
|
|
||||||
networks:
|
networks:
|
||||||
- filebrowser
|
- filebrowser
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ var (
|
|||||||
ErrSourceIsParent = errors.New("source is parent")
|
ErrSourceIsParent = errors.New("source is parent")
|
||||||
ErrRootUserDeletion = errors.New("the sole admin can't be deleted")
|
ErrRootUserDeletion = errors.New("the sole admin can't be deleted")
|
||||||
ErrCurrentPasswordIncorrect = errors.New("the current password is incorrect")
|
ErrCurrentPasswordIncorrect = errors.New("the current password is incorrect")
|
||||||
|
ErrShareRequiresDownload = errors.New("permission to share requires permission to download")
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrShortPassword struct {
|
type ErrShortPassword struct {
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
"typecheck": "vue-tsc -p ./tsconfig.app.json --noEmit",
|
"typecheck": "vue-tsc -p ./tsconfig.app.json --noEmit",
|
||||||
"lint": "eslint src/",
|
"lint": "eslint src/",
|
||||||
"lint:fix": "eslint --fix src/",
|
"lint:fix": "eslint --fix src/",
|
||||||
"format": "prettier --write ."
|
"format": "prettier --write .",
|
||||||
|
"test": "vitest run"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chenfengyuan/vue-number-input": "^2.0.1",
|
"@chenfengyuan/vue-number-input": "^2.0.1",
|
||||||
@@ -70,7 +71,8 @@
|
|||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^8.0.0",
|
"vite": "^8.0.0",
|
||||||
"vite-plugin-compression2": "^2.3.1",
|
"vite-plugin-compression2": "^2.3.1",
|
||||||
|
"vitest": "^4.1.0",
|
||||||
"vue-tsc": "^3.1.3"
|
"vue-tsc": "^3.1.3"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
|
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319"
|
||||||
}
|
}
|
||||||
Generated
+705
-508
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 baseItems = (await api.fetch(path)).items;
|
||||||
|
|
||||||
const action = (overwrite?: boolean, rename?: boolean) => {
|
const action = (overwrite?: boolean, rename?: boolean) => {
|
||||||
api
|
const action =
|
||||||
.move(items, overwrite, rename)
|
(event as KeyboardEvent).ctrlKey || (event as KeyboardEvent).metaKey
|
||||||
|
? api.copy
|
||||||
|
: api.move;
|
||||||
|
action(items, overwrite, rename)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fileStore.reload = true;
|
fileStore.reload = true;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
{{ $t("settings.perm.delete") }}
|
{{ $t("settings.perm.delete") }}
|
||||||
</p>
|
</p>
|
||||||
<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") }}
|
{{ $t("settings.perm.download") }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -61,5 +65,15 @@ export default {
|
|||||||
},
|
},
|
||||||
isExecEnabled: () => enableExec,
|
isExecEnabled: () => enableExec,
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
perm: {
|
||||||
|
deep: true,
|
||||||
|
handler() {
|
||||||
|
if (this.perm.share === true) {
|
||||||
|
this.perm.download = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -245,7 +245,7 @@
|
|||||||
"execute": "Execute commands",
|
"execute": "Execute commands",
|
||||||
"modify": "Edit files",
|
"modify": "Edit files",
|
||||||
"rename": "Rename or move files and directories",
|
"rename": "Rename or move files and directories",
|
||||||
"share": "Share files"
|
"share": "Share files (require download permission)"
|
||||||
},
|
},
|
||||||
"permissions": "Permissions",
|
"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",
|
"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
@@ -42,17 +42,17 @@
|
|||||||
"update": "Ažuriraj",
|
"update": "Ažuriraj",
|
||||||
"upload": "Prenesi",
|
"upload": "Prenesi",
|
||||||
"openFile": "Otvori datoteku",
|
"openFile": "Otvori datoteku",
|
||||||
"openDirect": "View raw",
|
"openDirect": "Pregled neobrađenog",
|
||||||
"discardChanges": "Odbaci",
|
"discardChanges": "Odbaci",
|
||||||
"stopSearch": "Stop searching",
|
"stopSearch": "Prestanak pretraživanja",
|
||||||
"saveChanges": "Spremi promjene",
|
"saveChanges": "Spremi promjene",
|
||||||
"editAsText": "Uredi kao tekst",
|
"editAsText": "Uredi kao tekst",
|
||||||
"increaseFontSize": "Povećaj veličinu fonta",
|
"increaseFontSize": "Povećaj veličinu fonta",
|
||||||
"decreaseFontSize": "Smanji veličinu fonta",
|
"decreaseFontSize": "Smanji veličinu fonta",
|
||||||
"overrideAll": "Replace all files in destination folder",
|
"overrideAll": "Zamijeni sve datoteke u destinacijskoj mapi",
|
||||||
"skipAll": "Skip all conflicting files",
|
"skipAll": "Preskoči sve konfliktirajuće datoteke",
|
||||||
"renameAll": "Rename all files (create a copy)",
|
"renameAll": "Preimenuj sve datoteke (stvori kopiju)",
|
||||||
"singleDecision": "Decide for each conflicting file"
|
"singleDecision": "Odluči za svaku konfliktirajuću datoteku"
|
||||||
},
|
},
|
||||||
"download": {
|
"download": {
|
||||||
"downloadFile": "Preuzmi Datoteku",
|
"downloadFile": "Preuzmi Datoteku",
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
"semicolon": "Točka zarez (;)",
|
"semicolon": "Točka zarez (;)",
|
||||||
"both": "I (,) i (;)"
|
"both": "I (,) i (;)"
|
||||||
},
|
},
|
||||||
"fileEncoding": "File Encoding"
|
"fileEncoding": "Kodiranje datoteka"
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"click": "odaberi datoteku ili mapu",
|
"click": "odaberi datoteku ili mapu",
|
||||||
@@ -166,18 +166,18 @@
|
|||||||
"optionalPassword": "Opcionalna lozinka",
|
"optionalPassword": "Opcionalna lozinka",
|
||||||
"resolution": "Rezolucija",
|
"resolution": "Rezolucija",
|
||||||
"discardEditorChanges": "Jeste li sigurni da želite odbaciti promjene koje ste napravili?",
|
"discardEditorChanges": "Jeste li sigurni da želite odbaciti promjene koje ste napravili?",
|
||||||
"replaceOrSkip": "Replace or skip files",
|
"replaceOrSkip": "Zamijeni ili preskoči datoteke",
|
||||||
"resolveConflict": "Which files do you want to keep?",
|
"resolveConflict": "Koje datoteke želite sačuvati?",
|
||||||
"singleConflictResolve": "If you select both versions, a number will be added to the name of the copied file.",
|
"singleConflictResolve": "Ako odaberete obje verzije, u ime kopirane datoteke bit će dodan broj.",
|
||||||
"fastConflictResolve": "The destination folder there are {count} files with same name.",
|
"fastConflictResolve": "Destinacijska mapa sadrži {count} istoimenih datoteka.",
|
||||||
"uploadingFiles": "Uploading files",
|
"uploadingFiles": "Prenošenje datoteka",
|
||||||
"filesInOrigin": "Files in origin",
|
"filesInOrigin": "Datoteke u izvornoj mapi",
|
||||||
"filesInDest": "Files in destination",
|
"filesInDest": "Datoteke u destinacijskoj mapi",
|
||||||
"override": "Overwrite",
|
"override": "Prebrisivanje",
|
||||||
"skip": "Skip",
|
"skip": "Preskoči",
|
||||||
"forbiddenError": "Forbidden Error",
|
"forbiddenError": "Greška zabrane pristupa",
|
||||||
"currentPassword": "Your password",
|
"currentPassword": "Vaša lozinka",
|
||||||
"currentPasswordMessage": "Enter your password to validate this action."
|
"currentPasswordMessage": "Unesite Vašu lozinku da biste validirali ovu akciju."
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"images": "Slike",
|
"images": "Slike",
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
"permissions": "Dopuštenja",
|
"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",
|
"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",
|
"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",
|
"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.",
|
"ruleExample2": "blokira pristup datoteci naziva Caddyfile na korijenu opsega.",
|
||||||
"rules": "Pravila",
|
"rules": "Pravila",
|
||||||
@@ -278,7 +278,7 @@
|
|||||||
"userUpdated": "Korisnik ažuriran!",
|
"userUpdated": "Korisnik ažuriran!",
|
||||||
"username": "Korisničko ime",
|
"username": "Korisničko ime",
|
||||||
"users": "Korisnici",
|
"users": "Korisnici",
|
||||||
"currentPassword": "Your Current Password"
|
"currentPassword": "Vaša trenutna lozinka"
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"help": "Pomoć",
|
"help": "Pomoć",
|
||||||
|
|||||||
@@ -176,8 +176,8 @@
|
|||||||
"override": "덮어쓰기",
|
"override": "덮어쓰기",
|
||||||
"skip": "건너뛰기",
|
"skip": "건너뛰기",
|
||||||
"forbiddenError": "권한 오류",
|
"forbiddenError": "권한 오류",
|
||||||
"currentPassword": "Your password",
|
"currentPassword": "기존 비밀번호",
|
||||||
"currentPasswordMessage": "Enter your password to validate this action."
|
"currentPasswordMessage": "기존 비밀번호를 입력해 이 동작을 확인하십시오."
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"images": "이미지",
|
"images": "이미지",
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
"click": "seleccionar ficheiro ou pasta",
|
"click": "seleccionar ficheiro ou pasta",
|
||||||
"ctrl": {
|
"ctrl": {
|
||||||
"click": "seleccionar vários ficheiros e pastas",
|
"click": "seleccionar vários ficheiros e pastas",
|
||||||
"f": "opens search",
|
"f": "abre a pesquisa",
|
||||||
"s": "guarda um ficheiro ou descarrega a pasta onde estiver"
|
"s": "guarda um ficheiro ou descarrega a pasta onde estiver"
|
||||||
},
|
},
|
||||||
"del": "elimina os itens seleccionados",
|
"del": "elimina os itens seleccionados",
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
"lastModified": "última modificação",
|
"lastModified": "última modificação",
|
||||||
"move": "Mover",
|
"move": "Mover",
|
||||||
"moveMessage": "Escolha uma nova casa para o(s) seu(s) ficheiro(s)/pasta(s):",
|
"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",
|
"newDir": "Nova pasta",
|
||||||
"newDirMessage": "Nomeie a sua nova pasta.",
|
"newDirMessage": "Nomeie a sua nova pasta.",
|
||||||
"newFile": "Novo ficheiro",
|
"newFile": "Novo ficheiro",
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
"replace": "Substituir",
|
"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",
|
"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",
|
"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",
|
"show": "Mostrar",
|
||||||
"size": "Tamanho",
|
"size": "Tamanho",
|
||||||
"upload": "Enviar",
|
"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"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -124,11 +124,14 @@ export function scanFiles(dt: DataTransfer): Promise<UploadList | FileList> {
|
|||||||
reader.readEntries((entries) => {
|
reader.readEntries((entries) => {
|
||||||
reading--;
|
reading--;
|
||||||
if (entries.length > 0) {
|
if (entries.length > 0) {
|
||||||
|
const dirWithSlash = directory.endsWith("/")
|
||||||
|
? directory
|
||||||
|
: `${directory}/`;
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
readEntry(entry, `${directory}/`);
|
readEntry(entry, dirWithSlash);
|
||||||
}
|
}
|
||||||
|
|
||||||
readReaderContent(reader, `${directory}/`);
|
readReaderContent(reader, dirWithSlash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reading === 0) {
|
if (reading === 0) {
|
||||||
|
|||||||
@@ -84,7 +84,6 @@
|
|||||||
}"
|
}"
|
||||||
:epubOptions="{
|
:epubOptions="{
|
||||||
allowPopups: true,
|
allowPopups: true,
|
||||||
allowScriptedContent: true,
|
|
||||||
}"
|
}"
|
||||||
@update:location="locationChange"
|
@update:location="locationChange"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ require (
|
|||||||
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
|
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
|
||||||
go.etcd.io/bbolt v1.4.3
|
go.etcd.io/bbolt v1.4.3
|
||||||
golang.org/x/crypto v0.49.0
|
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
|
golang.org/x/text v0.35.0
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
|
|||||||
@@ -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-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-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.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.38.0 h1:5l+q+Y9JDC7mBOMjo4/aPhMDcxEptsX+Tt3GgRQRPuE=
|
||||||
golang.org/x/image v0.37.0/go.mod h1:/3f6vaXC+6CEanU4KJxbcUZyEePbyKbaLoDOe4ehFYY=
|
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-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-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
|||||||
@@ -171,6 +171,12 @@ var signupHandler = func(_ http.ResponseWriter, r *http.Request, d *data) (int,
|
|||||||
// if that is the default permission.
|
// if that is the default permission.
|
||||||
user.Perm.Admin = false
|
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)
|
pwd, err := users.ValidateAndHashPwd(info.Password, d.settings.MinimumPasswordLength)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusBadRequest, err
|
return http.StatusBadRequest, err
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ func NewHandler(
|
|||||||
|
|
||||||
api.PathPrefix("/usage").Handler(monkey(diskUsage, "/api/usage")).Methods("GET")
|
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(shareGetsHandler, "/api/share")).Methods("GET")
|
||||||
api.PathPrefix("/share").Handler(monkey(sharePostHandler, "/api/share")).Methods("POST")
|
api.PathPrefix("/share").Handler(monkey(sharePostHandler, "/api/share")).Methods("POST")
|
||||||
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
|
api.PathPrefix("/share").Handler(monkey(shareDeleteHandler, "/api/share")).Methods("DELETE")
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
|||||||
return errToStatus(err), err
|
return errToStatus(err), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !user.Perm.Share || !user.Perm.Download {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
|
|
||||||
d.user = user
|
d.user = user
|
||||||
|
|
||||||
file, err := files.NewFileInfo(&files.FileOptions{
|
file, err := files.NewFileInfo(&files.FileOptions{
|
||||||
|
|||||||
+36
-1
@@ -23,38 +23,66 @@ func TestPublicShareHandlerAuthentication(t *testing.T) {
|
|||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
share *share.Link
|
share *share.Link
|
||||||
req *http.Request
|
req *http.Request
|
||||||
|
sharePerm bool
|
||||||
|
downloadPerm bool
|
||||||
expectedStatusCode int
|
expectedStatusCode int
|
||||||
}{
|
}{
|
||||||
"Public share, no auth required": {
|
"Public share, no auth required": {
|
||||||
share: &share.Link{Hash: "h", UserID: 1},
|
share: &share.Link{Hash: "h", UserID: 1},
|
||||||
req: newHTTPRequest(t),
|
req: newHTTPRequest(t),
|
||||||
|
sharePerm: true,
|
||||||
|
downloadPerm: true,
|
||||||
expectedStatusCode: 200,
|
expectedStatusCode: 200,
|
||||||
},
|
},
|
||||||
"Private share, no auth provided, 401": {
|
"Private share, no auth provided, 401": {
|
||||||
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
||||||
req: newHTTPRequest(t),
|
req: newHTTPRequest(t),
|
||||||
|
sharePerm: true,
|
||||||
|
downloadPerm: true,
|
||||||
expectedStatusCode: 401,
|
expectedStatusCode: 401,
|
||||||
},
|
},
|
||||||
"Private share, authentication via token": {
|
"Private share, authentication via token": {
|
||||||
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
||||||
req: newHTTPRequest(t, func(r *http.Request) { r.URL.RawQuery = "token=123" }),
|
req: newHTTPRequest(t, func(r *http.Request) { r.URL.RawQuery = "token=123" }),
|
||||||
|
sharePerm: true,
|
||||||
|
downloadPerm: true,
|
||||||
expectedStatusCode: 200,
|
expectedStatusCode: 200,
|
||||||
},
|
},
|
||||||
"Private share, authentication via invalid token, 401": {
|
"Private share, authentication via invalid token, 401": {
|
||||||
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
||||||
req: newHTTPRequest(t, func(r *http.Request) { r.URL.RawQuery = "token=1234" }),
|
req: newHTTPRequest(t, func(r *http.Request) { r.URL.RawQuery = "token=1234" }),
|
||||||
|
sharePerm: true,
|
||||||
|
downloadPerm: true,
|
||||||
expectedStatusCode: 401,
|
expectedStatusCode: 401,
|
||||||
},
|
},
|
||||||
"Private share, authentication via password": {
|
"Private share, authentication via password": {
|
||||||
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
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") }),
|
req: newHTTPRequest(t, func(r *http.Request) { r.Header.Set("X-SHARE-PASSWORD", "password") }),
|
||||||
|
sharePerm: true,
|
||||||
|
downloadPerm: true,
|
||||||
expectedStatusCode: 200,
|
expectedStatusCode: 200,
|
||||||
},
|
},
|
||||||
"Private share, authentication via invalid password, 401": {
|
"Private share, authentication via invalid password, 401": {
|
||||||
share: &share.Link{Hash: "h", UserID: 1, PasswordHash: passwordBcrypt, Token: "123"},
|
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") }),
|
req: newHTTPRequest(t, func(r *http.Request) { r.Header.Set("X-SHARE-PASSWORD", "wrong-password") }),
|
||||||
|
sharePerm: true,
|
||||||
|
downloadPerm: true,
|
||||||
expectedStatusCode: 401,
|
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 {
|
for name, tc := range testCases {
|
||||||
@@ -82,7 +110,14 @@ func TestPublicShareHandlerAuthentication(t *testing.T) {
|
|||||||
if err := storage.Share.Save(tc.share); err != nil {
|
if err := storage.Share.Save(tc.share); err != nil {
|
||||||
t.Fatalf("failed to save share: %v", err)
|
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)
|
t.Fatalf("failed to save user: %v", err)
|
||||||
}
|
}
|
||||||
if err := storage.Settings.Save(&settings.Settings{Key: []byte("key")}); err != nil {
|
if err := storage.Settings.Save(&settings.Settings{Key: []byte("key")}); err != nil {
|
||||||
|
|||||||
+2
-1
@@ -72,7 +72,8 @@ func parseQueryAlgorithm(r *http.Request) (string, archives.Archival, error) {
|
|||||||
|
|
||||||
func setContentDisposition(w http.ResponseWriter, r *http.Request, file *files.FileInfo) {
|
func setContentDisposition(w http.ResponseWriter, r *http.Request, file *files.FileInfo) {
|
||||||
if r.URL.Query().Get("inline") == "true" {
|
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 {
|
} else {
|
||||||
// As per RFC6266 section 4.3
|
// As per RFC6266 section 4.3
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(file.Name))
|
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(file.Name))
|
||||||
|
|||||||
@@ -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
@@ -30,7 +30,7 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
|||||||
Expand: true,
|
Expand: true,
|
||||||
ReadHeader: d.server.TypeDetectionByHeader,
|
ReadHeader: d.server.TypeDetectionByHeader,
|
||||||
Checker: d,
|
Checker: d,
|
||||||
Content: true,
|
Content: d.user.Perm.Download,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errToStatus(err), err
|
return errToStatus(err), err
|
||||||
@@ -42,6 +42,9 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
|||||||
file.ApplySort()
|
file.ApplySort()
|
||||||
return renderJSON(w, r, file)
|
return renderJSON(w, r, file)
|
||||||
} else if encoding == "true" {
|
} else if encoding == "true" {
|
||||||
|
if !d.user.Perm.Download {
|
||||||
|
return http.StatusAccepted, nil
|
||||||
|
}
|
||||||
if file.Type != "text" {
|
if file.Type != "text" {
|
||||||
return renderJSON(w, r, file)
|
return renderJSON(w, r, file)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,19 +1,19 @@
|
|||||||
package fbhttp
|
package fbhttp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"compress/gzip"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/v2/auth"
|
"github.com/filebrowser/filebrowser/v2/auth"
|
||||||
"github.com/filebrowser/filebrowser/v2/settings"
|
"github.com/filebrowser/filebrowser/v2/settings"
|
||||||
@@ -85,7 +85,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, fSys
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
data["Json"] = strings.ReplaceAll(string(b), `'`, `\'`)
|
data["Json"] = template.JS(strings.ReplaceAll(string(b), `'`, `\'`))
|
||||||
|
|
||||||
fileContents, err := fs.ReadFile(fSys, file)
|
fileContents, err := fs.ReadFile(fSys, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func tusPostHandler(cache UploadCache) handleFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadLength, err := getUploadLength(r)
|
uploadLength, err := getUploadLength(r)
|
||||||
if err != nil {
|
if err != nil || uploadLength < 0 {
|
||||||
return http.StatusBadRequest, fmt.Errorf("invalid upload length: %w", err)
|
return http.StatusBadRequest, fmt.Errorf("invalid upload length: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ func (c *redisUploadCache) GetLength(filePath string) (int64, error) {
|
|||||||
return 0, fmt.Errorf("invalid upload length in cache: %w", err)
|
return 0, fmt.Errorf("invalid upload length in cache: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.Touch(filePath)
|
||||||
|
|
||||||
return size, nil
|
return size, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ var userPostHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *
|
|||||||
return http.StatusBadRequest, err
|
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)
|
userHome, err := d.settings.MakeUserDir(req.Data.Username, req.Data.Scope, d.server.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
|
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
|
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 len(req.Which) == 0 || (len(req.Which) == 1 && req.Which[0] == "all") {
|
||||||
if !d.user.Perm.Admin {
|
if !d.user.Perm.Admin {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
|
|||||||
+10
-1
@@ -31,7 +31,16 @@ func (r *Rule) Matches(path string) bool {
|
|||||||
return r.Regexp.MatchString(path)
|
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
|
// Regexp is a wrapper to the native regexp type where we
|
||||||
|
|||||||
@@ -2,6 +2,37 @@ package rules
|
|||||||
|
|
||||||
import "testing"
|
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) {
|
func TestMatchHidden(t *testing.T) {
|
||||||
cases := map[string]bool{
|
cases := map[string]bool{
|
||||||
"/": false,
|
"/": false,
|
||||||
|
|||||||
Reference in new issue
Block a user