exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 203 discussion

Actual exam question from Salesforce's CRT-450
Question #: 203
Topic #: 1
[All CRT-450 Questions]

A developer has an Apex controller for a Visualforce page that takes an ID as a URL parameter.
How should the developer prevent a cross site scripting vulnerability?

  • A. ApexPages.currentPage().getParameters().get('url_param')
  • B. String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('url_param'))
  • C. String.ValueOf(ApexPages.currentPage().getParameters().get('url_param'))
  • D. ApexPages.currentPage().getParameters().get('url_param').escapeHtml4()
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
noox
Highly Voted 1 year ago
Selected Answer: D
https://salesforce.stackexchange.com/questions/233885/apex-classes-should-escape-sanitize-strings-obtained-from-url-parameters-how
upvoted 5 times
...
lmeloni91
Most Recent 7 months, 3 weeks ago
Both B and D do some kind of sanitization to the string, but D seems to be more complete, as it transforms ALL special characters (not only single quotes) to Html4 entities
upvoted 3 times
...
illyaOsiyuk
1 year, 1 month ago
I think 'B' is right answer, please correct me it's not right
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...