Adds AngularJsonMediaTypeFormatter and ensures our controllers all use this formatter in order to enable angular's JSON Vulnerability protection.

This commit is contained in:
Shannon
2013-12-02 13:31:44 +11:00
parent 1ac6f6db50
commit 33c32579c8
7 changed files with 71 additions and 7 deletions

View File

@@ -96,12 +96,14 @@ namespace Umbraco.Web.WebApi
}
/// <summary>
/// Removes the xml formatter so it only outputs json
/// Removes the xml formatter so it only outputs angularized json (with the json vulnerability prefix added)
/// </summary>
/// <param name="controllerContext"></param>
internal static void EnsureJsonOutputOnly(this HttpControllerContext controllerContext)
{
controllerContext.Configuration.Formatters.Remove(controllerContext.Configuration.Formatters.XmlFormatter);
controllerContext.Configuration.Formatters.Remove(controllerContext.Configuration.Formatters.JsonFormatter);
controllerContext.Configuration.Formatters.Add(new AngularJsonMediaTypeFormatter());
}
}
}