Skip to content

Commit

Permalink
Backport of r135486
Browse files Browse the repository at this point in the history
svn path=/branches/mono-2-4/mcs/; revision=135487
  • Loading branch information
grendello committed Jun 4, 2009
1 parent 69340b3 commit 905299d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 2 deletions.
5 changes: 5 additions & 0 deletions mcs/class/System.Web/ChangeLog
@@ -1,3 +1,8 @@
2009-06-04 Marek Habersack <mhabersack@novell.com>

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

2009-05-10 Marek Habersack <mhabersack@novell.com>

* Makefile (TEST_RESOURCE_FILES): added
Expand Down
3 changes: 2 additions & 1 deletion mcs/class/System.Web/Makefile
Expand Up @@ -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))
Expand Down
34 changes: 33 additions & 1 deletion mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs
Expand Up @@ -950,15 +950,41 @@ 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);
CodeRenderParser r = new CodeRenderParser (text, stack.Builder);
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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions mcs/class/System.Web/System.Web.Compilation/ChangeLog
@@ -1,3 +1,8 @@
2009-06-04 Marek Habersack <mhabersack@novell.com>

* 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 <gonzalo@novell.com>

* BuildManager.cs: allow deployment of precompiled applications under
Expand Down
4 changes: 4 additions & 0 deletions mcs/class/System.Web/Test/System.Web.Compilation/ChangeLog
@@ -1,3 +1,7 @@
2009-06-04 Marek Habersack <mhabersack@novell.com>

* TemplateControlCompilerTest.cs: added test for bug #508888

2009-05-10 Marek Habersack <mhabersack@novell.com>

* TemplateControlCompilerTest.cs: added a test for expressions in
Expand Down
Expand Up @@ -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");
Expand Down Expand Up @@ -181,6 +182,15 @@ public void ExpressionInListControl ()
</select>";
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 = @"<script type=""text/javascript"">alert (escape(""reporting/location?report=ViewsByDate&minDate=minDate&maxDate=maxDate""));</script>";
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
}
#endif

[Test]
Expand Down
@@ -0,0 +1,20 @@
<%@ Page Language="C#" %>
<html><head><title>Bug 508888</title></head>
<body>
<form runat="server">
<%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><script type="text/javascript">alert (escape("reporting/location?report=ViewsByDate&minDate=<asp:Literal id="minDate" runat="server"/>&maxDate=<asp:Literal id="maxDate" runat="server" />"));</script><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>

<script runat="server">
void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
minDate.Text = "minDate";
maxDate.Text = "maxDate";
}
}
</script>
</form>
</body></html>

0 comments on commit 905299d

Please sign in to comment.