ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 13 - AD0-E720 discussion

Report
Export

An Adobe Commerce developer needs to pass JSON data to a JavaScript component while keeping XSS prevention strategies in mind.

Which two options would the developer use? (Choose two.)

A)

C)

D)

A.
Option A
Answers
A.
Option A
B.
Option B
Answers
B.
Option B
C.
Option C
Answers
C.
Option C
D.
Option D
Answers
D.
Option D
Suggested answer: A, C

Explanation:

To pass JSON data to a JavaScript component while keeping XSS prevention strategies in mind, the developer should use the following options:

Option A: Use the x-magento-init script tag with the data-mage-init attribute and the JSON.parse function to initialize the component with the JSON data. This option is secure because it does not use any HTML tags or attributes that can be exploited by XSS attacks.

Option C: Use the text/x-magento-init script tag with the type attribute and the JSON.parse function to initialize the component with the JSON data. This option is secure because it does not use any HTML tags or attributes that can be exploited by XSS attacks.

The following options are not secure and should not be used:

Option B: Use the script tag with the type attribute and the escapeHtmlAttr function to initialize the component with the JSON data. This option is not secure because it uses the escapeHtmlAttr function, which is meant for escaping HTML attributes, not JSON data. This function can introduce double quotes in the JSON data, which can break the JSON syntax and cause errors.

Option D: Use the script tag with the type attribute and the escapeJsQuote function to initialize the component with the JSON data. This option is not secure because it uses the escapeJsQuote function, which is meant for escaping JavaScript strings, not JSON data. This function can introduce backslashes in the JSON data, which can break the JSON syntax and cause errors.

asked 02/10/2024
Arnaud DUTEL
32 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first