Sfoglia il codice sorgente

Use base64 URL encoding instead of standard encoding

Frédéric Guillot 8 anni fa
parent
commit
ce75748cf2
2 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  1. 1 1
      server/ui/controller/proxy.go
  2. 2 1
      server/ui/filter/image_proxy_filter.go

+ 1 - 1
server/ui/controller/proxy.go

@@ -30,7 +30,7 @@ func (c *Controller) ImageProxy(ctx *core.Context, request *core.Request, respon
 		return
 	}
 
-	decodedURL, err := base64.StdEncoding.DecodeString(encodedURL)
+	decodedURL, err := base64.URLEncoding.DecodeString(encodedURL)
 	if err != nil {
 		response.HTML().BadRequest(errors.New("Unable to decode this URL"))
 		return

+ 2 - 1
server/ui/filter/image_proxy_filter.go

@@ -36,5 +36,6 @@ func ImageProxyFilter(router *mux.Router, data string) string {
 
 // Proxify returns a proxified link.
 func Proxify(router *mux.Router, link string) string {
-	return route.Path(router, "proxy", "encodedURL", base64.StdEncoding.EncodeToString([]byte(link)))
+	// We use base64 url encoding to avoid slash in the URL.
+	return route.Path(router, "proxy", "encodedURL", base64.URLEncoding.EncodeToString([]byte(link)))
 }