You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
@ -78,12 +78,6 @@ namespace System.Web.Util {
|
||||
w.Write ((long) value);
|
||||
break;
|
||||
case TypeCode.Object:
|
||||
#if TARGET_J2EE
|
||||
if (w.BaseStream is java.io.ObjectOutput) {
|
||||
((java.io.ObjectOutput) w.BaseStream).writeObject (value);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
BinaryFormatter bf = new BinaryFormatter ();
|
||||
bf.Serialize (w.BaseStream, value);
|
||||
break;
|
||||
@ -136,10 +130,6 @@ namespace System.Web.Util {
|
||||
case TypeCode.Int64:
|
||||
return r.ReadInt64 ();
|
||||
case TypeCode.Object:
|
||||
#if TARGET_J2EE
|
||||
if (r.BaseStream is java.io.ObjectInput)
|
||||
return ((java.io.ObjectInput) r.BaseStream).readObject ();
|
||||
#endif
|
||||
BinaryFormatter bf = new BinaryFormatter ();
|
||||
return bf.Deserialize (r.BaseStream);
|
||||
case TypeCode.SByte:
|
||||
|
@ -41,20 +41,14 @@ using System.Web.Configuration;
|
||||
|
||||
namespace System.Web.Util
|
||||
{
|
||||
#if NET_4_0
|
||||
public
|
||||
#endif
|
||||
class HttpEncoder
|
||||
{
|
||||
static char [] hexChars = "0123456789abcdef".ToCharArray ();
|
||||
static object entitiesLock = new object ();
|
||||
static SortedDictionary <string, char> entities;
|
||||
#if NET_4_0
|
||||
static Lazy <HttpEncoder> defaultEncoder;
|
||||
static Lazy <HttpEncoder> currentEncoderLazy;
|
||||
#else
|
||||
static HttpEncoder defaultEncoder;
|
||||
#endif
|
||||
static HttpEncoder currentEncoder;
|
||||
|
||||
static IDictionary <string, char> Entities {
|
||||
@ -70,50 +64,33 @@ namespace System.Web.Util
|
||||
|
||||
public static HttpEncoder Current {
|
||||
get {
|
||||
#if NET_4_0
|
||||
if (currentEncoder == null)
|
||||
currentEncoder = currentEncoderLazy.Value;
|
||||
#endif
|
||||
return currentEncoder;
|
||||
}
|
||||
#if NET_4_0
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException ("value");
|
||||
currentEncoder = value;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static HttpEncoder Default {
|
||||
get {
|
||||
#if NET_4_0
|
||||
return defaultEncoder.Value;
|
||||
#else
|
||||
return defaultEncoder;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static HttpEncoder ()
|
||||
{
|
||||
#if NET_4_0
|
||||
defaultEncoder = new Lazy <HttpEncoder> (() => new HttpEncoder ());
|
||||
currentEncoderLazy = new Lazy <HttpEncoder> (new Func <HttpEncoder> (GetCustomEncoderFromConfig));
|
||||
#else
|
||||
defaultEncoder = new HttpEncoder ();
|
||||
currentEncoder = defaultEncoder;
|
||||
#endif
|
||||
}
|
||||
|
||||
public HttpEncoder ()
|
||||
{
|
||||
}
|
||||
#if NET_4_0
|
||||
protected internal virtual
|
||||
#else
|
||||
internal static
|
||||
#endif
|
||||
void HeaderNameValueEncode (string headerName, string headerValue, out string encodedHeaderName, out string encodedHeaderValue)
|
||||
{
|
||||
if (String.IsNullOrEmpty (headerName))
|
||||
@ -151,7 +128,6 @@ namespace System.Web.Util
|
||||
|
||||
return input;
|
||||
}
|
||||
#if NET_4_0
|
||||
protected internal virtual void HtmlAttributeEncode (string value, TextWriter output)
|
||||
{
|
||||
|
||||
@ -208,12 +184,7 @@ namespace System.Web.Util
|
||||
return Activator.CreateInstance (t, false) as HttpEncoder;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if NET_4_0
|
||||
protected internal virtual
|
||||
#else
|
||||
internal static
|
||||
#endif
|
||||
string UrlPathEncode (string value)
|
||||
{
|
||||
if (String.IsNullOrEmpty (value))
|
||||
@ -262,9 +233,7 @@ namespace System.Web.Util
|
||||
for (int i = 0; i < s.Length; i++) {
|
||||
char c = s [i];
|
||||
if (c == '&' || c == '"' || c == '<' || c == '>' || c > 159
|
||||
#if NET_4_0
|
||||
|| c == '\''
|
||||
#endif
|
||||
) {
|
||||
needEncode = true;
|
||||
break;
|
||||
@ -292,11 +261,9 @@ namespace System.Web.Util
|
||||
case '"' :
|
||||
output.Append (""");
|
||||
break;
|
||||
#if NET_4_0
|
||||
case '\'':
|
||||
output.Append ("'");
|
||||
break;
|
||||
#endif
|
||||
case '\uff1c':
|
||||
output.Append ("<");
|
||||
break;
|
||||
@ -321,23 +288,13 @@ namespace System.Web.Util
|
||||
|
||||
internal static string HtmlAttributeEncode (string s)
|
||||
{
|
||||
#if NET_4_0
|
||||
if (String.IsNullOrEmpty (s))
|
||||
return String.Empty;
|
||||
#else
|
||||
if (s == null)
|
||||
return null;
|
||||
|
||||
if (s.Length == 0)
|
||||
return String.Empty;
|
||||
#endif
|
||||
bool needEncode = false;
|
||||
for (int i = 0; i < s.Length; i++) {
|
||||
char c = s [i];
|
||||
if (c == '&' || c == '"' || c == '<'
|
||||
#if NET_4_0
|
||||
|| c == '\''
|
||||
#endif
|
||||
) {
|
||||
needEncode = true;
|
||||
break;
|
||||
@ -362,11 +319,9 @@ namespace System.Web.Util
|
||||
case '<':
|
||||
output.Append ("<");
|
||||
break;
|
||||
#if NET_4_0
|
||||
case '\'':
|
||||
output.Append ("'");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
output.Append (ch);
|
||||
break;
|
||||
@ -386,9 +341,7 @@ namespace System.Web.Util
|
||||
|
||||
if (s.IndexOf ('&') == -1)
|
||||
return s;
|
||||
#if NET_4_0
|
||||
StringBuilder rawEntity = new StringBuilder ();
|
||||
#endif
|
||||
StringBuilder entity = new StringBuilder ();
|
||||
StringBuilder output = new StringBuilder ();
|
||||
int len = s.Length;
|
||||
@ -406,9 +359,7 @@ namespace System.Web.Util
|
||||
if (state == 0) {
|
||||
if (c == '&') {
|
||||
entity.Append (c);
|
||||
#if NET_4_0
|
||||
rawEntity.Append (c);
|
||||
#endif
|
||||
state = 1;
|
||||
} else {
|
||||
output.Append (c);
|
||||
@ -444,9 +395,7 @@ namespace System.Web.Util
|
||||
state = 3;
|
||||
}
|
||||
entity.Append (c);
|
||||
#if NET_4_0
|
||||
rawEntity.Append (c);
|
||||
#endif
|
||||
}
|
||||
} else if (state == 2) {
|
||||
entity.Append (c);
|
||||
@ -458,17 +407,13 @@ namespace System.Web.Util
|
||||
output.Append (key);
|
||||
state = 0;
|
||||
entity.Length = 0;
|
||||
#if NET_4_0
|
||||
rawEntity.Length = 0;
|
||||
#endif
|
||||
}
|
||||
} else if (state == 3) {
|
||||
if (c == ';') {
|
||||
#if NET_4_0
|
||||
if (number == 0)
|
||||
output.Append (rawEntity.ToString () + ";");
|
||||
else
|
||||
#endif
|
||||
if (number > 65535) {
|
||||
output.Append ("&#");
|
||||
output.Append (number.ToString (Helpers.InvariantCulture));
|
||||
@ -478,27 +423,19 @@ namespace System.Web.Util
|
||||
}
|
||||
state = 0;
|
||||
entity.Length = 0;
|
||||
#if NET_4_0
|
||||
rawEntity.Length = 0;
|
||||
#endif
|
||||
have_trailing_digits = false;
|
||||
} else if (is_hex_value && Uri.IsHexDigit(c)) {
|
||||
number = number * 16 + Uri.FromHex(c);
|
||||
have_trailing_digits = true;
|
||||
#if NET_4_0
|
||||
rawEntity.Append (c);
|
||||
#endif
|
||||
} else if (Char.IsDigit (c)) {
|
||||
number = number * 10 + ((int) c - '0');
|
||||
have_trailing_digits = true;
|
||||
#if NET_4_0
|
||||
rawEntity.Append (c);
|
||||
#endif
|
||||
} else if (number == 0 && (c == 'x' || c == 'X')) {
|
||||
is_hex_value = true;
|
||||
#if NET_4_0
|
||||
rawEntity.Append (c);
|
||||
#endif
|
||||
} else {
|
||||
state = 2;
|
||||
if (have_trailing_digits) {
|
||||
@ -521,9 +458,6 @@ namespace System.Web.Util
|
||||
internal static bool NotEncoded (char c)
|
||||
{
|
||||
return (c == '!' || c == '(' || c == ')' || c == '*' || c == '-' || c == '.' || c == '_'
|
||||
#if !NET_4_0
|
||||
|| c == '\''
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
namespace System.Web.Util {
|
||||
|
||||
@ -36,4 +35,3 @@ namespace System.Web.Util {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
namespace System.Web.Util {
|
||||
|
||||
@ -37,4 +36,3 @@ namespace System.Web.Util {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,6 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
namespace System.Web.Util {
|
||||
|
||||
@ -101,12 +100,10 @@ namespace System.Web.Util {
|
||||
sa = TripleDES.Create ();
|
||||
break;
|
||||
default:
|
||||
#if NET_4_0
|
||||
if (name.StartsWith ("alg:")) {
|
||||
sa = SymmetricAlgorithm.Create (name.Substring (4));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
throw new ConfigurationErrorsException ();
|
||||
}
|
||||
return sa;
|
||||
@ -127,7 +124,6 @@ namespace System.Web.Util {
|
||||
case MachineKeyValidation.SHA1:
|
||||
kha = new HMACSHA1 ();
|
||||
break;
|
||||
#if NET_4_0
|
||||
case MachineKeyValidation.HMACSHA256:
|
||||
kha = new HMACSHA256 ();
|
||||
break;
|
||||
@ -143,7 +139,6 @@ namespace System.Web.Util {
|
||||
if (algo.StartsWith ("alg:"))
|
||||
kha = KeyedHashAlgorithm.Create (algo.Substring (4));
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return kha;
|
||||
}
|
||||
@ -312,4 +307,3 @@ namespace System.Web.Util {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,6 @@
|
||||
// Author:
|
||||
// Daniel Nauck <d.nauck(at)nauck-it.de>
|
||||
|
||||
#if NET_2_0
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@ -86,4 +85,3 @@ namespace System.Web.Util
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -98,36 +98,12 @@ namespace System.Web.Util {
|
||||
|
||||
public static bool IsNullOrEmpty (string value)
|
||||
{
|
||||
#if NET_2_0
|
||||
return String.IsNullOrEmpty (value);
|
||||
#else
|
||||
return value == null || value.Length == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string [] SplitRemoveEmptyEntries (string value, char [] separator)
|
||||
{
|
||||
#if NET_2_0
|
||||
return value.Split (separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
#else
|
||||
string [] parts = value.Split (separator);
|
||||
int delta = 0;
|
||||
for (int i = 0; i < parts.Length; i++) {
|
||||
if (IsNullOrEmpty (parts [i])) {
|
||||
delta++;
|
||||
}
|
||||
else {
|
||||
if (delta > 0)
|
||||
parts [i - delta] = parts [i];
|
||||
}
|
||||
}
|
||||
if (delta == 0)
|
||||
return parts;
|
||||
|
||||
string [] parts_copy = new string [parts.Length - delta];
|
||||
Array.Copy (parts, parts_copy, parts_copy.Length);
|
||||
return parts_copy;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,9 +203,7 @@ namespace System.Web.Util {
|
||||
return "/";
|
||||
|
||||
string str = String.Join ("/", parts, 0, dest);
|
||||
#if NET_2_0
|
||||
str = RemoveDoubleSlashes (str);
|
||||
#endif
|
||||
if (isRooted)
|
||||
str = "/" + str;
|
||||
if (endsWithSlash)
|
||||
@ -222,17 +220,12 @@ namespace System.Web.Util {
|
||||
if (last > 0) {
|
||||
if (last < url.Length)
|
||||
last++;
|
||||
#if NET_2_0
|
||||
return RemoveDoubleSlashes (url.Substring (0, last));
|
||||
#else
|
||||
return url.Substring (0, last);
|
||||
#endif
|
||||
}
|
||||
|
||||
return "/";
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
public static string RemoveDoubleSlashes (string input)
|
||||
{
|
||||
// MS VirtualPathUtility removes duplicate '/'
|
||||
@ -264,7 +257,6 @@ namespace System.Web.Util {
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
#endif
|
||||
|
||||
public static string GetFile (string url)
|
||||
{
|
||||
|
@ -36,7 +36,6 @@ namespace System.Web.Util
|
||||
{
|
||||
internal class WebEncoding
|
||||
{
|
||||
#if NET_2_0
|
||||
static bool cached;
|
||||
static GlobalizationSection sect;
|
||||
static GlobalizationSection GlobalizationConfig {
|
||||
@ -51,13 +50,6 @@ namespace System.Web.Util
|
||||
return sect;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static GlobalizationConfiguration GlobalizationConfig {
|
||||
get {
|
||||
return GlobalizationConfiguration.GetInstance (null);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static public Encoding FileEncoding {
|
||||
get {
|
||||
|
Reference in New Issue
Block a user