Using new encoders over the old encoders.
This commit is contained in:
parent
8ca2728ef8
commit
ca07b6e2fd
|
|
@ -4,7 +4,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Core.Authentication
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Core.Authentication
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Infrastructure;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Core.Collections
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Http.Core.Collections
|
|||
/// <param name="value"></param>
|
||||
public void Append(string key, string value)
|
||||
{
|
||||
Headers.AppendValues(Constants.Headers.SetCookie, Uri.EscapeDataString(key) + "=" + Uri.EscapeDataString(value) + "; path=/");
|
||||
Headers.AppendValues(Constants.Headers.SetCookie, UrlEncoder.Default.UrlEncode(key) + "=" + UrlEncoder.Default.UrlEncode(value) + "; path=/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -49,9 +49,9 @@ namespace Microsoft.AspNet.Http.Core.Collections
|
|||
bool expiresHasValue = options.Expires.HasValue;
|
||||
|
||||
string setCookieValue = string.Concat(
|
||||
Uri.EscapeDataString(key),
|
||||
UrlEncoder.Default.UrlEncode(key),
|
||||
"=",
|
||||
Uri.EscapeDataString(value ?? string.Empty),
|
||||
UrlEncoder.Default.UrlEncode(value ?? string.Empty),
|
||||
!domainHasValue ? null : "; domain=",
|
||||
!domainHasValue ? null : options.Domain,
|
||||
!pathHasValue ? null : "; path=",
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Http.Core.Collections
|
|||
{
|
||||
Func<string, bool> predicate = value => value.StartsWith(key + "=", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
var deleteCookies = new[] { Uri.EscapeDataString(key) + "=; expires=Thu, 01-Jan-1970 00:00:00 GMT" };
|
||||
var deleteCookies = new[] { UrlEncoder.Default.UrlEncode(key) + "=; expires=Thu, 01-Jan-1970 00:00:00 GMT" };
|
||||
IList<string> existingValues = Headers.GetValues(Constants.Headers.SetCookie);
|
||||
if (existingValues == null || existingValues.Count == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Core.Collections
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Core.Collections;
|
||||
using Microsoft.AspNet.Http.Core.Infrastructure;
|
||||
using Microsoft.AspNet.WebUtilities;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Infrastructure;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Core.Collections;
|
||||
using Microsoft.AspNet.Http.Core.Infrastructure;
|
||||
using Microsoft.AspNet.Http.Infrastructure;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Core
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Core.Collections;
|
||||
using Microsoft.AspNet.Http.Core.Infrastructure;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,34 @@
|
|||
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "ASP.NET 5 HTTP feature implementations.",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.FeatureModel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http.Interfaces": "1.0.0-*",
|
||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||
"Microsoft.Net.Http.Headers": "1.0.0-*"
|
||||
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
|
||||
"System.Collections": "4.0.10-beta-*",
|
||||
"System.ComponentModel": "4.0.0-beta-*",
|
||||
"System.Diagnostics.Debug": "4.0.10-beta-*",
|
||||
"System.Diagnostics.Tools": "4.0.0-beta-*",
|
||||
"System.Globalization": "4.0.10-beta-*",
|
||||
"System.IO": "4.0.10-beta-*",
|
||||
"System.Linq": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.20-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.10-beta-*",
|
||||
"System.Runtime.InteropServices": "4.0.20-beta-*",
|
||||
"System.Security.Claims": "4.0.0-beta-*",
|
||||
"System.Security.Principal" : "4.0.0-beta-*",
|
||||
"System.Text.Encoding": "4.0.10-beta-*",
|
||||
"System.Threading.Tasks": "4.0.10-beta-*"
|
||||
}
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "ASP.NET 5 HTTP feature implementations.",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.FeatureModel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http.Interfaces": "1.0.0-*",
|
||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*",
|
||||
"Microsoft.Net.Http.Headers": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
|
||||
"System.Collections": "4.0.10-beta-*",
|
||||
"System.ComponentModel": "4.0.0-beta-*",
|
||||
"System.Diagnostics.Debug": "4.0.10-beta-*",
|
||||
"System.Diagnostics.Tools": "4.0.0-beta-*",
|
||||
"System.Globalization": "4.0.10-beta-*",
|
||||
"System.IO": "4.0.10-beta-*",
|
||||
"System.Linq": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.20-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.10-beta-*",
|
||||
"System.Runtime.InteropServices": "4.0.20-beta-*",
|
||||
"System.Security.Claims": "4.0.0-beta-*",
|
||||
"System.Security.Principal": "4.0.0-beta-*",
|
||||
"System.Text.Encoding": "4.0.10-beta-*",
|
||||
"System.Threading.Tasks": "4.0.10-beta-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Http.Extensions
|
||||
{
|
||||
|
|
@ -45,9 +45,9 @@ namespace Microsoft.AspNet.Http.Extensions
|
|||
var pair = _params[i];
|
||||
builder.Append(first ? "?" : "&");
|
||||
first = false;
|
||||
builder.Append(Uri.EscapeDataString(pair.Key));
|
||||
builder.Append(UrlEncoder.Default.UrlEncode(pair.Key));
|
||||
builder.Append("=");
|
||||
builder.Append(Uri.EscapeDataString(pair.Value));
|
||||
builder.Append(UrlEncoder.Default.UrlEncode(pair.Value));
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@
|
|||
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http.Interfaces": "1.0.0-*",
|
||||
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*",
|
||||
"Microsoft.Net.Http.Headers": "1.0.0-*"
|
||||
},
|
||||
"frameworks" : {
|
||||
"dnx451" : {
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
},
|
||||
"dnxcore50" : {
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Reflection.TypeExtensions": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.20-beta-*"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -65,7 +66,7 @@ namespace Microsoft.AspNet.Http
|
|||
public string ToUriComponent()
|
||||
{
|
||||
// TODO: Measure the cost of this escaping and consider optimizing.
|
||||
return HasValue ? String.Join("/", _value.Split('/').Select(Uri.EscapeDataString)) : String.Empty;
|
||||
return HasValue ? string.Join("/", _value.Split('/').Select(UrlEncoder.Default.UrlEncode)) : string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.Http
|
||||
{
|
||||
|
|
@ -38,7 +39,7 @@ namespace Microsoft.AspNet.Http
|
|||
/// <param name="value">The un-encoded parameter value</param>
|
||||
public QueryString(string name, string value)
|
||||
{
|
||||
_value = "?" + Uri.EscapeDataString(name) + '=' + Uri.EscapeDataString(value);
|
||||
_value = "?" + UrlEncoder.Default.UrlEncode(name) + '=' + UrlEncoder.Default.UrlEncode(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,26 +1,28 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "ASP.NET 5 HTTP object model. HttpContext and family.",
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
|
||||
"System.Collections": "4.0.10-beta-*",
|
||||
"System.ComponentModel": "4.0.0-beta-*",
|
||||
"System.Diagnostics.Tools": "4.0.0-beta-*",
|
||||
"System.Globalization": "4.0.10-beta-*",
|
||||
"System.Globalization.Extensions": "4.0.0-beta-*",
|
||||
"System.IO": "4.0.10-beta-*",
|
||||
"System.Linq": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.20-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.10-beta-*",
|
||||
"System.Runtime.InteropServices": "4.0.20-beta-*",
|
||||
"System.Security.Claims": "4.0.0-beta-*",
|
||||
"System.Security.Principal" : "4.0.0-beta-*",
|
||||
"System.Threading.Tasks": "4.0.10-beta-*"
|
||||
}
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "ASP.NET 5 HTTP object model. HttpContext and family.",
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"Microsoft.Net.WebSocketAbstractions": "1.0.0-*",
|
||||
"System.Collections": "4.0.10-beta-*",
|
||||
"System.ComponentModel": "4.0.0-beta-*",
|
||||
"System.Diagnostics.Tools": "4.0.0-beta-*",
|
||||
"System.Globalization": "4.0.10-beta-*",
|
||||
"System.Globalization.Extensions": "4.0.0-beta-*",
|
||||
"System.IO": "4.0.10-beta-*",
|
||||
"System.Linq": "4.0.0-beta-*",
|
||||
"System.Runtime": "4.0.20-beta-*",
|
||||
"System.Runtime.Extensions": "4.0.10-beta-*",
|
||||
"System.Runtime.InteropServices": "4.0.20-beta-*",
|
||||
"System.Security.Claims": "4.0.0-beta-*",
|
||||
"System.Security.Principal": "4.0.0-beta-*",
|
||||
"System.Threading.Tasks": "4.0.10-beta-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,9 +14,8 @@ using System.Security.Principal;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Core.Authentication;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.AspNet.Http.Core.Authentication;
|
||||
|
||||
namespace Microsoft.AspNet.Owin
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Framework.WebEncoders;
|
||||
|
||||
namespace Microsoft.AspNet.WebUtilities
|
||||
{
|
||||
|
|
@ -19,7 +20,7 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
public static string AddQueryString([NotNull] string uri, [NotNull] string name, [NotNull] string value)
|
||||
{
|
||||
bool hasQuery = uri.IndexOf('?') != -1;
|
||||
return uri + (hasQuery ? "&" : "?") + Uri.EscapeDataString(name) + "=" + Uri.EscapeDataString(value);
|
||||
return uri + (hasQuery ? "&" : "?") + UrlEncoder.Default.UrlEncode(name) + "=" + UrlEncoder.Default.UrlEncode(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -36,9 +37,9 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
foreach (var parameter in queryString)
|
||||
{
|
||||
sb.Append(hasQuery ? '&' : '?');
|
||||
sb.Append(Uri.EscapeDataString(parameter.Key));
|
||||
sb.Append(UrlEncoder.Default.UrlEncode(parameter.Key));
|
||||
sb.Append('=');
|
||||
sb.Append(Uri.EscapeDataString(parameter.Value));
|
||||
sb.Append(UrlEncoder.Default.UrlEncode(parameter.Value));
|
||||
hasQuery = true;
|
||||
}
|
||||
return sb.ToString();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"version": "1.0.0-*",
|
||||
"description": "ASP.NET 5 common helper methods.",
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
|
|
|
|||
Loading…
Reference in New Issue