Skip to content

Commit

Permalink
Encode + and space correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Livia Chiorean committed Jun 12, 2018
1 parent 7df267d commit 2642689
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion collections/app/controllers/CollectionsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class CollectionsController(authenticated: Authentication, config: CollectionsCo
}

def removeCollection(collectionPath: String) = authenticated.async { req =>
val path = CollectionsManager.uriToPath(UriOps.encode(collectionPath))
val path = CollectionsManager.uriToPath(UriOps.encodePlus(collectionPath))

hasChildren(path).flatMap { noRemove =>
if(noRemove) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.gu.mediaservice.lib.net
import java.net.{URLDecoder, URLEncoder}

object URI {
def encode(uri: String) = URLEncoder.encode(uri, "UTF-8")
def decode(uri: String) = URLDecoder.decode(uri, "UTF-8")
def encode(uri: String): String = URLEncoder.encode(uri, "UTF-8").replace("+", "%20")
def decode(uri: String): String = URLDecoder.decode(uri, "UTF-8")

def encodePlus(uri: String): String = uri.replace("+", "%2B")
}

0 comments on commit 2642689

Please sign in to comment.