+2010-03-06 Marek Habersack <mhabersack@novell.com>
+
+ * HttpUtility.cs: decode entities which use hexadecimal
+ encoding. Fixes bug #585992. Patch from Sebastien Morin
+ <smsisko@gmail.com>, thanks!
+
2010-03-04 Marek Habersack <mhabersack@novell.com>
* HttpRuntime.cs: do less work in the static constructor. Most of
// 3 -> '#' found after '&' and getting numbers
int state = 0;
int number = 0;
+ bool is_hex_value = false;
bool have_trailing_digits = false;
for (int i = 0; i < len; i++) {
entity.Length = 0;
} else {
number = 0;
+ is_hex_value = false;
if (c != '#') {
state = 2;
} else {
state = 0;
entity.Length = 0;
have_trailing_digits = false;
+ } else if (is_hex_value && Uri.IsHexDigit(c)) {
+ number = number * 16 + Uri.FromHex(c);
+ have_trailing_digits = true;
} else if (Char.IsDigit (c)) {
number = number * 10 + ((int) c - '0');
have_trailing_digits = true;
+ } else if (number == 0 && (c == 'x' || c == 'X')) {
+ is_hex_value = true;
} else {
state = 2;
if (have_trailing_digits) {
Assert.AreEqual ("\xE9", HttpUtility.HtmlDecode ("é"));
}
+ [Test (Description="Bug #585992")]
+ public void Decode2 ()
+ {
+ string encodedSource = "© == © == © and Γ == Γ == Γ";
+ string utf8Result = "© == © == © and Γ == Γ == Γ";
+
+ Assert.AreEqual (utf8Result, HttpUtility.HtmlDecode (encodedSource), "#A1");
+ }
+
[Test]
public void RoundTrip ()
{