Browse Source

ensure uids are url safe

Mark deVilliers 2 years ago
parent
commit
16a102bb09
2 changed files with 5 additions and 2 deletions
  1. 3 0
      metadata/api/catalog.go
  2. 2 2
      node/api/metadata_store.go

+ 3 - 0
metadata/api/catalog.go

@@ -6,6 +6,7 @@ import (
6 6
 	"fmt"
7 7
 	"log"
8 8
 	"net/http"
9
+	"strings"
9 10
 
10 11
 	validator "gopkg.in/validator.v2"
11 12
 
@@ -215,6 +216,8 @@ func (e catalogResource) catalogItem(request *restful.Request, response *restful
215 216
 	key := []byte(fmt.Sprintf("%s:%s", locationUID, req.Key))
216 217
 	hash := md5.Sum(key)
217 218
 	encoded := base64.StdEncoding.EncodeToString(hash[:])
219
+	// urlencode the url as used in URL for deletes
220
+	encoded = strings.Replace(encoded, "/", "_", -1)
218 221
 
219 222
 	item := CatalogItem{
220 223
 		CatalogRequest: req,

+ 2 - 2
node/api/metadata_store.go

@@ -41,11 +41,11 @@ func (m *MetadataStore) FindBySubject(subject utils.Subject) (Metadata, bool) {
41 41
 	perms := subject.Perms()
42 42
 
43 43
 	// TODO : optimise optimise optimise - rewrite as a trie
44
-
45 44
 	for _, s := range perms {
46 45
 		for _, m := range m.store {
47 46
 			if m.Subject == s {
48
-				return m, true
47
+				ffs := m
48
+				return ffs, true
49 49
 			}
50 50
 		}
51 51
 	}