Browse Source

2008-05-19 Marek Habersack <[email protected]>

	* AspGenerator.cs: if the last tag parsed was a code directive,
	ignore any accumulated text if it's 100% whitespace.

svn path=/trunk/mcs/; revision=103541
Marek Habersack 17 years ago
parent
commit
d807258f66

+ 17 - 4
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs

@@ -190,7 +190,8 @@ namespace System.Web.Compilation
 		static Hashtable emptyHash = new Hashtable ();
 		bool inForm;
 		bool useOtherTags;
-
+		TagType lastTag;
+		
 		public AspGenerator (TemplateParser tparser)
 		{
 			this.tparser = tparser;
@@ -415,7 +416,7 @@ namespace System.Web.Compilation
 				tparser.Location = location;
 
 			if (text.Length != 0)
-				FlushText ();
+				FlushText (lastTag == TagType.CodeRender);
 
 			if (0 == String.Compare (tagid, "script", true, CultureInfo.InvariantCulture)) {
 				bool in_script = (inScript || ignore_text);
@@ -425,6 +426,7 @@ namespace System.Web.Compilation
 				}
 			}
 
+			lastTag = tagtype;
 			switch (tagtype) {
 			case TagType.Directive:
 				if (tagid == "")
@@ -465,6 +467,7 @@ namespace System.Web.Compilation
 			case TagType.CodeRenderExpression:
 				goto case TagType.CodeRender;
 			case TagType.CodeRender:
+				lastTag = TagType.CodeRender;
 				if (isApplication)
 					throw new ParseException (location, "Invalid content for application file.");
 			
@@ -543,21 +546,31 @@ namespace System.Web.Compilation
 				return;
 
 			if (text.IndexOf ("<%") != -1 && !inScript) {
+				Console.WriteLine ("code tag beginning");
 				if (this.text.Length > 0)
-					FlushText ();
+					FlushText (true);
 				CodeRenderParser r = new CodeRenderParser (text, stack.Builder);
 				r.AddChildren ();
 				return;
 			}
-
+			
 			this.text.Append (text);
 			//PrintLocation (location);
 		}
 
 		void FlushText ()
+		{
+			FlushText (false);
+		}
+		
+		void FlushText (bool ignoreEmptyString)
 		{
 			string t = text.ToString ();
 			text.Length = 0;
+
+			if (ignoreEmptyString && t.Trim ().Length == 0)
+				return;
+			
 			if (inScript) {
 				tparser.Scripts.Add (new ServerSideScript (t, new System.Web.Compilation.Location (tparser.Location)));
 				return;

+ 5 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,3 +1,8 @@
+2008-05-19  Marek Habersack  <[email protected]>
+
+	* AspGenerator.cs: if the last tag parsed was a code directive,
+	ignore any accumulated text if it's 100% whitespace.
+
 2008-05-15  Marek Habersack  <[email protected]>
 
 	* AspComponentFoundry.cs: treat AssemblyFoundry in a special way