Просмотр исходного кода

2009-08-25 Marek Habersack <[email protected]>

	* AspGenerator.cs: correctly parse server-side tags nested in
	client-side ones. Fixes bug #323719

2009-08-25  Marek Habersack  <[email protected]>

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

2009-08-25  Marek Habersack  <[email protected]>

	* TemplateControlCompilerTest.cs: added test for bug #323719

svn path=/trunk/mcs/; revision=140611
Marek Habersack 16 лет назад
Родитель
Сommit
dfabffa5b2

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

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

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

@@ -175,7 +175,8 @@ TEST_RESOURCE_FILES = \
 	Test/mainsoft/NunitWebResources/FullTagsInText.aspx \
 	Test/mainsoft/NunitWebResources/TagsExpressionsAndCommentsInText.aspx \
 	Test/mainsoft/NunitWebResources/NewlineInCodeExpression.aspx \
-	Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx
+	Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx \
+	Test/mainsoft/NunitWebResources/TagsNestedInClientTag.aspx
 
 RESX_DIST =  resources/TranslationResources.resx
 ifneq (1, $(FRAMEWORK_VERSION_MAJOR))

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

@@ -914,6 +914,17 @@ namespace System.Web.Compilation
 			if (exception != null || !StrUtils.StartsWith (newdir, HttpRuntime.AppDomainAppPath))
 				throw new ParseException (Location, "Files above the application's root directory cannot be included.");
 		}
+
+		string ChopOffTagStart (ILocation location, string content, string tagid)
+		{
+			string tagstart = '<' + tagid;
+			if (content.StartsWith (tagstart)) {
+				TextParsed (location, tagstart);
+				content = content.Substring (tagstart.Length);
+			}
+
+			return content;
+		}
 		
 		void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes attributes)
 		{
@@ -959,7 +970,7 @@ namespace System.Web.Compilation
 				{
 					string plainText = location.PlainText;
 					if (!ProcessTagsInAttributes (location, tagid, attributes, TagType.Tag))
-						TextParsed (location, plainText);
+						TextParsed (location, ChopOffTagStart (location, plainText, tagid));
 				}
 				break;
 			case TagType.Close:
@@ -974,7 +985,7 @@ namespace System.Web.Compilation
 				if (!ProcessTag (location, tagid, attributes, tagtype, out tagIgnored) && !tagIgnored) {
 					string plainText = location.PlainText;
 					if (!ProcessTagsInAttributes (location, tagid, attributes, TagType.SelfClosing))
-						TextParsed (location, plainText);
+						TextParsed (location, ChopOffTagStart (location, plainText, tagid));
 				} else if (stack.Count != count) {
 					CloseControl (tagid);
 				}
@@ -1414,7 +1425,14 @@ namespace System.Web.Compilation
 						Parser.VerbatimID = "script";
 						javascript = true;
 					}
-					TextParsed (location, location.PlainText);
+					string content = location.PlainText;
+					/* HACK, HACK, HACK */
+					if (content.StartsWith ("<script")) {
+						TextParsed (location, "<script");
+						content = content.Substring (7);
+					}
+
+					TextParsed (location, content);
 					return true;
 				}
 			}

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

@@ -1,3 +1,8 @@
+2009-08-25  Marek Habersack  <[email protected]>
+
+	* AspGenerator.cs: correctly parse server-side tags nested in
+	client-side ones. Fixes bug #323719
+
 2009-08-24  Marek Habersack  <[email protected]>
 
 	* PageBuildProvider.cs: MapPath now takes a VirtualPath

+ 1 - 0
mcs/class/System.Web/System.Web_test.dll.sources

@@ -35,6 +35,7 @@ mainsoft/NunitWeb/NunitWeb/Response.cs
 mainsoft/NunitWeb/NunitWeb/StandardUrl.cs
 mainsoft/NunitWeb/NunitWeb/WebTest.cs
 mainsoft/NunitWeb/NunitWeb/WebTestResourcesSetupAttribute.cs
+mainsoft/NunitWeb/NunitWeb/Tests/TagsNestedInClientTag.cs
 System.Web/AppBrowsersTest.cs
 System.Web/HttpBrowserCapabilitiesTest.cs
 System.Web/HttpCacheVaryByContentEncodingsTest.cs

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

@@ -1,3 +1,7 @@
+2009-08-25  Marek Habersack  <[email protected]>
+
+	* TemplateControlCompilerTest.cs: added test for bug #323719
+
 2009-08-18  Marek Habersack  <[email protected]>
 
 	* TemplateControlCompilerTest.cs: added test for bug #525104 and

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

@@ -60,6 +60,7 @@ namespace MonoTests.System.Web.Compilation {
 			WebTest.CopyResource (GetType (), "TagsExpressionsAndCommentsInText.aspx", "TagsExpressionsAndCommentsInText.aspx");
 			WebTest.CopyResource (GetType (), "NewlineInCodeExpression.aspx", "NewlineInCodeExpression.aspx");
 			WebTest.CopyResource (GetType (), "DuplicateControlsInClientComment.aspx", "DuplicateControlsInClientComment.aspx");
+			WebTest.CopyResource (GetType (), "TagsNestedInClientTag.aspx", "TagsNestedInClientTag.aspx");
 #if NET_2_0
 			WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx");
 			WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx");
@@ -223,6 +224,17 @@ namespace MonoTests.System.Web.Compilation {
 			new WebTest ("DuplicateControlsInClientComment.aspx").Run ();
 		}
 #endif
+
+		[Test (Description="Bug #323719")]
+		public void TagsNestedInClientTag ()
+		{
+			string pageHtml = new WebTest ("TagsNestedInClientTag.aspx").Run ();
+			string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+			string originalHtml = @"<script language=""javascript"" src=""/js/test.js"" type=""text/javascript""></script>
+<sometag language=""javascript"" src=""/js/test.js"" type=""text/javascript""></sometag>";
+
+			HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+		}
 		
 		[Test (Description="Bug #517656")]
 		public void ServerControlInClientSideComment ()

+ 29 - 0
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Tests/TagsNestedInClientTag.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Data;
+using System.Data.Common;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace Tests {
+	public class TagsNestedInClientTag : System.Web.UI.Page
+	{
+		protected Literal languageLiteral;
+		protected Literal typeLiteral;
+		protected Literal srcLiteral;
+		protected Literal languageLiteral1;
+		protected Literal typeLiteral1;
+		protected Literal srcLiteral1;
+		
+		protected void Page_Load(object sender, EventArgs e)
+		{
+			languageLiteral.Text = "language=\"javascript\"";
+			typeLiteral.Text = "type=\"text/javascript\"";
+			srcLiteral.Text = "src=\"/js/test.js\"";
+			
+			languageLiteral1.Text = "language=\"javascript\"";
+			typeLiteral1.Text = "type=\"text/javascript\"";
+			srcLiteral1.Text = "src=\"/js/test.js\"";
+		}
+	}
+}
+

+ 15 - 0
mcs/class/System.Web/Test/mainsoft/NunitWebResources/TagsNestedInClientTag.aspx

@@ -0,0 +1,15 @@
+<%@ Page Language="C#" 
+         AutoEventWireup="true" 
+         Inherits="Tests.TagsNestedInClientTag" %>
+<html>
+<head runat="server"><title>Bug #323719</title></head>
+<body>
+
+<p>
+This is a test to see if mono can handle a control embedded in a script tag; which MS is able to deal with.
+</p>
+
+<%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><script <asp:Literal ID="languageLiteral" runat="server" EnableViewState="false" /> <asp:Literal ID="srcLiteral" runat="server" EnableViewState="false" /> <asp:Literal ID="typeLiteral" runat="server" EnableViewState="false" />></script>
+<sometag <asp:Literal ID="languageLiteral1" runat="server" EnableViewState="false" /> <asp:Literal ID="srcLiteral1" runat="server" EnableViewState="false" /> <asp:Literal ID="typeLiteral1" runat="server" EnableViewState="false"/>></sometag></sometag><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+</body>
+</html>