Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65a837de49 | ||
|
|
876cdb3426 | ||
|
|
2f805de527 | ||
|
|
7a16129bfc | ||
|
|
0f39bd055e | ||
|
|
860c19ddf5 | ||
|
|
a8fc1657b7 | ||
|
|
c406bda0c7 | ||
|
|
d9f9460c1e | ||
|
|
126227bb27 | ||
|
|
b6a4fb1f27 | ||
|
|
2368e468b9 | ||
|
|
8d8cd26d7f | ||
|
|
8f81b77cf2 | ||
|
|
0616f6811f | ||
|
|
432f3e60ff | ||
|
|
ae72f93667 | ||
|
|
4812536555 | ||
|
|
6d44b3ae1d | ||
|
|
811cf2dfe5 | ||
|
|
b5f970731b | ||
|
|
fc80f4f44c |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,40 @@
|
||||
|
||||
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.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)
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
filebrowser:
|
||||
container_name: filebrowser
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
image: filebrowser/filebrowser:latest
|
||||
networks:
|
||||
- filebrowser
|
||||
ports:
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
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 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>
|
||||
|
||||
@@ -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
@@ -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ć",
|
||||
|
||||
@@ -176,8 +176,8 @@
|
||||
"override": "덮어쓰기",
|
||||
"skip": "건너뛰기",
|
||||
"forbiddenError": "권한 오류",
|
||||
"currentPassword": "Your password",
|
||||
"currentPasswordMessage": "Enter your password to validate this action."
|
||||
"currentPassword": "기존 비밀번호",
|
||||
"currentPasswordMessage": "기존 비밀번호를 입력해 이 동작을 확인하십시오."
|
||||
},
|
||||
"search": {
|
||||
"images": "이미지",
|
||||
|
||||
@@ -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"]);
|
||||
});
|
||||
});
|
||||
@@ -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) {
|
||||
|
||||
@@ -84,7 +84,6 @@
|
||||
}"
|
||||
:epubOptions="{
|
||||
allowPopups: true,
|
||||
allowScriptedContent: true,
|
||||
}"
|
||||
@update:location="locationChange"
|
||||
/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=
|
||||
|
||||
@@ -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
@@ -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")
|
||||
|
||||
+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) {
|
||||
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))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user