Skip to content

Commit 5fbab24

Browse files
author
David Christofas
authored
implement url translation for legacy urls (#1989)
1 parent 969ac3c commit 5fbab24

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: Add redirects from OC10 URL formats
2+
3+
Added redirectors for ownCloud 10 URLs. This allows users to continue to use their bookmarks from ownCloud 10 in ocis.
4+
5+
https://github.com/cs3org/reva/pull/1989

internal/http/services/owncloud/ocdav/ocdav.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (s *svc) Close() error {
153153
}
154154

155155
func (s *svc) Unprotected() []string {
156-
return []string{"/status.php", "/remote.php/dav/public-files/"}
156+
return []string{"/status.php", "/remote.php/dav/public-files/", "/apps/files/", "/index.php/f/", "/index.php/s/"}
157157
}
158158

159159
func (s *svc) Handler() http.Handler {
@@ -187,7 +187,20 @@ func (s *svc) Handler() http.Handler {
187187

188188
// yet, add it to baseURI
189189
base = path.Join(base, "remote.php")
190-
190+
case "apps":
191+
head, r.URL.Path = router.ShiftPath(r.URL.Path)
192+
if head == "files" {
193+
s.handleLegacyPath(w, r)
194+
return
195+
}
196+
case "index.php":
197+
head, r.URL.Path = router.ShiftPath(r.URL.Path)
198+
if head == "s" {
199+
token := r.URL.Path
200+
url := s.c.PublicURL + path.Join("#", head, token)
201+
http.Redirect(w, r, url, http.StatusMovedPermanently)
202+
return
203+
}
191204
}
192205
switch head {
193206
// the old `/webdav` endpoint uses remote.php/webdav/$path
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2018-2021 CERN
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// In applying this license, CERN does not waive the privileges and immunities
16+
// granted to it by virtue of its status as an Intergovernmental Organization
17+
// or submit itself to any jurisdiction.
18+
19+
package ocdav
20+
21+
import (
22+
"net/http"
23+
"net/url"
24+
"path"
25+
)
26+
27+
func (s *svc) handleLegacyPath(w http.ResponseWriter, r *http.Request) {
28+
query := r.URL.Query()
29+
dir := query.Get("dir")
30+
url := s.c.PublicURL + path.Join("#", "/files/list/all", url.PathEscape(dir))
31+
http.Redirect(w, r, url, http.StatusMovedPermanently)
32+
}

0 commit comments

Comments
 (0)