Plat-Dev-201 practice question 30 of 30
Which code in a Visualforce page and/or controller might present a security vulnerability?
Full set: 204 questionsOption B inserts an unescaped merge expression directly into a JavaScript block, enabling malicious data in Account.Name to break out of the string literal and execute arbitrary script (ref. Security Guide, “Protect Against XSS”). Expressions rendered inside <script> tags must be wrapped with JSENCODE/HTMLENCODE or assigned through apex:outputText with escape=”true”; failing to do so is a documented XSS vulnerability.
A Apex outputText escapes HTML by default, so Account.Name is encoded—no XSS risk. C Explicit HTMLENCODE() guarantees the value is safely rendered, removing injection vectors. D JSENCODE() correctly escapes characters for JavaScript contexts, blocking script-breaking characters.
1. Salesforce Security Implementation Guide, “Visualforce and XSS”, §“Escape Output in JavaScript”, Winter ’24, p.167–169.
2. Visualforce Developer Guide, “escape attribute of ”, p.487.
Keep practicing
Take the free Plat-Dev-201 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Plat-Dev-201 practice questions
- Question 1Which three steps allow a custom Scalable Vector Graphic (SVG) to be included in a Lightn…
- Question 2Which two statements are true about using the @testSetup annotation in an Apex test class…
- Question 3Managers at Universal Containers want to ensure that only decommissioned containers are a…
- Question 4Universal Containers has a Visualforce page that displays a table of every Container__c b…
- Question 5A developer is alerted to an issue with a custom Apex trigger that is causing records to …
- Question 6Which two operations affect the number of times a trigger can fire? Choose 2 answers
