Fix Windows clients sending the wrong path for public sharing

Fixes #73
This commit is contained in:
Bruno Bernardino
2025-06-22 11:19:02 +01:00
parent 7fac7febcf
commit cb95085ea3
4 changed files with 17 additions and 8 deletions

View File

@@ -28,12 +28,12 @@ export default function CreateShareModal(
<h1 class='text-2xl font-semibold my-5'>Create New Public Share Link</h1>
<section class='py-5 my-2 border-y border-slate-500'>
<fieldset class='block mb-2'>
<label class='text-slate-300 block pb-1' for='password'>Password</label>
<label class='text-slate-300 block pb-1' for='create-share-password'>Password</label>
<input
class='input-field'
type='password'
name='password'
id='password'
id='create-share-password'
value={newPassword.value}
onInput={(event) => {
newPassword.value = event.currentTarget.value;

View File

@@ -73,14 +73,14 @@ export default function ManageShareModal(
<code class='bg-slate-700 my-2 px-2 py-1 rounded-md'>{baseUrl}/file-share/{fileShareId}</code>
</section>
<fieldset class='block mb-2'>
<label class='text-slate-300 block pb-1' for='password'>
<label class='text-slate-300 block pb-1' for='manage-share-password'>
{fileShare.value?.extra.hashed_password ? 'New Password' : 'Set Password'}
</label>
<input
class='input-field'
type='password'
name='password'
id='password'
name='manage-share-password'
id='manage-share-password'
value={newPassword.value}
onInput={(event) => {
newPassword.value = event.currentTarget.value;

View File

@@ -30,12 +30,12 @@ export default function ShareVerifyForm(
method='POST'
>
<fieldset class='block mb-4'>
<label class='text-slate-300 block pb-1' for='token'>
<label class='text-slate-300 block pb-1' for='verify-password'>
Password
</label>
<input
type='password'
id='password'
id='verify-password'
name='password'
placeholder='Password'
class='mt-1 input-field'

View File

@@ -37,7 +37,16 @@ export const handler: Handlers<Data, FreshContextState> = {
if (
!requestBody.filePath || !requestBody.pathInView || !requestBody.filePath.trim() ||
!requestBody.pathInView.trim() || !requestBody.filePath.startsWith('/') ||
!requestBody.pathInView.trim()
) {
return new Response('Bad Request', { status: 400 });
}
// Fix Windows clients sending the directory path with backslashes
requestBody.filePath = requestBody.filePath.replace(/\\/g, '/');
if (
!requestBody.filePath.startsWith('/') ||
requestBody.filePath.includes('../') || !requestBody.pathInView.startsWith('/') ||
requestBody.pathInView.includes('../')
) {