From: Stephane Delcroix Date: Mon, 10 Mar 2008 09:23:00 +0000 (-0000) Subject: 2008-03-10 Stephane Delcroix X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=2c94c84127e7eedc6b64b3f7a9f33032b1a338a0;p=mono.git 2008-03-10 Stephane Delcroix * Uri.cs: port the changes I did in System.Uri in r97844. svn path=/trunk/mcs/; revision=97845 --- diff --git a/mcs/class/corlib/Mono.Security/ChangeLog b/mcs/class/corlib/Mono.Security/ChangeLog index 057e0d9f2c5..90bc20f2345 100644 --- a/mcs/class/corlib/Mono.Security/ChangeLog +++ b/mcs/class/corlib/Mono.Security/ChangeLog @@ -1,3 +1,7 @@ +2008-03-10 Stephane Delcroix + + * Uri.cs: port the changes I did in System.Uri in r97844. + 2007-03-11 Zoltan Varga * ASN1Convert.cs: Fix a warning. diff --git a/mcs/class/corlib/Mono.Security/Uri.cs b/mcs/class/corlib/Mono.Security/Uri.cs index bc8e63686ff..e9ac8ae299e 100644 --- a/mcs/class/corlib/Mono.Security/Uri.cs +++ b/mcs/class/corlib/Mono.Security/Uri.cs @@ -8,6 +8,7 @@ // Ian MacLean (ianm@activestate.com) // Ben Maurer (bmaurer@users.sourceforge.net) // Atsushi Enomoto (atsushi@ximian.com) +// Stephane Delcroix // // (C) 2001 Garrett Rooney // (C) 2003 Ian MacLean @@ -777,11 +778,9 @@ namespace Mono.Security { if (str == null) return String.Empty; - byte [] data = Encoding.UTF8.GetBytes (str.ToCharArray ()); StringBuilder s = new StringBuilder (); - int len = data.Length; + int len = str.Length; for (int i = 0; i < len; i++) { - char c = (char) data [i]; // reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," // mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" // control = @@ -791,33 +790,34 @@ namespace Mono.Security { // check for escape code already placed in str, // i.e. for encoding that follows the pattern - // "%hexhex" in a string, where "hex" is a digit from 0-9 + // "%hexhex" in a string, where "hex" is a digit from 0-9 // or a letter from A-F (case-insensitive). - if('%'.Equals(c) && IsHexEncoding(str,i)) - { + if (IsHexEncoding (str,i)) { // if ,yes , copy it as is - s.Append(c); - s.Append(str[++i]); - s.Append(str[++i]); + s.Append(str.Substring (i, 3)); + i += 2; continue; } - if ((c <= 0x20) || (c >= 0x7f) || - ("<>%\"{}|\\^`".IndexOf (c) != -1) || - (escapeHex && (c == '#')) || - (escapeBrackets && (c == '[' || c == ']')) || - (escapeReserved && (";/?:@&=+$,".IndexOf (c) != -1))) { - s.Append (HexEscape (c)); - continue; + byte [] data = Encoding.UTF8.GetBytes (new char[] {str[i]}); + int length = data.Length; + for (int j = 0; j < length; j++) { + char c = (char) data [j]; + if ((c <= 0x20) || (c >= 0x7f) || + ("<>%\"{}|\\^`".IndexOf (c) != -1) || + (escapeHex && (c == '#')) || + (escapeBrackets && (c == '[' || c == ']')) || + (escapeReserved && (";/?:@&=+$,".IndexOf (c) != -1))) { + s.Append (HexEscape (c)); + continue; + } + s.Append (c); } - - - s.Append (c); } return s.ToString (); } - + // This method is called from .ctor(). When overriden, we can // avoid the "absolute uri" constraints of the .ctor() by // overriding with custom code.