Author: gonzalo
Date: 2005-03-05 16:13:11 -0500 (Sat, 05 Mar 2005)
New Revision: 41472
Modified:
branches/mono-1-0/mcs/class/System/System/ChangeLog
branches/mono-1-0/mcs/class/System/System/Uri.cs
Log:
from HEAD
Modified: branches/mono-1-0/mcs/class/System/System/ChangeLog
===================================================================
--- branches/mono-1-0/mcs/class/System/System/ChangeLog 2005-03-05 21:12:15 UTC
(rev 41471)
+++ branches/mono-1-0/mcs/class/System/System/ChangeLog 2005-03-05 21:13:11 UTC
(rev 41472)
@@ -1,3 +1,18 @@
+2005-03-05 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * Uri.cs: when unescaping in stages, handle the case when the next
+ substring is not a escaped sequence or the string ends. Fixes bug
+ #73316.
+
+2005-01-20 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * Uri.cs: Set the UriSchemNews port default to 119 as well.
+ Fixes bug #71050.
+
+ When dealing with fragments use the `dontEscape' flag passed to
+ the Uri constructor to decide whether the fragment must or must
+ not be escaped, fixes 71051.
+
2004-06-22 Atsushi Enomoto <[EMAIL PROTECTED]>
* Uri.cs : Such ctor arg string that starts with "//" should be
Modified: branches/mono-1-0/mcs/class/System/System/Uri.cs
===================================================================
--- branches/mono-1-0/mcs/class/System/System/Uri.cs 2005-03-05 21:12:15 UTC
(rev 41471)
+++ branches/mono-1-0/mcs/class/System/System/Uri.cs 2005-03-05 21:13:11 UTC
(rev 41472)
@@ -173,8 +173,10 @@
// Note that in relative constructor, file URI cannot
handle '#' as a filename character, but just regarded as a fragment identifier.
pos = relativeUri.IndexOf ('#');
if (pos != -1) {
- fragment = relativeUri.Substring (pos);
- // fragment is not escaped.
+ if (userEscaped)
+ fragment = relativeUri.Substring (pos);
+ else
+ fragment = "#" + EscapeString
(relativeUri.Substring (pos+1));
relativeUri = relativeUri.Substring (0, pos);
}
@@ -644,26 +646,25 @@
if (index < 0 || index >= pattern.Length)
throw new ArgumentOutOfRangeException ("index");
+ if (!IsHexEncoding (pattern, index))
+ return pattern [index++];
+
int stage = 0;
int c = 0;
- byte [] bytes = new byte [6];
+ int b = 0;
+ bool looped = false;
do {
- if (((index + 3) > pattern.Length) ||
- (pattern [index] != '%') ||
- !IsHexDigit (pattern [index + 1]) ||
- !IsHexDigit (pattern [index + 2]))
- {
- if (stage == 0)
- return pattern [index++];
- break;
- }
-
index++;
int msb = FromHex (pattern [index++]);
int lsb = FromHex (pattern [index++]);
- int b = (msb << 4) + lsb;
-
- if (stage == 0) {
+ b = (msb << 4) + lsb;
+ if (!IsHexEncoding (pattern, index)) {
+ if (looped)
+ c += (b - 0x80) << ((stage - 1)
* 6);
+ else
+ c = b;
+ break;
+ } else if (stage == 0) {
if (b < 0xc0)
return (char) b;
else if (b < 0xE0) {
@@ -683,11 +684,11 @@
stage = 6;
}
c <<= (stage - 1) * 6;
+ } else {
+ c += (b - 0x80) << ((stage - 1) * 6);
}
- else
- c += (b - 0x80) << ((stage - 1) * 6);
-//Console.WriteLine ("stage {0}: {5:X04} <-- {1:X02}|{2:X01},{3:X01} {4}", new
object [] {stage, b, msb, lsb, pattern.Substring (index), c});
stage--;
+ looped = true;
} while (stage > 0);
return (char) c;
@@ -784,9 +785,9 @@
// 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('%' == c && IsHexEncoding(str,i))
{
// if ,yes , copy it as is
s.Append(c);
@@ -979,7 +980,11 @@
// 8 fragment
pos = uriString.IndexOf ('#');
if (!IsUnc && pos != -1) {
- fragment = uriString.Substring (pos);
+ if (userEscaped)
+ fragment = uriString.Substring (pos);
+ else
+ fragment = "#" + EscapeString
(uriString.Substring (pos+1));
+
uriString = uriString.Substring (0, pos);
}
@@ -1137,7 +1142,7 @@
new UriScheme (UriSchemeFtp, SchemeDelimiter, 21),
new UriScheme (UriSchemeFile, SchemeDelimiter, -1),
new UriScheme (UriSchemeMailto, ":", 25),
- new UriScheme (UriSchemeNews, ":", -1),
+ new UriScheme (UriSchemeNews, ":", 119),
new UriScheme (UriSchemeNntp, SchemeDelimiter, 119),
new UriScheme (UriSchemeGopher, SchemeDelimiter, 70),
};
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches