<commit_before>package controllers

import play._
import play.mvc._
import play.templates._

import models._

object People extends Controller {

  def publicationsData(vivoId: String, items: Int) = {
    Publication.findAllForPerson(Vivo.baseUri+vivoId,items) match {
      case Some(publications) =>
        val vwr = new VivoWidgetJsonResult(publications.asInstanceOf[List[Publication]])
        request.format match {
          case "json" => Json(vwr.json.toString)
          case "jsonp" => Json(vwr.jsonp)
          case _ => NoContent
        }
      case _ => NoContent
    }
  }

  def publications(vivoId: String, items: Int, formatting: String = "detailed", style: String = "yes") = {
    Publication.findAllForPerson(Vivo.baseUri+vivoId,items) match {
      case Some(publications) =>
        val modelData = new java.util.HashMap[java.lang.String,java.lang.Object]
        modelData.put("publications",publications)
        modelData.put("style",style)
        modelData.put("formatting",formatting)
        val htmlString = TemplateLoader.load("People/publications.html").render(modelData)
        request.format.toString match {
          case "js" => 
            val lines = htmlString.split('\n').toList
            val documentWrites = lines.map { "document.write('"+_+"');" }
            val documentWritesString = documentWrites.mkString("\n")
            Json(documentWritesString)
          case "html" => Html(htmlString)
          case _ => NoContent
        }
      case _ => NoContent
    }
  }

}


<commit_msg>FDP-624: added single quote escaping to document write wrapper<commit_after>package controllers

import play._
import play.mvc._
import play.templates._

import models._

object People extends Controller {

  def publicationsData(vivoId: String, items: Int) = {
    Publication.findAllForPerson(Vivo.baseUri+vivoId,items) match {
      case Some(publications) =>
        val vwr = new VivoWidgetJsonResult(publications.asInstanceOf[List[Publication]])
        request.format match {
          case "json" => Json(vwr.json.toString)
          case "jsonp" => Json(vwr.jsonp)
          case _ => NoContent
        }
      case _ => NoContent
    }
  }

  def publications(vivoId: String, items: Int, formatting: String = "detailed", style: String = "yes") = {
    Publication.findAllForPerson(Vivo.baseUri+vivoId,items) match {
      case Some(publications) =>
        val modelData = new java.util.HashMap[java.lang.String,java.lang.Object]
        modelData.put("publications",publications)
        modelData.put("style",style)
        modelData.put("formatting",formatting)
        val htmlString = TemplateLoader.load("People/publications.html").render(modelData)
        request.format.toString match {
          case "js" => 
            val lines = htmlString.split('\n').toList
            val documentWrites = lines.map { "document.write('"+_.replaceAll("'","\\\\'")+"');" }
            val documentWritesString = documentWrites.mkString("\n")
            Json(documentWritesString)
          case "html" => Html(htmlString)
          case _ => NoContent
        }
      case _ => NoContent
    }
  }

}



{'fraction_non_alphanumeric': 0.11988582302568981, 'fraction_numerical': 0.0009514747859181732, 'mean_word_length': 2.795427196149218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '787965', 'n_tokens_mistral': 931, 'n_tokens_neox': 919, 'n_words': 180}