Răsfoiți Sursa

* HttpUtility.cs: fixed HtmlAttributeEncode, performance improvement

svn path=/trunk/mcs/; revision=80614
Vladimir Krasnov 18 ani în urmă
părinte
comite
32cdaa3f83

+ 4 - 0
mcs/class/System.Web/System.Web/ChangeLog

@@ -1,3 +1,7 @@
+2007-06-24  Vladimir Krasnov  <[email protected]>
+
+	* HttpUtility.cs: fixed HtmlAttributeEncode, performance improvement
+
 2007-06-20  Marek Habersack  <[email protected]>
 
 	* HttpRuntime.cs: added new internal property, InternalCache, to

+ 9 - 1
mcs/class/System.Web/System.Web/HttpUtility.cs

@@ -339,7 +339,15 @@ namespace System.Web {
 			if (null == s) 
 				return null;
 	
-			if (s.IndexOf ('&') == -1 && s.IndexOf ('"') == -1 && s.IndexOf ('<') == -1)
+			bool needEncode = false;
+			for (int i = 0; i < s.Length; i++) {
+				if (s [i] == '&' || s [i] == '"' || s [i] == '<') {
+					needEncode = true;
+					break;
+				}
+			}
+
+			if (!needEncode)
 				return s;
 
 			StringBuilder output = new StringBuilder ();