test/html is cause of xss

This commit is contained in:
nazoking
2015-01-30 15:32:53 +09:00
parent da55bf6af3
commit 9ba564c864
5 changed files with 16 additions and 8 deletions

View File

@@ -134,6 +134,16 @@ abstract class ControllerBase extends ScalatraFilter
if (path.startsWith("http")) path
else baseUrl + super.url(path, params, false, false, false)
/** against XSS */
def outputUploadedRawData[DATATYPE](contentType: String, rawData: DATATYPE): DATATYPE = {
if(contentType.split(";").head.trim.toLowerCase.startsWith("text/html")){
this.contentType = "text/plain"
} else {
this.contentType = contentType
}
response.addHeader("X-Content-Type-Options", "nosniff")
rawData
}
}
/**