Should fix XSS mentioned in #32
This commit is contained in:
+4
-5
@@ -21,6 +21,8 @@ function ChatController( $scope, rconService, $timeout )
|
|||||||
$scope.OnMessage = function( msg )
|
$scope.OnMessage = function( msg )
|
||||||
{
|
{
|
||||||
msg.Message = stripHtml(msg.Message);
|
msg.Message = stripHtml(msg.Message);
|
||||||
|
msg.Username = stripHtml(msg.Username);
|
||||||
|
|
||||||
$scope.Output.push( msg );
|
$scope.Output.push( msg );
|
||||||
|
|
||||||
if($scope.isOnBottom()) {
|
if($scope.isOnBottom()) {
|
||||||
@@ -79,10 +81,7 @@ function ChatController( $scope, rconService, $timeout )
|
|||||||
rconService.InstallService( $scope, $scope.GetHistory )
|
rconService.InstallService( $scope, $scope.GetHistory )
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripHtml(html)
|
function stripHtml( text )
|
||||||
{
|
{
|
||||||
if (html == null) return "";
|
return text ? String(text).replace( /<[^>]+>/gm, '' ) : '';
|
||||||
var tmp = document.createElement("div");
|
|
||||||
tmp.innerHTML = html;
|
|
||||||
return tmp.textContent || tmp.innerText || "";
|
|
||||||
}
|
}
|
||||||
@@ -134,6 +134,8 @@ function ConsoleController( $scope, rconService, $timeout )
|
|||||||
$scope.addOutput = function (msg)
|
$scope.addOutput = function (msg)
|
||||||
{
|
{
|
||||||
msg.Class = msg.Type;
|
msg.Class = msg.Type;
|
||||||
|
msg.Message = stripHtml(msg.Message);
|
||||||
|
|
||||||
$scope.Output.push( msg );
|
$scope.Output.push( msg );
|
||||||
|
|
||||||
if($scope.isOnBottom()) {
|
if($scope.isOnBottom()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user