[Mono-list] MS ASP .NET Bug
David Waite
dwaite@gmail.com
Fri, 23 Jul 2004 11:49:18 -0600
This is not a bug; the </script> just takes precidence over code
structure; the contents of the script block is interpreted by a
separate engine. Without knowing the grammar of the language you are
using for the script block, the parser has no way of knowing if
sql += @"
is a valid statement or not.
As someone said, you should divide up the script close tag in your
code. Something like a CDATA block will not work, at least not with
the MS implementation (which appears to be regexp-based rather than
having a real grammar). Another option would be to separate your code
from the page.
-David Waite
On Fri, 23 Jul 2004 11:36:18 -0600, Andrew Arnott <andrewarnott@byu.edu> wrote:
> Answer below.
>
> > so I wonder if it would happen in Mono too. The bug is simple, supose we
> > have the following in an aspx:
> > <script runat="server">
> > void ProcessClick( object sender, EventArgs args )
> > {
> > string sql = @"<script language='javascript'>";
> > sql += @"alert('";
> > sql += nome.Value;
> > sql += "');";
> > sql += @"</script>"; // Here is the PROBLEM!
> > this.RegisterClientScriptBlock( "JJ", sql );
> > }
> > </script>
> > The parser will only "copy" to the class definition the code from <script
> > runat=server> to <script>. The problem is that he thinks that the
> > "</script>" literal is the tag end... So in the class definition we will
> > have only:
> >
> > void ProcessClick( object sender, EventArgs args )
> > {
> > string sql = @"<script language='javascript'>";
> > sql += @"alert('";
> > sql += nome.Value;
> > sql += "');";
> > sql += @"
> >
> > Witch produces a compiler error. Would this happen in Mono? If not, should
> > it happen?
>
> I can't answer the "will it happen in Mono question", but a solution to the
> problem is to just divide your </script> tag up:
>
> sql += @"</scr" + "ipt>"; // Here is the SOLUTION!
>
> That will work in any implementation that has the bug.
>
>
>