Skip to content

Commit

Permalink
fix: UTF-8 encode username and password
Browse files Browse the repository at this point in the history
to support Unicode Special chars (like `é`) in username or passord,
as the auth-backend decodes them using UTF-8.

See perry-mitchell/webdav-client#293
  • Loading branch information
n-peugnet committed Feb 22, 2022
1 parent d12c83d commit 57da8ec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-typescript": "^8.0.0",
"@tsconfig/svelte": "^2.0.0 || ^3.0.0",
"@types/utf8": "^3.0.1",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"carbon-icons-svelte": "^10.44.4",
Expand All @@ -39,6 +40,7 @@
},
"dependencies": {
"carbon-components-svelte": ">=0.42.2 <1",
"utf8": "^3.0.0",
"webdav": "^4.5.0"
},
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/model/webdav/WebdavFileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AuthType, createClient } from "webdav/web";
import type { FileSystem } from "../FileSystem";
import type { FileSystemProvider } from "../FileSystemProvider";
import { WebdavFileSystem } from "./WebdavFileSystem";
import { encode } from "utf8";

export class WebdavFileSystemProvider implements FileSystemProvider {
constructor(
Expand All @@ -13,8 +14,8 @@ export class WebdavFileSystemProvider implements FileSystemProvider {
async getFileSystem(username: string, password: string): Promise<FileSystem> {
const client = createClient(this.serverUrl, {
authType: this.authType,
username: username,
password: password,
username: encode(username),
password: encode(password),
});
const root = this.root.replace("{username}", username);
if (!await client.exists(root)) {
Expand Down

0 comments on commit 57da8ec

Please sign in to comment.