Skip to content

Commit e134f85

Browse files
authored
Avoid XSS by escaping HTML during serialization
Addresses #18
1 parent 8eca10f commit e134f85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Source/Schema.NET/Thing.Partial.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
public partial class Thing : JsonLdObject
99
{
1010
private const string ContextPropertyJson = "\"@context\":\"http://schema.org\",";
11+
12+
/// <summary>
13+
/// Serializer settings used.
14+
/// Note: Escapes HTML to avoid XSS vulnerabilities where user-supplied data is used.
15+
/// </summary>
1116
private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings()
1217
{
1318
Converters = new List<JsonConverter>()
1419
{
1520
new StringEnumConverter()
1621
},
17-
NullValueHandling = NullValueHandling.Ignore
22+
NullValueHandling = NullValueHandling.Ignore,
23+
StringEscapeHandling = StringEscapeHandling.EscapeHtml
1824
};
1925

2026
/// <summary>

0 commit comments

Comments
 (0)