https://badsite.com?c=<script>document.cookie()</script>
<b>Bad</b>
page strips or blocks the code, then no unauthorized code run:
Hello {!HTMLENCODE(Account.Name)}
var x = '{!JSENCODE($CurrentPage.parameters.userInput)}';
{!JSINHTMLENCODE(Account.Name)}
ESAPI.encoder().SFDC_HTMLENCODE(person.Title__c)
queryResult = [select id from contact where firstname =:var];
// With a bind variable, the attacker isn’t able to break out and control the SOQL query
whereClause += 'Title__c like \'%'+ String.escapeSingleQuotes(textualTitle) +'%\' ';
whereclause_records = database.query(query+' where '+whereClause);
whereClause +='Age__c >'+string.valueOf(textualAge)+'';
database.query(query+' where '+ whereClause);
// The code to remove all spaces from a string can be written as follows
String query = 'select id from user where isActive='+ var.replaceAll('[^\w]','');
if (top != self) top.location = self.location;