-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathHtmlEncode.cs
More file actions
20 lines (17 loc) · 860 Bytes
/
HtmlEncode.cs
File metadata and controls
20 lines (17 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Web.cs ${testdir}/../../../resources/stubs/System.Windows.cs /r:System.Collections.Specialized.dll ${testdir}/../../../resources/stubs/System.Net.cs /r:System.ComponentModel.Primitives.dll /r:System.ComponentModel.TypeConverter.dll ${testdir}/../../../resources/stubs/System.Data.cs /r:System.Data.Common.dll
using System;
using System.Web;
using System.Net;
public class HtmlEncode
{
public static void Bad(HttpContext ctx)
{
var user = WebUtility.UrlDecode(ctx.Request.QueryString["user"]);
ctx.Response.Write("Hello, " + WebUtility.UrlEncode(user));
}
public static void Good(HttpContext ctx)
{
var user = WebUtility.UrlDecode(ctx.Request.QueryString["user"]);
ctx.Response.Write("Hello, " + WebUtility.HtmlEncode(user));
}
}