fix: correctly handle non-ascii passwords for shared resources
parent
0942fc7042
commit
c782f21b0f
|
@ -5,7 +5,7 @@ export async function fetch(url, password = "") {
|
||||||
url = removePrefix(url);
|
url = removePrefix(url);
|
||||||
|
|
||||||
const res = await fetchURL(`/api/public/share${url}`, {
|
const res = await fetchURL(`/api/public/share${url}`, {
|
||||||
headers: { "X-SHARE-PASSWORD": password },
|
headers: { "X-SHARE-PASSWORD": encodeURIComponent(password) },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package http
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -124,6 +125,10 @@ func authenticateShareRequest(r *http.Request, l *share.Link) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
password := r.Header.Get("X-SHARE-PASSWORD")
|
password := r.Header.Get("X-SHARE-PASSWORD")
|
||||||
|
password, err := url.QueryUnescape(password)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
if password == "" {
|
if password == "" {
|
||||||
return http.StatusUnauthorized, nil
|
return http.StatusUnauthorized, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue