@@ -10,323 +10,266 @@ namespace Ganss.Xss
10
10
/// <summary>
11
11
/// Provides data for the <see cref="HtmlSanitizer.PostProcessDom"/> event.
12
12
/// </summary>
13
- public class PostProcessDomEventArgs : EventArgs
13
+ /// <remarks>
14
+ /// Initializes a new instance of the <see cref="PostProcessDomEventArgs"/> class.
15
+ /// </remarks>
16
+ public class PostProcessDomEventArgs ( IHtmlDocument document ) : EventArgs
14
17
{
15
18
/// <summary>
16
19
/// Gets the document.
17
20
/// </summary>
18
21
/// <value>
19
22
/// The document.
20
23
/// </value>
21
- public IHtmlDocument Document { get ; private set ; }
22
-
23
- /// <summary>
24
- /// Initializes a new instance of the <see cref="PostProcessDomEventArgs"/> class.
25
- /// </summary>
26
- public PostProcessDomEventArgs ( IHtmlDocument document )
27
- {
28
- Document = document ;
29
- }
24
+ public IHtmlDocument Document { get ; private set ; } = document ;
30
25
}
31
26
32
27
/// <summary>
33
28
/// Provides data for the <see cref="HtmlSanitizer.PostProcessNode"/> event.
34
29
/// </summary>
35
- public class PostProcessNodeEventArgs : EventArgs
30
+ /// <remarks>
31
+ /// Initializes a new instance of the <see cref="PostProcessNodeEventArgs"/> class.
32
+ /// </remarks>
33
+ public class PostProcessNodeEventArgs ( IHtmlDocument document , INode node ) : EventArgs
36
34
{
37
35
/// <summary>
38
36
/// Gets the document.
39
37
/// </summary>
40
38
/// <value>
41
39
/// The document.
42
40
/// </value>
43
- public IHtmlDocument Document { get ; private set ; }
41
+ public IHtmlDocument Document { get ; private set ; } = document ;
44
42
45
43
/// <summary>
46
44
/// Gets the DOM node to be processed.
47
45
/// </summary>
48
46
/// <value>
49
47
/// The DOM node.
50
48
/// </value>
51
- public INode Node { get ; private set ; }
49
+ public INode Node { get ; private set ; } = node ;
52
50
53
51
/// <summary>
54
52
/// Gets the replacement nodes. Leave empty if no replacement should occur.
55
53
/// </summary>
56
54
/// <value>
57
55
/// The replacement nodes.
58
56
/// </value>
59
- public ICollection < INode > ReplacementNodes { get ; private set ; }
60
-
61
- /// <summary>
62
- /// Initializes a new instance of the <see cref="PostProcessNodeEventArgs"/> class.
63
- /// </summary>
64
- public PostProcessNodeEventArgs ( IHtmlDocument document , INode node )
65
- {
66
- Document = document ;
67
- Node = node ;
68
- ReplacementNodes = new List < INode > ( ) ;
69
- }
57
+ public ICollection < INode > ReplacementNodes { get ; private set ; } = new List < INode > ( ) ;
70
58
}
71
59
72
60
/// <summary>
73
61
/// Provides data for the <see cref="HtmlSanitizer.RemovingTag"/> event.
74
62
/// </summary>
75
- public class RemovingTagEventArgs : CancelEventArgs
63
+ /// <remarks>
64
+ /// Initializes a new instance of the <see cref="RemovingTagEventArgs"/> class.
65
+ /// </remarks>
66
+ /// <param name="tag">The element to be removed.</param>
67
+ /// <param name="reason">The reason why the tag will be removed.</param>
68
+ public class RemovingTagEventArgs ( IElement tag , RemoveReason reason ) : CancelEventArgs
76
69
{
77
70
/// <summary>
78
71
/// Gets the tag to be removed.
79
72
/// </summary>
80
73
/// <value>
81
74
/// The tag.
82
75
/// </value>
83
- public IElement Tag { get ; private set ; }
76
+ public IElement Tag { get ; private set ; } = tag ;
84
77
85
78
/// <summary>
86
79
/// Gets the reason why the tag will be removed.
87
80
/// </summary>
88
81
/// <value>
89
82
/// The reason.
90
83
/// </value>
91
- public RemoveReason Reason { get ; private set ; }
92
-
93
- /// <summary>
94
- /// Initializes a new instance of the <see cref="RemovingTagEventArgs"/> class.
95
- /// </summary>
96
- /// <param name="tag">The element to be removed.</param>
97
- /// <param name="reason">The reason why the tag will be removed.</param>
98
- public RemovingTagEventArgs ( IElement tag , RemoveReason reason )
99
- {
100
- Tag = tag ;
101
- Reason = reason ;
102
- }
84
+ public RemoveReason Reason { get ; private set ; } = reason ;
103
85
}
104
86
105
87
/// <summary>
106
88
/// Provides data for the <see cref="HtmlSanitizer.RemovingAttribute"/> event.
107
89
/// </summary>
108
- public class RemovingAttributeEventArgs : CancelEventArgs
90
+ /// <remarks>
91
+ /// Initializes a new instance of the <see cref="RemovingAttributeEventArgs"/> class.
92
+ /// </remarks>
93
+ /// <param name="tag">The element containing the attribute.</param>
94
+ /// <param name="attribute">The attribute to be removed.</param>
95
+ /// <param name="reason">The reason why the attribute will be removed.</param>
96
+ public class RemovingAttributeEventArgs ( IElement tag , IAttr attribute , RemoveReason reason ) : CancelEventArgs
109
97
{
110
98
/// <summary>
111
99
/// Gets the tag containing the attribute to be removed.
112
100
/// </summary>
113
101
/// <value>
114
102
/// The tag.
115
103
/// </value>
116
- public IElement Tag { get ; private set ; }
104
+ public IElement Tag { get ; private set ; } = tag ;
117
105
118
106
/// <summary>
119
107
/// Gets the attribute to be removed.
120
108
/// </summary>
121
109
/// <value>
122
110
/// The attribute.
123
111
/// </value>
124
- public IAttr Attribute { get ; private set ; }
112
+ public IAttr Attribute { get ; private set ; } = attribute ;
125
113
126
114
/// <summary>
127
115
/// Gets the reason why the attribute will be removed.
128
116
/// </summary>
129
117
/// <value>
130
118
/// The reason.
131
119
/// </value>
132
- public RemoveReason Reason { get ; private set ; }
133
-
134
- /// <summary>
135
- /// Initializes a new instance of the <see cref="RemovingAttributeEventArgs"/> class.
136
- /// </summary>
137
- /// <param name="tag">The element containing the attribute.</param>
138
- /// <param name="attribute">The attribute to be removed.</param>
139
- /// <param name="reason">The reason why the attribute will be removed.</param>
140
- public RemovingAttributeEventArgs ( IElement tag , IAttr attribute , RemoveReason reason )
141
- {
142
- Tag = tag ;
143
- Attribute = attribute ;
144
- Reason = reason ;
145
- }
120
+ public RemoveReason Reason { get ; private set ; } = reason ;
146
121
}
147
122
148
123
/// <summary>
149
124
/// Provides data for the <see cref="HtmlSanitizer.RemovingStyle"/> event.
150
125
/// </summary>
151
- public class RemovingStyleEventArgs : CancelEventArgs
126
+ /// <remarks>
127
+ /// Initializes a new instance of the <see cref="RemovingStyleEventArgs"/> class.
128
+ /// </remarks>
129
+ /// <param name="tag">The element containing the attribute.</param>
130
+ /// <param name="style">The style to be removed.</param>
131
+ /// <param name="reason">The reason why the attribute will be removed.</param>
132
+ public class RemovingStyleEventArgs ( IElement tag , ICssProperty style , RemoveReason reason ) : CancelEventArgs
152
133
{
153
134
/// <summary>
154
135
/// Gets the tag containing the style to be removed.
155
136
/// </summary>
156
137
/// <value>
157
138
/// The tag.
158
139
/// </value>
159
- public IElement Tag { get ; private set ; }
140
+ public IElement Tag { get ; private set ; } = tag ;
160
141
161
142
/// <summary>
162
143
/// Gets the style to be removed.
163
144
/// </summary>
164
145
/// <value>
165
146
/// The style.
166
147
/// </value>
167
- public ICssProperty Style { get ; private set ; }
148
+ public ICssProperty Style { get ; private set ; } = style ;
168
149
169
150
/// <summary>
170
151
/// Gets the reason why the style will be removed.
171
152
/// </summary>
172
153
/// <value>
173
154
/// The reason.
174
155
/// </value>
175
- public RemoveReason Reason { get ; private set ; }
176
-
177
- /// <summary>
178
- /// Initializes a new instance of the <see cref="RemovingStyleEventArgs"/> class.
179
- /// </summary>
180
- /// <param name="tag">The element containing the attribute.</param>
181
- /// <param name="style">The style to be removed.</param>
182
- /// <param name="reason">The reason why the attribute will be removed.</param>
183
- public RemovingStyleEventArgs ( IElement tag , ICssProperty style , RemoveReason reason )
184
- {
185
- Tag = tag ;
186
- Style = style ;
187
- Reason = reason ;
188
- }
156
+ public RemoveReason Reason { get ; private set ; } = reason ;
189
157
}
190
158
191
159
/// <summary>
192
160
/// Provides data for the <see cref="HtmlSanitizer.RemovingAtRule"/> event.
193
161
/// </summary>
194
- public class RemovingAtRuleEventArgs : CancelEventArgs
162
+ /// <remarks>
163
+ /// Initializes a new instance of the <see cref="RemovingAtRuleEventArgs"/> class.
164
+ /// </remarks>
165
+ /// <param name="tag">The element containing the attribute.</param>
166
+ /// <param name="rule">The rule to be removed.</param>
167
+ public class RemovingAtRuleEventArgs ( IElement tag , ICssRule rule ) : CancelEventArgs
195
168
{
196
169
/// <summary>
197
170
/// Gets the tag containing the at-rule to be removed.
198
171
/// </summary>
199
172
/// <value>
200
173
/// The tag.
201
174
/// </value>
202
- public IElement Tag { get ; private set ; }
175
+ public IElement Tag { get ; private set ; } = tag ;
203
176
204
177
/// <summary>
205
178
/// Gets the rule to be removed.
206
179
/// </summary>
207
180
/// <value>
208
181
/// The rule.
209
182
/// </value>
210
- public ICssRule Rule { get ; private set ; }
211
-
212
- /// <summary>
213
- /// Initializes a new instance of the <see cref="RemovingAtRuleEventArgs"/> class.
214
- /// </summary>
215
- /// <param name="tag">The element containing the attribute.</param>
216
- /// <param name="rule">The rule to be removed.</param>
217
- public RemovingAtRuleEventArgs ( IElement tag , ICssRule rule )
218
- {
219
- Tag = tag ;
220
- Rule = rule ;
221
- }
183
+ public ICssRule Rule { get ; private set ; } = rule ;
222
184
}
223
185
224
186
/// <summary>
225
187
/// Provides data for the <see cref="HtmlSanitizer.RemovingComment"/> event.
226
188
/// </summary>
227
- public class RemovingCommentEventArgs : CancelEventArgs
189
+ /// <remarks>
190
+ /// Initializes a new instance of the <see cref="RemovingCommentEventArgs"/> class.
191
+ /// </remarks>
192
+ /// <param name="comment">The comment to be removed.</param>
193
+ public class RemovingCommentEventArgs ( IComment comment ) : CancelEventArgs
228
194
{
229
195
/// <summary>
230
196
/// Gets the comment node to be removed.
231
197
/// </summary>
232
198
/// <value>
233
199
/// The comment node.
234
200
/// </value>
235
- public IComment Comment { get ; private set ; }
236
-
237
- /// <summary>
238
- /// Initializes a new instance of the <see cref="RemovingCommentEventArgs"/> class.
239
- /// </summary>
240
- /// <param name="comment">The comment to be removed.</param>
241
- public RemovingCommentEventArgs ( IComment comment )
242
- {
243
- Comment = comment ;
244
- }
201
+ public IComment Comment { get ; private set ; } = comment ;
245
202
}
246
203
247
204
/// <summary>
248
205
/// Provides data for the <see cref="HtmlSanitizer.RemovingCssClass"/> event.
249
206
/// </summary>
250
- public class RemovingCssClassEventArgs : CancelEventArgs
207
+ /// <remarks>
208
+ /// Initializes a new instance of the <see cref="RemovingCssClassEventArgs"/> class.
209
+ /// </remarks>
210
+ /// <param name="tag">The element containing the attribute.</param>
211
+ /// <param name="cssClass">The CSS class to be removed.</param>
212
+ /// <param name="reason">The reason why the attribute will be removed.</param>
213
+ public class RemovingCssClassEventArgs ( IElement tag , string cssClass , RemoveReason reason ) : CancelEventArgs
251
214
{
252
215
/// <summary>
253
216
/// Gets the tag containing the CSS class to be removed.
254
217
/// </summary>
255
218
/// <value>
256
219
/// The tag.
257
220
/// </value>
258
- public IElement Tag { get ; private set ; }
221
+ public IElement Tag { get ; private set ; } = tag ;
259
222
260
223
/// <summary>
261
224
/// Gets the CSS class to be removed.
262
225
/// </summary>
263
226
/// <value>
264
227
/// The CSS class.
265
228
/// </value>
266
- public string CssClass { get ; private set ; }
229
+ public string CssClass { get ; private set ; } = cssClass ;
267
230
268
231
/// <summary>
269
232
/// Gets the reason why the CSS class will be removed.
270
233
/// </summary>
271
234
/// <value>
272
235
/// The reason.
273
236
/// </value>
274
- public RemoveReason Reason { get ; private set ; }
275
-
276
- /// <summary>
277
- /// Initializes a new instance of the <see cref="RemovingCssClassEventArgs"/> class.
278
- /// </summary>
279
- /// <param name="tag">The element containing the attribute.</param>
280
- /// <param name="cssClass">The CSS class to be removed.</param>
281
- /// <param name="reason">The reason why the attribute will be removed.</param>
282
- public RemovingCssClassEventArgs ( IElement tag , string cssClass , RemoveReason reason )
283
- {
284
- Tag = tag ;
285
- CssClass = cssClass ;
286
- Reason = reason ;
287
- }
237
+ public RemoveReason Reason { get ; private set ; } = reason ;
288
238
}
289
239
290
240
/// <summary>
291
241
/// Provides data for the <see cref="HtmlSanitizer.FilterUrl"/> event.
292
242
/// </summary>
293
- public class FilterUrlEventArgs : EventArgs
243
+ /// <remarks>
244
+ /// Initializes a new instance of the <see cref="FilterUrlEventArgs"/> class.
245
+ /// </remarks>
246
+ /// <param name="tag">The tag containing the URI being sanitized.</param>
247
+ /// <param name="originalUrl">The original URL.</param>
248
+ /// <param name="sanitizedUrl">The sanitized URL.</param>
249
+ public class FilterUrlEventArgs ( IElement tag , string originalUrl , string ? sanitizedUrl = null ) : EventArgs
294
250
{
295
251
/// <summary>
296
252
/// Gets the original URL.
297
253
/// </summary>
298
254
/// <value>
299
255
/// The original URL.
300
256
/// </value>
301
- public string OriginalUrl { get ; private set ; }
257
+ public string OriginalUrl { get ; private set ; } = originalUrl ;
302
258
303
259
/// <summary>
304
260
/// Gets or sets the sanitized URL.
305
261
/// </summary>
306
262
/// <value>
307
263
/// The sanitized URL. If it is null, it will be removed.
308
264
/// </value>
309
- public string ? SanitizedUrl { get ; set ; }
265
+ public string ? SanitizedUrl { get ; set ; } = sanitizedUrl ;
310
266
311
267
/// <summary>
312
268
/// Gets the tag containing the URI being sanitized.
313
269
/// </summary>
314
270
/// <value>
315
271
/// The tag.
316
272
/// </value>
317
- public IElement Tag { get ; private set ; }
318
-
319
- /// <summary>
320
- /// Initializes a new instance of the <see cref="FilterUrlEventArgs"/> class.
321
- /// </summary>
322
- /// <param name="tag">The tag containing the URI being sanitized.</param>
323
- /// <param name="originalUrl">The original URL.</param>
324
- /// <param name="sanitizedUrl">The sanitized URL.</param>
325
- public FilterUrlEventArgs ( IElement tag , string originalUrl , string ? sanitizedUrl = null )
326
- {
327
- OriginalUrl = originalUrl ;
328
- SanitizedUrl = sanitizedUrl ;
329
- Tag = tag ;
330
- }
273
+ public IElement Tag { get ; private set ; } = tag ;
331
274
}
332
275
}
0 commit comments