Skip to content

Commit 8fa356e

Browse files
authored
Fix contradictory statements in XSS doc (#35680)
1 parent d44c4e8 commit 8fa356e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

aspnetcore/security/cross-site-scripting.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ms.author: tdykstra
66
monikerRange: '>= aspnetcore-3.1'
77
ms.date: 2/15/2020
88
uid: security/cross-site-scripting
9+
ai-usage: ai-assisted
910
---
1011
# Prevent Cross-Site Scripting (XSS) in ASP.NET Core
1112

@@ -22,8 +23,8 @@ To prevent XSS attacks, web APIs should implement input validation and output en
2223
At a basic level, XSS works by tricking your application into inserting a `<script>` tag into your rendered page, or by inserting an `On*` event into an element. Developers should use the following prevention steps to avoid introducing XSS into their applications:
2324

2425
1. Never put untrusted data into your HTML input, unless you follow the rest of the steps below. Untrusted data is any data that may be controlled by a cyberattacker, such as HTML form inputs, query strings, HTTP headers, or even data sourced from a database, as a cyberattacker may be able to breach your database even if they can't breach your application.
25-
1. Before putting untrusted data inside an HTML element, ensure it's HTML encoded. HTML encoding takes characters such as &lt; and changes them into a safe form like &amp;lt;.
26-
1. Before putting untrusted data into an HTML attribute, ensure it's HTML encoded. HTML attribute encoding is a subset of HTML encoding and encodes double quote ("), single quote ('), ampersand (&), and less-than (&lt;) characters.
26+
1. Before putting untrusted data into an HTML element, ensure thatt it's HTML encoded. HTML encoding takes characters such as &lt; and changes them into a safe form like &amp;lt;.
27+
1. Before putting untrusted data into an HTML attribute, ensure that it's HTML attribute encoded. This specialized form of HTML encoding handles double quotes (\"), single quotes ('\), ampersands (\&), and less-than (\<) characters. When dealing with untrusted input, use HTML encoding for general HTML content and HTML attribute encoding for HTML attributes.
2728
1. Before putting untrusted data into JavaScript, place the data in an HTML element whose contents you retrieve at runtime. If this isn't possible, then ensure the data is JavaScript encoded. JavaScript encoding takes dangerous characters for JavaScript and replaces them with their hex, for example, &lt; would be encoded as `\u003C`.
2829
1. Before putting untrusted data into a URL query string ensure it's URL encoded.
2930

0 commit comments

Comments
 (0)