2009-08-25 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 25 Aug 2009 11:22:37 +0000 (11:22 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 25 Aug 2009 11:22:37 +0000 (11:22 -0000)
* AspGenerator.cs: correctly parse server-side tags nested in
client-side ones. Fixes bug #323719

2009-08-25  Marek Habersack  <mhabersack@novell.com>

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

2009-08-25  Marek Habersack  <mhabersack@novell.com>

* TemplateControlCompilerTest.cs: added test for bug #323719

svn path=/trunk/mcs/; revision=140611

mcs/class/System.Web/ChangeLog
mcs/class/System.Web/Makefile
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web_test.dll.sources
mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog
mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Tests/TagsNestedInClientTag.cs [new file with mode: 0644]
mcs/class/System.Web/Test/mainsoft/NunitWebResources/TagsNestedInClientTag.aspx [new file with mode: 0644]

index 2063013abe17b7fa1d64b66752ad74333391a65b..6f9d6ca1ced9b849f339a6e1b96c7634290b4f3b 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-25  Marek Habersack  <mhabersack@novell.com>
+
+       * Makefile (TEST_RESOURCE_FILES): added
+       Test/mainsoft/NunitWebResources/TagsNestedInClientTag.aspx
+
 2009-08-18  Marek Habersack  <mhabersack@novell.com>
 
        * Makefile (TEST_RESOURCE_FILES): added
index af8857dc5e576e623b586f7b3c4957da4e8b1cfe..0ec4416ac2957ffe167db1f70c76a952bdb751db 100644 (file)
@@ -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))
index b29dc60746dbec632a3b9168989e657e97f1646b..b69f22dfde026628eddb8128712431424b84b415 100644 (file)
@@ -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;
                                }
                        }
index 4e9089ebd2b3a854616d14fcf0d7c95eb5445af3..04745b753c29a86dd3e002cc8e9ab635c8c32ff7 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-25  Marek Habersack  <mhabersack@novell.com>
+
+       * AspGenerator.cs: correctly parse server-side tags nested in
+       client-side ones. Fixes bug #323719
+
 2009-08-24  Marek Habersack  <mhabersack@novell.com>
 
        * PageBuildProvider.cs: MapPath now takes a VirtualPath
index c28a26b87ab01ed95787ae6ce1688febcff46d2b..332cb0655e41535541e173f40f4c0e32425e1475 100644 (file)
@@ -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
index bbeaf758f74b35333c872325ac007e221dde2485..2c446b203d890ca41baf0f8a802f3718ed7c04ca 100644 (file)
@@ -1,3 +1,7 @@
+2009-08-25  Marek Habersack  <mhabersack@novell.com>
+
+       * TemplateControlCompilerTest.cs: added test for bug #323719
+
 2009-08-18  Marek Habersack  <mhabersack@novell.com>
 
        * TemplateControlCompilerTest.cs: added test for bug #525104 and
index a947f23873577d566c02c2039ff320acc280e8bd..b2c186a212a230959d67e37bfbea75c9af01463d 100644 (file)
@@ -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 ()
diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Tests/TagsNestedInClientTag.cs b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Tests/TagsNestedInClientTag.cs
new file mode 100644 (file)
index 0000000..7d3061b
--- /dev/null
@@ -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\"";
+               }
+       }
+}
+
diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWebResources/TagsNestedInClientTag.aspx b/mcs/class/System.Web/Test/mainsoft/NunitWebResources/TagsNestedInClientTag.aspx
new file mode 100644 (file)
index 0000000..3b72d7e
--- /dev/null
@@ -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>