diff --git a/app/api/Datasets.scala b/app/api/Datasets.scala index b59e67e8a..dd3a02526 100644 --- a/app/api/Datasets.scala +++ b/app/api/Datasets.scala @@ -716,7 +716,15 @@ class Datasets @Inject()( } Logger.debug("----- Adding file to dataset completed") } else { + val foldersContainingFile = folders.findByFileId(file.id).sortBy(_.name) Logger.debug("File was already in dataset.") + Logger.debug("Remove file from folders in dataset") + foldersContainingFile.foreach(folder => { + if (folder.parentDatasetId == dsId){ + folders.removeFile(folder.id, fileId) + + } + }) } } diff --git a/app/api/Users.scala b/app/api/Users.scala index 866e8e9c2..88608b405 100644 --- a/app/api/Users.scala +++ b/app/api/Users.scala @@ -1,5 +1,6 @@ package api - +// import org.springframework.web.util.HtmlUtils.htmlEscape +import org.apache.commons.lang.StringEscapeUtils.escapeJavaScript import javax.inject.Inject import play.api.libs.json._ import play.api.Play.current @@ -61,10 +62,14 @@ class Users @Inject()(users: UserService, events: EventService) extends ApiContr /** @deprecated use id instead of email */ def updateName(id: UUID, firstName: String, lastName: String) = PermissionAction(Permission.EditUser, Some(ResourceRef(ResourceRef.user, id))) { implicit request => implicit val user = request.user - users.updateUserField(id, "firstName", firstName) - users.updateUserField(id, "lastName", lastName) - users.updateUserField(id, "fullName", firstName + " " + lastName) - users.updateUserFullName(id, firstName + " " + lastName) +// val escapedFirstName = htmlEscape(firstName) +// val escapedLastName = htmlEscape(lastName) + val escapedFirstName = scala.xml.Text(firstName).toString + val escapedLastName = scala.xml.Text(lastName).toString + users.updateUserField(id, "firstName", escapedFirstName) + users.updateUserField(id, "lastName", escapedLastName) + users.updateUserField(id, "fullName", escapedFirstName + " " + escapedLastName) + users.updateUserFullName(id, escapedFirstName + " " + escapedLastName) Ok(Json.obj("status" -> "success")) } diff --git a/app/views/profile.scala.html b/app/views/profile.scala.html index 69693cd07..c891e3ea2 100644 --- a/app/views/profile.scala.html +++ b/app/views/profile.scala.html @@ -65,7 +65,7 @@

@profile.fullName

} else { @if(ownProfile){
-

@Html(profile.firstName)

+

@Html(escapeString(""))

diff --git a/docker-compose.yml b/docker-compose.yml index 1e9f05fcb..30f9f98e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,7 +51,7 @@ services: # main clowder application clowder: - image: clowder/clowder:${CLOWDER_VERSION:-latest} + image: clowder:bugfix restart: unless-stopped networks: - clowder diff --git a/public/javascripts/htmlEncodeDecode.js b/public/javascripts/htmlEncodeDecode.js index 84ab0aee4..b34244b1b 100644 --- a/public/javascripts/htmlEncodeDecode.js +++ b/public/javascripts/htmlEncodeDecode.js @@ -11,4 +11,13 @@ function htmlEncode(value){ function htmlDecode(value){ return $('
').html(value).text(); +} + +function escapeString(htmlStr) { + return htmlStr.replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + } \ No newline at end of file