Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit ca07b6e

Browse files
author
Praburaj
committed
Using new encoders over the old encoders.
1 parent 8ca2728 commit ca07b6e

File tree

16 files changed

+83
-88
lines changed

16 files changed

+83
-88
lines changed

src/Microsoft.AspNet.Http.Core/Authentication/AuthenticateContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Generic;
55
using System.Security.Claims;
66
using Microsoft.AspNet.Http.Authentication;
7-
using Microsoft.AspNet.Http.Authentication;
87

98
namespace Microsoft.AspNet.Http.Core.Authentication
109
{

src/Microsoft.AspNet.Http.Core/Authentication/DescribeSchemesContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Collections.Generic;
55
using Microsoft.AspNet.Http.Authentication;
6-
using Microsoft.AspNet.Http.Authentication;
76

87
namespace Microsoft.AspNet.Http.Core.Authentication
98
{

src/Microsoft.AspNet.Http.Core/Collections/ResponseCookies.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using System.Collections.Generic;
66
using System.Globalization;
77
using System.Linq;
8-
using Microsoft.AspNet.Http;
98
using Microsoft.AspNet.Http.Infrastructure;
9+
using Microsoft.Framework.WebEncoders;
1010

1111
namespace Microsoft.AspNet.Http.Core.Collections
1212
{
@@ -33,7 +33,7 @@ public ResponseCookies([NotNull] IHeaderDictionary headers)
3333
/// <param name="value"></param>
3434
public void Append(string key, string value)
3535
{
36-
Headers.AppendValues(Constants.Headers.SetCookie, Uri.EscapeDataString(key) + "=" + Uri.EscapeDataString(value) + "; path=/");
36+
Headers.AppendValues(Constants.Headers.SetCookie, UrlEncoder.Default.UrlEncode(key) + "=" + UrlEncoder.Default.UrlEncode(value) + "; path=/");
3737
}
3838

3939
/// <summary>
@@ -49,9 +49,9 @@ public void Append(string key, string value, [NotNull] CookieOptions options)
4949
bool expiresHasValue = options.Expires.HasValue;
5050

5151
string setCookieValue = string.Concat(
52-
Uri.EscapeDataString(key),
52+
UrlEncoder.Default.UrlEncode(key),
5353
"=",
54-
Uri.EscapeDataString(value ?? string.Empty),
54+
UrlEncoder.Default.UrlEncode(value ?? string.Empty),
5555
!domainHasValue ? null : "; domain=",
5656
!domainHasValue ? null : options.Domain,
5757
!pathHasValue ? null : "; path=",
@@ -71,7 +71,7 @@ public void Delete(string key)
7171
{
7272
Func<string, bool> predicate = value => value.StartsWith(key + "=", StringComparison.OrdinalIgnoreCase);
7373

74-
var deleteCookies = new[] { Uri.EscapeDataString(key) + "=; expires=Thu, 01-Jan-1970 00:00:00 GMT" };
74+
var deleteCookies = new[] { UrlEncoder.Default.UrlEncode(key) + "=; expires=Thu, 01-Jan-1970 00:00:00 GMT" };
7575
IList<string> existingValues = Headers.GetValues(Constants.Headers.SetCookie);
7676
if (existingValues == null || existingValues.Count == 0)
7777
{

src/Microsoft.AspNet.Http.Core/Collections/SessionCollection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
using System;
55
using System.Collections;
66
using System.Collections.Generic;
7-
using Microsoft.AspNet.Http;
8-
using Microsoft.AspNet.Http;
97

108
namespace Microsoft.AspNet.Http.Core.Collections
119
{

src/Microsoft.AspNet.Http.Core/QueryFeature.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
using System.Collections.Generic;
55
using Microsoft.AspNet.FeatureModel;
6-
using Microsoft.AspNet.Http;
7-
using Microsoft.AspNet.Http;
86
using Microsoft.AspNet.Http.Core.Collections;
97
using Microsoft.AspNet.Http.Core.Infrastructure;
108
using Microsoft.AspNet.WebUtilities;

src/Microsoft.AspNet.Http.Core/RequestCookiesFeature.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
using System;
55
using System.Collections.Generic;
66
using Microsoft.AspNet.FeatureModel;
7-
using Microsoft.AspNet.Http;
8-
using Microsoft.AspNet.Http.Infrastructure;
9-
using Microsoft.AspNet.Http;
107
using Microsoft.AspNet.Http.Core.Collections;
118
using Microsoft.AspNet.Http.Core.Infrastructure;
9+
using Microsoft.AspNet.Http.Infrastructure;
1210

1311
namespace Microsoft.AspNet.Http.Core
1412
{

src/Microsoft.AspNet.Http.Core/ResponseCookiesFeature.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using Microsoft.AspNet.Http;
54
using Microsoft.AspNet.FeatureModel;
6-
using Microsoft.AspNet.Http;
75
using Microsoft.AspNet.Http.Core.Collections;
86
using Microsoft.AspNet.Http.Core.Infrastructure;
97

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
2-
{
3-
"version": "1.0.0-*",
4-
"description": "ASP.NET 5 HTTP feature implementations.",
5-
"dependencies": {
6-
"Microsoft.AspNet.FeatureModel": "1.0.0-*",
7-
"Microsoft.AspNet.Http": "1.0.0-*",
8-
"Microsoft.AspNet.Http.Interfaces": "1.0.0-*",
9-
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
10-
"Microsoft.Net.Http.Headers": "1.0.0-*"
11-
12-
},
13-
"frameworks": {
14-
"dnx451": {},
15-
"dnxcore50": {
16-
"dependencies": {
17-
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
18-
"System.Collections": "4.0.10-beta-*",
19-
"System.ComponentModel": "4.0.0-beta-*",
20-
"System.Diagnostics.Debug": "4.0.10-beta-*",
21-
"System.Diagnostics.Tools": "4.0.0-beta-*",
22-
"System.Globalization": "4.0.10-beta-*",
23-
"System.IO": "4.0.10-beta-*",
24-
"System.Linq": "4.0.0-beta-*",
25-
"System.Runtime": "4.0.20-beta-*",
26-
"System.Runtime.Extensions": "4.0.10-beta-*",
27-
"System.Runtime.InteropServices": "4.0.20-beta-*",
28-
"System.Security.Claims": "4.0.0-beta-*",
29-
"System.Security.Principal" : "4.0.0-beta-*",
30-
"System.Text.Encoding": "4.0.10-beta-*",
31-
"System.Threading.Tasks": "4.0.10-beta-*"
32-
}
1+
{
2+
"version": "1.0.0-*",
3+
"description": "ASP.NET 5 HTTP feature implementations.",
4+
"dependencies": {
5+
"Microsoft.AspNet.FeatureModel": "1.0.0-*",
6+
"Microsoft.AspNet.Http": "1.0.0-*",
7+
"Microsoft.AspNet.Http.Interfaces": "1.0.0-*",
8+
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
9+
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*",
10+
"Microsoft.Net.Http.Headers": "1.0.0-*"
11+
},
12+
"frameworks": {
13+
"dnx451": { },
14+
"dnxcore50": {
15+
"dependencies": {
16+
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
17+
"System.Collections": "4.0.10-beta-*",
18+
"System.ComponentModel": "4.0.0-beta-*",
19+
"System.Diagnostics.Debug": "4.0.10-beta-*",
20+
"System.Diagnostics.Tools": "4.0.0-beta-*",
21+
"System.Globalization": "4.0.10-beta-*",
22+
"System.IO": "4.0.10-beta-*",
23+
"System.Linq": "4.0.0-beta-*",
24+
"System.Runtime": "4.0.20-beta-*",
25+
"System.Runtime.Extensions": "4.0.10-beta-*",
26+
"System.Runtime.InteropServices": "4.0.20-beta-*",
27+
"System.Security.Claims": "4.0.0-beta-*",
28+
"System.Security.Principal": "4.0.0-beta-*",
29+
"System.Text.Encoding": "4.0.10-beta-*",
30+
"System.Threading.Tasks": "4.0.10-beta-*"
31+
}
32+
}
3333
}
34-
}
35-
}
34+
}

src/Microsoft.AspNet.Http.Extensions/QueryBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Collections;
65
using System.Collections.Generic;
76
using System.Text;
7+
using Microsoft.Framework.WebEncoders;
88

99
namespace Microsoft.AspNet.Http.Extensions
1010
{
@@ -45,9 +45,9 @@ public override string ToString()
4545
var pair = _params[i];
4646
builder.Append(first ? "?" : "&");
4747
first = false;
48-
builder.Append(Uri.EscapeDataString(pair.Key));
48+
builder.Append(UrlEncoder.Default.UrlEncode(pair.Key));
4949
builder.Append("=");
50-
builder.Append(Uri.EscapeDataString(pair.Value));
50+
builder.Append(UrlEncoder.Default.UrlEncode(pair.Value));
5151
}
5252

5353
return builder.ToString();

src/Microsoft.AspNet.Http.Extensions/project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"Microsoft.AspNet.Http": "1.0.0-*",
66
"Microsoft.AspNet.Http.Interfaces": "1.0.0-*",
77
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
8+
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*",
89
"Microsoft.Net.Http.Headers": "1.0.0-*"
910
},
10-
"frameworks" : {
11-
"dnx451" : {
11+
"frameworks": {
12+
"dnx451": {
1213
},
13-
"dnxcore50" : {
14+
"dnxcore50": {
1415
"dependencies": {
1516
"System.Reflection.TypeExtensions": "4.0.0-beta-*",
1617
"System.Runtime": "4.0.20-beta-*"

src/Microsoft.AspNet.Http/PathString.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Linq;
6+
using Microsoft.Framework.WebEncoders;
67

78
namespace Microsoft.AspNet.Http
89
{
@@ -65,7 +66,7 @@ public override string ToString()
6566
public string ToUriComponent()
6667
{
6768
// TODO: Measure the cost of this escaping and consider optimizing.
68-
return HasValue ? String.Join("/", _value.Split('/').Select(Uri.EscapeDataString)) : String.Empty;
69+
return HasValue ? string.Join("/", _value.Split('/').Select(UrlEncoder.Default.UrlEncode)) : string.Empty;
6970
}
7071

7172
/// <summary>

src/Microsoft.AspNet.Http/QueryString.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using Microsoft.Framework.WebEncoders;
56

67
namespace Microsoft.AspNet.Http
78
{
@@ -38,7 +39,7 @@ public QueryString(string value)
3839
/// <param name="value">The un-encoded parameter value</param>
3940
public QueryString(string name, string value)
4041
{
41-
_value = "?" + Uri.EscapeDataString(name) + '=' + Uri.EscapeDataString(value);
42+
_value = "?" + UrlEncoder.Default.UrlEncode(name) + '=' + UrlEncoder.Default.UrlEncode(value);
4243
}
4344

4445
/// <summary>
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
{
2-
"version": "1.0.0-*",
3-
"description": "ASP.NET 5 HTTP object model. HttpContext and family.",
4-
"dependencies": {},
5-
"frameworks": {
6-
"dnx451": {},
7-
"dnxcore50": {
8-
"dependencies": {
9-
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
10-
"System.Collections": "4.0.10-beta-*",
11-
"System.ComponentModel": "4.0.0-beta-*",
12-
"System.Diagnostics.Tools": "4.0.0-beta-*",
13-
"System.Globalization": "4.0.10-beta-*",
14-
"System.Globalization.Extensions": "4.0.0-beta-*",
15-
"System.IO": "4.0.10-beta-*",
16-
"System.Linq": "4.0.0-beta-*",
17-
"System.Runtime": "4.0.20-beta-*",
18-
"System.Runtime.Extensions": "4.0.10-beta-*",
19-
"System.Runtime.InteropServices": "4.0.20-beta-*",
20-
"System.Security.Claims": "4.0.0-beta-*",
21-
"System.Security.Principal" : "4.0.0-beta-*",
22-
"System.Threading.Tasks": "4.0.10-beta-*"
23-
}
1+
{
2+
"version": "1.0.0-*",
3+
"description": "ASP.NET 5 HTTP object model. HttpContext and family.",
4+
"dependencies": {
5+
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
6+
},
7+
"frameworks": {
8+
"dnx451": { },
9+
"dnxcore50": {
10+
"dependencies": {
11+
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
12+
"System.Collections": "4.0.10-beta-*",
13+
"System.ComponentModel": "4.0.0-beta-*",
14+
"System.Diagnostics.Tools": "4.0.0-beta-*",
15+
"System.Globalization": "4.0.10-beta-*",
16+
"System.Globalization.Extensions": "4.0.0-beta-*",
17+
"System.IO": "4.0.10-beta-*",
18+
"System.Linq": "4.0.0-beta-*",
19+
"System.Runtime": "4.0.20-beta-*",
20+
"System.Runtime.Extensions": "4.0.10-beta-*",
21+
"System.Runtime.InteropServices": "4.0.20-beta-*",
22+
"System.Security.Claims": "4.0.0-beta-*",
23+
"System.Security.Principal": "4.0.0-beta-*",
24+
"System.Threading.Tasks": "4.0.10-beta-*"
25+
}
26+
}
2427
}
25-
}
26-
}
28+
}

src/Microsoft.AspNet.Owin/OwinEnvironment.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
using System.Threading;
1515
using System.Threading.Tasks;
1616
using Microsoft.AspNet.Http;
17-
using Microsoft.AspNet.Http.Core.Authentication;
18-
using Microsoft.AspNet.Http;
1917
using Microsoft.AspNet.Http.Authentication;
18+
using Microsoft.AspNet.Http.Core.Authentication;
2019

2120
namespace Microsoft.AspNet.Owin
2221
{

src/Microsoft.AspNet.WebUtilities/QueryHelpers.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Text;
7+
using Microsoft.Framework.WebEncoders;
78

89
namespace Microsoft.AspNet.WebUtilities
910
{
@@ -19,7 +20,7 @@ public static class QueryHelpers
1920
public static string AddQueryString([NotNull] string uri, [NotNull] string name, [NotNull] string value)
2021
{
2122
bool hasQuery = uri.IndexOf('?') != -1;
22-
return uri + (hasQuery ? "&" : "?") + Uri.EscapeDataString(name) + "=" + Uri.EscapeDataString(value);
23+
return uri + (hasQuery ? "&" : "?") + UrlEncoder.Default.UrlEncode(name) + "=" + UrlEncoder.Default.UrlEncode(value);
2324
}
2425

2526
/// <summary>
@@ -36,9 +37,9 @@ public static string AddQueryString([NotNull] string uri, [NotNull] IDictionary<
3637
foreach (var parameter in queryString)
3738
{
3839
sb.Append(hasQuery ? '&' : '?');
39-
sb.Append(Uri.EscapeDataString(parameter.Key));
40+
sb.Append(UrlEncoder.Default.UrlEncode(parameter.Key));
4041
sb.Append('=');
41-
sb.Append(Uri.EscapeDataString(parameter.Value));
42+
sb.Append(UrlEncoder.Default.UrlEncode(parameter.Value));
4243
hasQuery = true;
4344
}
4445
return sb.ToString();

src/Microsoft.AspNet.WebUtilities/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "1.0.0-*",
33
"description": "ASP.NET 5 common helper methods.",
44
"dependencies": {
5+
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
56
},
67
"frameworks": {
78
"dnx451": { },

0 commit comments

Comments
 (0)