Skip to main content

Posts

Showing posts with the label Handle XSS Vulnerability Scenario in AngularJs

How Prevents HTML DOM Based Cross Site Scripting (XSS) Attacks?

What Is Cross Site Scripting (XSS) Attack? The Cross Site Scripting (XSS) attack is a type of injection and attackers inject your web applications using the client side scripts and malicious code into web pages. An attacker can insert vulnerability scripts and malicious code in your web applications. The Cross Site Scripting (XSS) attacks are common on web browsers and it carried out on websites around 84% (approximately). How Prevents HTML DOM Based XSS attacks? < script type = "text/javascript" >   let escapeHTML = function ( unsafe_str ) {     return unsafe_str         . replace ( /&/ g , '&amp;' )         . replace ( /</ g , '&lt;' )         . replace ( />/ g , '&gt;' )         . replace ( / \" / g , '&quot;' )      ...

How To Handle XSS Vulnerability Scenarios in AngularJs?

JavaScript Code- < script type = "text/javascript" >   var app = angular . module ( 'App' , [ "ngSanitize" ]);   app . controller ( 'AppCtrl' , [ '$scope' , '$sce' , function ( $scope , $sce ){     $scope . name = "" ;     $scope . processHtmlCode = function () {        $scope . trustedMessage =  $sce . trustAsHtml ( $scope . name );     }   }]); </ script > HTML code- < span ng-bind-html = "trustedMessage" ></ span > How To Preventing Cross Site Scripting (XSS) in Angular?  How Angular Protects Us From XSS Attacks? I hope you are enjoying with this post! Please share with you friends. Thank you so much!