Procházet zdrojové kódy

2009-07-21 Marek Habersack <[email protected]>

	* Makefile (TEST_RESOURCE_FILES): added
	Test/mainsoft/NunitWebResources/UnquotedAngleBrackets.aspx

2009-07-21  Marek Habersack  <[email protected]>

	* AspTokenizer.cs: in put_back, store inTag value as well.

	* AspParser.cs: correctly parse code like "<asp:tag> < </asp:tag>"

svn path=/trunk/mcs/; revision=138280
Marek Habersack před 16 roky
rodič
revize
d4cc6a70f7

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

@@ -1,3 +1,8 @@
+2009-07-21  Marek Habersack  <[email protected]>
+
+	* Makefile (TEST_RESOURCE_FILES): added
+	Test/mainsoft/NunitWebResources/UnquotedAngleBrackets.aspx
+
 2009-07-08  Marek Habersack  <[email protected]>
 
 	* Makefile (TEST_RESOURCE_FILES): added

+ 2 - 1
mcs/class/System.Web/Makefile

@@ -171,7 +171,8 @@ TEST_RESOURCE_FILES = \
 	Test/mainsoft/NunitWebResources/ExpressionInListControl.aspx \
 	Test/mainsoft/NunitWebResources/ServerSideControlsInScriptBlock.aspx \
 	Test/mainsoft/NunitWebResources/ServerControlInClientSideComment.aspx \
-	Test/mainsoft/NunitWebResources/PreprocessorDirectivesInMarkup.aspx
+	Test/mainsoft/NunitWebResources/PreprocessorDirectivesInMarkup.aspx \
+	Test/mainsoft/NunitWebResources/UnquotedAngleBrackets.aspx
 
 RESX_DIST =  resources/TranslationResources.resx
 ifneq (1, $(FRAMEWORK_VERSION_MAJOR))

+ 21 - 3
mcs/class/System.Web/System.Web.Compilation/AspParser.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //	Gonzalo Paniagua Javier ([email protected])
+//      Marek Habersack <[email protected]>
 //
 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
+// (C) 2004-2009 Novell, Inc (http://novell.com)
 //
 
 //
@@ -154,7 +156,8 @@ namespace System.Web.Compilation
 
 		bool Eat (int expected_token)
 		{
-			if (tokenizer.get_token () != expected_token) {
+			int token = tokenizer.get_token ();
+			if (token != expected_token) {
 				tokenizer.put_back ();
 				return false;
 			}
@@ -227,7 +230,7 @@ namespace System.Web.Compilation
 						continue;
 					}
 
-					if (tokenizer.Value.Trim () == "" && tagtype == TagType.Directive) {
+					if (tokenizer.Value.Trim ().Length == 0 && tagtype == TagType.Directive) {
 						continue;
 					}
 
@@ -381,9 +384,24 @@ namespace System.Web.Compilation
 
 				break;
 			default:
+				string idvalue = null;
+				// This is to handle code like:
+				//
+				//  <asp:ListItem runat="server"> < </asp:ListItem>
+				//
+				if ((char)token == '<') {
+					string odds = tokenizer.Odds;
+					if (odds != null && odds.Length > 0 && Char.IsWhiteSpace (odds [0])) {
+						tokenizer.put_back ();
+						idvalue = odds;
+					} else
+						idvalue = tokenizer.Value;
+				} else
+					idvalue = tokenizer.Value;
+				
 				tagtype = TagType.Text;
 				tokenizer.InTag = false;
-				id = "<" + tokenizer.Value;
+				id = "<" + idvalue;
 				break;
 			}
 		}

+ 5 - 2
mcs/class/System.Web/System.Web.Compilation/AspTokenizer.cs

@@ -57,12 +57,14 @@ namespace System.Web.Compilation
 			public readonly string Value;
 			public readonly int Position;
 			public readonly int CurrentToken;
+			public readonly bool InTag;
 			
-			public PutBackItem (string value, int position, int currentToken)
+			public PutBackItem (string value, int position, int currentToken, bool inTag)
 			{
 				Value = value;
 				Position = position;
 				CurrentToken = currentToken;
+				InTag = inTag;
 			}
 		}
 		
@@ -118,7 +120,7 @@ namespace System.Web.Compilation
 				putBackBuffer = new Stack ();
 
 			string val = Value;
-			putBackBuffer.Push (new PutBackItem (val, position, current_token));
+			putBackBuffer.Push (new PutBackItem (val, position, current_token, inTag));
 			position -= val.Length;
 		}
 		
@@ -132,6 +134,7 @@ namespace System.Web.Compilation
 				val = null;
 				sb = new StringBuilder (pbi.Value);
 				current_token = pbi.CurrentToken;
+				inTag = pbi.InTag;
 				return current_token;
 			}
 

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

@@ -1,5 +1,9 @@
 2009-07-21  Marek Habersack  <[email protected]>
 
+	* AspTokenizer.cs: in put_back, store inTag value as well.
+
+	* AspParser.cs: correctly parse code like "<asp:tag> < </asp:tag>"
+
 	* BuildManager.cs: GetReferencedAssemblies unconditionally
 	includes all assemblies from bin/ for precompiled sites. Fixes bug
 	#502016

+ 8 - 0
mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs

@@ -55,6 +55,7 @@ namespace MonoTests.System.Web.Compilation {
 			WebTest.CopyResource (GetType (), "TemplateControlParsingTest.aspx", "TemplateControlParsingTest.aspx");
 			WebTest.CopyResource (GetType (), "ServerSideControlsInScriptBlock.aspx", "ServerSideControlsInScriptBlock.aspx");
 			WebTest.CopyResource (GetType (), "ServerControlInClientSideComment.aspx", "ServerControlInClientSideComment.aspx");
+			WebTest.CopyResource (GetType (), "UnquotedAngleBrackets.aspx", "UnquotedAngleBrackets.aspx");
 #if NET_2_0
 			WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx");
 			WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx");
@@ -208,6 +209,13 @@ namespace MonoTests.System.Web.Compilation {
 			// We just test if it doesn't throw an exception
 			new WebTest ("ServerControlInClientSideComment.aspx").Run ();
 		}
+
+		[Test]
+		public void UnquotedAngleBrackets ()
+		{
+			// We just test if it doesn't throw an exception
+			new WebTest ("UnquotedAngleBrackets.aspx").Run ();
+		}
 		
 		[Test]
 		public void ChildTemplatesTest ()

+ 13 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/UnquotedAngleBrackets.aspx

@@ -0,0 +1,13 @@
+<%@ Page Language="C#" %>
+<html>
+<head><title>unquoted angle brackets</title></head>
+<body>
+<form runat="server">
+<asp:DropDownList runat="server">
+<asp:ListItem Value="&gt;"> > </asp:ListItem>
+<asp:ListItem Value="="> = </asp:ListItem>
+<asp:ListItem Value="&lt;"> < </asp:ListItem>
+</asp:DropDownList>
+</form>
+</body>
+</html>