Commit 10b1f431 authored by Nicolas Pernoud's avatar Nicolas Pernoud
Browse files

fix: accept range header with encrypted files

parent 147a972c
Pipeline #6713 passed with stages
in 2 minutes and 52 seconds
......@@ -459,10 +459,9 @@ func decryptFile(filePath string, key []byte) http.Handler {
w.Header().Set("content-length", strconv.FormatInt(size, 10))
}
_, err = io.Copy(w, ioutil.NopCloser(stream.DecryptReader(f, nonce, nil)))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
dr := stream.DecryptReaderAt(io.NewSectionReader(f, int64(len(binaryHeader)), fi.Size()), nonce, nil)
section := io.NewSectionReader(dr, 0, size)
http.ServeContent(w, r, f.Name(), time.Time{}, section)
})
}
......
......@@ -31,7 +31,7 @@ func TestEncryption(t *testing.T) {
do("GET", "/test.txt", noH, "", 500, "unexpected EOF")
// Try to access a crypted file with the wrong key
davAug = NewWebDavAug("", "./testdata", true, "wrong key")
body = do("GET", "/test-ciphered.txt", noH, "", 500, "")
body = do("GET", "/test-ciphered.txt", noH, "", 200, "")
if body != "" { // Check that the body is really empty
t.Errorf("body must be empty")
}
......
......@@ -32,7 +32,7 @@
<div class="navbar-brand">
<div class="navbar-item">
<a class="button is-primary is-rounded is-outlined" href="https://www.github.com/nicolaspernoud/Vestibule" target="_blank" rel="noopener noreferrer">
<span>4.3.39</span>
<span>4.3.40</span>
<span class="icon">
<svg
class="svg-inline--fa fa-github fa-w-16"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment