diff --git a/mcs/class/System.Web/ChangeLog b/mcs/class/System.Web/ChangeLog index d2242c6cac5e8..241b2c967b02f 100644 --- a/mcs/class/System.Web/ChangeLog +++ b/mcs/class/System.Web/ChangeLog @@ -1,3 +1,8 @@ +2009-06-04 Marek Habersack + + * Makefile (TEST_RESOURCE_FILES): added + Test/mainsoft/NunitWebResources/ServerSideControlsInScriptBlock.aspx + 2009-05-10 Marek Habersack * Makefile (TEST_RESOURCE_FILES): added diff --git a/mcs/class/System.Web/Makefile b/mcs/class/System.Web/Makefile index 5d69e10eace45..4495669bf6918 100644 --- a/mcs/class/System.Web/Makefile +++ b/mcs/class/System.Web/Makefile @@ -162,7 +162,8 @@ TEST_RESOURCE_FILES = \ Test/mainsoft/NunitWebResources/LoginDisplayRememberMe.aspx \ Test/mainsoft/NunitWebResources/NoBindForMethodsWithBindInName.aspx \ Test/mainsoft/NunitWebResources/LinkInHeadWithEmbeddedExpression.aspx \ - Test/mainsoft/NunitWebResources/ExpressionInListControl.aspx + Test/mainsoft/NunitWebResources/ExpressionInListControl.aspx \ + Test/mainsoft/NunitWebResources/ServerSideControlsInScriptBlock.aspx RESX_DIST = resources/TranslationResources.resx ifeq (net_2_0, $(PROFILE)) diff --git a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs index a1e2960a44a19..0a4ec35277561 100644 --- a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs +++ b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs @@ -950,6 +950,8 @@ void TextParsed (ILocation location, string text) if (ignore_text) return; + // And again... the first one wins - if we have expressions and server-side + // controls together in one block of plain text, tough luck... if (text.IndexOf ("<%") != -1 && !inScript) { if (this.text.Length > 0) FlushText (true); @@ -957,8 +959,32 @@ void TextParsed (ILocation location, string text) r.AddChildren (this); return; } + + int startIndex = 0, index = 0; + Match match; + int textLen = text.Length; + + while (index > -1 && startIndex < textLen) { + match = runatServer.Match (text, index); + + if (match.Success) { + string value = match.Value; + index = match.Index; + if (index > startIndex) + this.text.Append (text.Substring (startIndex, index - startIndex)); + ParseAttributeTag (value); + index += value.Length; + startIndex = index; + } else + break; + + if (index < textLen) + index = text.IndexOf ('<', index); + else + break; + } - this.text.Append (text); + this.text.Append (text.Substring (startIndex)); //PrintLocation (location); } @@ -1093,6 +1119,12 @@ bool ProcessTag (ILocation location, string tagid, TagAttributes atts, TagType t builder = RootBuilder.CreateSubBuilder (tagid, htable, null, tparser, location); } catch (TypeLoadException e) { throw new ParseException (Location, "Type not found.", e); + } catch (HttpException e) { + CompilationException inner = e.InnerException as CompilationException; + if (inner != null) + throw inner; + + throw new ParseException (Location, e.Message, e); } catch (Exception e) { throw new ParseException (Location, e.Message, e); } diff --git a/mcs/class/System.Web/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/System.Web.Compilation/ChangeLog index 5b284a0088d70..01c664ae4c5e9 100644 --- a/mcs/class/System.Web/System.Web.Compilation/ChangeLog +++ b/mcs/class/System.Web/System.Web.Compilation/ChangeLog @@ -1,3 +1,8 @@ +2009-06-04 Marek Habersack + + * AspGenerator.cs: if plain text is parsed and it contains + server-side controls, parse and process them. Fixes bug #508888 + 2009-06-02 Gonzalo Paniagua Javier * BuildManager.cs: allow deployment of precompiled applications under diff --git a/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog index bd14646cf2aed..ab7fadfa7d0fe 100644 --- a/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog +++ b/mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog @@ -1,3 +1,7 @@ +2009-06-04 Marek Habersack + + * TemplateControlCompilerTest.cs: added test for bug #508888 + 2009-05-10 Marek Habersack * TemplateControlCompilerTest.cs: added a test for expressions in diff --git a/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs b/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs index b9bb89fcd3995..b09207f55c969 100644 --- a/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs +++ b/mcs/class/System.Web/Test/System.Web.Compilation/TemplateControlCompilerTest.cs @@ -53,6 +53,7 @@ public void TemplateControlCompiler_Init () WebTest.CopyResource (GetType (), "ReadOnlyPropertyBind.aspx", "ReadOnlyPropertyBind.aspx"); WebTest.CopyResource (GetType (), "ReadOnlyPropertyControl.ascx", "ReadOnlyPropertyControl.ascx"); WebTest.CopyResource (GetType (), "TemplateControlParsingTest.aspx", "TemplateControlParsingTest.aspx"); + WebTest.CopyResource (GetType (), "ServerSideControlsInScriptBlock.aspx", "ServerSideControlsInScriptBlock.aspx"); #if NET_2_0 WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx"); WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx"); @@ -181,6 +182,15 @@ public void ExpressionInListControl () "; HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1"); } + + [Test (Description="Bug #508888")] + public void ServerSideControlsInScriptBlock () + { + string pageHtml = new WebTest ("ServerSideControlsInScriptBlock.aspx").Run (); + string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml); + string originalHtml = @""; + HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1"); + } #endif [Test] diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ServerSideControlsInScriptBlock.aspx b/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ServerSideControlsInScriptBlock.aspx new file mode 100644 index 0000000000000..39d4142c48df2 --- /dev/null +++ b/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ServerSideControlsInScriptBlock.aspx @@ -0,0 +1,20 @@ +<%@ Page Language="C#" %> +Bug 508888 + +
+<%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %> + + +
+