2009-08-18 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 18 Aug 2009 13:31:49 +0000 (13:31 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 18 Aug 2009 13:31:49 +0000 (13:31 -0000)
* Makefile (TEST_RESOURCE_FILES): added
Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx

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

* ControlBuilder.cs: Location property makes a copy of assigned
ILocation now.

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

* AspParser.cs: added a constructor which creates an internal
parser, nested within the outer one, and adjusts its ILocation
members to report correct locations in the outer parser for better
error reporting. Inner parser also returns the outer's FileText,
if available.

* AspGenerator.cs: restored part of r138474 reverted in r138657,
r138658 and r138659 to fix bug #525104
BuilderLocation creates a copy of Location for its own use (since
the ILocation passed is actually AspParser, the line numbers
change between creating a BuilderLocation and using its Location
member).
The end of tag, expression and client comment regular expressions
now use lazy quantifiers. This fixes bugs #525104 and #517656
Client side comment blocks aren't ignored anymore, they are parsed
just as the other parts of the document. Fixes bug #524358

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

* JavaScriptSerializer.cs: read converters from the config only if
explicitly requested.

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

* TemplateControlCompilerTest.cs: added test for bug #525104 and
improved test for bug #517656

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

13 files changed:
mcs/class/System.Web.Extensions/System.Web.Script.Serialization/ChangeLog
mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JavaScriptSerializer.cs
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/AspParser.cs
mcs/class/System.Web/System.Web.Compilation/ChangeLog
mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/ControlBuilder.cs
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/NunitWebResources/DuplicateControlsInClientComment.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/mainsoft/NunitWebResources/ServerControlInClientSideComment.aspx

index 5a80f42f63b7825a7872502c535b4a8f43120164..5cb604314f4fb3feb478275e061655d760b2c506 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-18  Marek Habersack  <mhabersack@novell.com>
+
+       * JavaScriptSerializer.cs: read converters from the config only if
+       explicitly requested.
+
 2009-08-17  Marek Habersack  <mhabersack@novell.com>
 
        * JsonSerializer.cs: serialize fields before properties.
index 5f26c96eac7431850c76350da01e1046412dbda5..7d2021dc3cef44cd9da510b697264798ed4a5aef 100644 (file)
@@ -75,27 +75,29 @@ namespace System.Web.Script.Serialization
                                _maxJsonLength = section.MaxJsonLength;
                                _recursionLimit = section.RecursionLimit;
 
-                               ConvertersCollection converters = section.Converters;
-                               if (converters != null && converters.Count > 0) {
-                                       var cvtlist = new List <JavaScriptConverter> ();
-                                       Type type;
-                                       string typeName;
-                                       JavaScriptConverter jsc;
-                                       
-                                       foreach (Converter cvt in converters) {
-                                               typeName = cvt != null ? cvt.Type : null;
-                                               if (typeName == null)
-                                                       continue;
-
-                                               type = HttpApplication.LoadType (typeName, true);
-                                               if (type == null || !typeof (JavaScriptConverter).IsAssignableFrom (type))
-                                                       continue;
+                               if (registerConverters) {
+                                       ConvertersCollection converters = section.Converters;
+                                       if (converters != null && converters.Count > 0) {
+                                               var cvtlist = new List <JavaScriptConverter> ();
+                                               Type type;
+                                               string typeName;
+                                               JavaScriptConverter jsc;
                                                
-                                               jsc = Activator.CreateInstance (type) as JavaScriptConverter;
-                                               cvtlist.Add (jsc);
-                                       }
+                                               foreach (Converter cvt in converters) {
+                                                       typeName = cvt != null ? cvt.Type : null;
+                                                       if (typeName == null)
+                                                               continue;
+                                                       
+                                                       type = HttpApplication.LoadType (typeName, true);
+                                                       if (type == null || !typeof (JavaScriptConverter).IsAssignableFrom (type))
+                                                               continue;
+                                                       
+                                                       jsc = Activator.CreateInstance (type) as JavaScriptConverter;
+                                                       cvtlist.Add (jsc);
+                                               }
                                        
-                                       RegisterConverters (cvtlist);
+                                               RegisterConverters (cvtlist);
+                                       }
                                }
                        }
                }
index 3254af03e2463c996e38a91d80df4dc348c684fb..2063013abe17b7fa1d64b66752ad74333391a65b 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-18  Marek Habersack  <mhabersack@novell.com>
+
+       * Makefile (TEST_RESOURCE_FILES): added
+       Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx
+
 2009-08-15  Marek Habersack  <mhabersack@novell.com>
 
        * Makefile (TEST_RESOURCE_FILES): added
index 1cc9d70493fc88d40e11bd4423e05e0754c488ec..f5a5d9a3904c2feb8a2336476d11f9079412204a 100644 (file)
@@ -175,7 +175,8 @@ TEST_RESOURCE_FILES = \
        Test/mainsoft/NunitWebResources/UnquotedAngleBrackets.aspx \
        Test/mainsoft/NunitWebResources/FullTagsInText.aspx \
        Test/mainsoft/NunitWebResources/TagsExpressionsAndCommentsInText.aspx \
-       Test/mainsoft/NunitWebResources/NewlineInCodeExpression.aspx
+       Test/mainsoft/NunitWebResources/NewlineInCodeExpression.aspx \
+       Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx
 
 RESX_DIST =  resources/TranslationResources.resx
 ifneq (1, $(FRAMEWORK_VERSION_MAJOR))
index 8e5555bdffad390728006ad9d5342e152920c312..d424109d37e5327355b68c06140370ab399e14a0 100644 (file)
@@ -3,9 +3,10 @@
 //
 // Authors:
 //     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//      Marek Habersack <mhabersack@novell.com>
 //
 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
-// Copyright (c) 2004,2006 Novell, Inc (http://www.novell.com)
+// Copyright (c) 2004-2009 Novell, Inc (http://www.novell.com)
 //
 
 //
@@ -56,7 +57,7 @@ namespace System.Web.Compilation
                public BuilderLocation (ControlBuilder builder, ILocation location)
                {
                        this.Builder = builder;
-                       this.Location = location;
+                       this.Location = new Location (location);
                }
        }
 
@@ -181,6 +182,33 @@ namespace System.Web.Compilation
                }
        }
 
+       enum TextBlockType
+       {
+               Verbatim,
+               Expression,
+               Tag,
+               Comment
+       }
+       
+       sealed class TextBlock
+       {
+               public string Content;
+               public readonly TextBlockType Type;
+               public readonly int Length;
+               
+               public TextBlock (TextBlockType type, string content)
+               {
+                       Content = content;
+                       Type = type;
+                       Length = content.Length;
+               }
+
+               public override string ToString ()
+               {
+                       return this.GetType ().FullName + " [" + this.Type + "]";
+               }
+       }
+       
        class AspGenerator
        {
 #if NET_2_0
@@ -188,6 +216,25 @@ namespace System.Web.Compilation
                
                internal static Regex DirectiveRegex = new Regex (@"<%\s*@(\s*(?<attrname>\w[\w:]*(?=\W))(\s*(?<equal>=)\s*""(?<attrval>[^""]*)""|\s*(?<equal>=)\s*'(?<attrval>[^']*)'|\s*(?<equal>=)\s*(?<attrval>[^\s%>]*)|(?<equal>)(?<attrval>\s*?)))*\s*?%>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
 #endif
+               static readonly Regex runatServer = new Regex (@"<[\w:\.]+.*?runat=[""']?server[""']?.*?/?>",
+                                                              RegexOptions.Compiled | RegexOptions.Singleline |
+                                                              RegexOptions.Multiline | RegexOptions.IgnoreCase |
+                                                              RegexOptions.CultureInvariant);
+               
+               static readonly Regex endOfTag = new Regex (@"</[\w:\.]+\s*?>",
+                                                           RegexOptions.Compiled | RegexOptions.Singleline |
+                                                           RegexOptions.Multiline | RegexOptions.IgnoreCase |
+                                                           RegexOptions.CultureInvariant);
+               
+               static readonly Regex expressionRegex = new Regex (@"<%.*?%>",
+                                                                  RegexOptions.Compiled | RegexOptions.Singleline |
+                                                                  RegexOptions.Multiline | RegexOptions.IgnoreCase |
+                                                                  RegexOptions.CultureInvariant);
+
+               static readonly Regex clientCommentRegex = new Regex (@"<!--(.|\s)*?-->",
+                                                                     RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase |
+                                                                     RegexOptions.CultureInvariant);
+               
                ParserStack pstack;
                BuilderLocationStack stack;
                TemplateParser tparser;
@@ -757,10 +804,6 @@ namespace System.Web.Compilation
                // The kludge supports only self-closing tags inside attributes.
                //
                // KLUDGE WARNING!!
-               static readonly Regex runatServer=new Regex (@"<[\w:\.]+.*?runat=[""']?server[""']?.*?/>",
-                                                            RegexOptions.Compiled | RegexOptions.Singleline |
-                                                            RegexOptions.Multiline | RegexOptions.IgnoreCase |
-                                                            RegexOptions.CultureInvariant);
                bool ProcessTagsInAttributes (ILocation location, string tagid, TagAttributes attributes, TagType type)
                {
                        if (attributes == null || attributes.Count == 0)
@@ -798,7 +841,7 @@ namespace System.Web.Compilation
 
                                TextParsed (location, String.Format (" {0}=\"{1}", key, index > 0 ? value.Substring (0, index) : String.Empty));;
                                FlushText ();
-                               ParseAttributeTag (group.Value);
+                               ParseAttributeTag (group.Value, location);
                                if (index + length < value.Length)
                                        TextParsed (location, value.Substring (index + length) + "\"");
                                else
@@ -815,9 +858,9 @@ namespace System.Web.Compilation
                        return retval;
                }
 
-               void ParseAttributeTag (string code)
+               void ParseAttributeTag (string code, ILocation location)
                {
-                       AspParser parser = new AspParser ("@@attribute_tag@@", new StringReader (code));
+                       AspParser parser = new AspParser ("@@attribute_tag@@", new StringReader (code), location.BeginLine - 1, location as AspParser);
                        parser.Error += new ParseErrorHandler (ParseError);
                        parser.TagParsed += new TagParsedHandler (TagParsed);
                        parser.TextParsed += new TextParsedHandler (TextParsed);
@@ -1006,118 +1049,127 @@ namespace System.Web.Compilation
 
                        return Path.GetFullPath (Path.Combine (basedir, filename));
                }
+
+               delegate bool CheckBlockEnd (string text);
                
-               void TextParsed (ILocation location, string text)
+               bool CheckTagEndNeeded (string text)
                {
-                       if (ignore_text)
-                               return;
-                       
-                       // Another gross hack - get rid of comments in the parsed text
-                       int textLen = text.Length;
-                       int textMaxIndex = textLen - 1;
-                       int commentStart = text.IndexOf ("<!--");
-                       int commentLastStart = 0;
+                       return !text.EndsWith ("/>");
+               }
+               
 #if NET_2_0
-                       List <int> commentRanges = null;
+               List <TextBlock>
 #else
-                       ArrayList commentRanges = null;
+               ArrayList
 #endif
-
-                       while (commentStart != -1) {
-                               int commentEnd = text.IndexOf ("-->", commentStart);
-
-                               if (commentEnd == -1) {
-                                       if (commentStart == 0)
-                                               return;
-                                       commentEnd = textMaxIndex;
-                               }
-
-                               if (commentRanges == null) {
+               FindRegexBlocks (Regex rxStart, Regex rxEnd, CheckBlockEnd checkEnd, IList blocks, TextBlockType typeForMatches, bool discardBlocks)
+               {
 #if NET_2_0
-                                       commentRanges = new List <int> ();
+                       var ret = new List <TextBlock> ();
 #else
-                                       commentRanges = new ArrayList ();
+                       ArrayList ret = new ArrayList ();
 #endif
+                       
+                       foreach (TextBlock block in blocks) {
+                               if (block.Type != TextBlockType.Verbatim) {
+                                       ret.Add (block);
+                                       continue;
                                }
 
-                               if (commentStart > commentLastStart) {
-                                       commentRanges.Add (commentLastStart);
-                                       commentRanges.Add (commentStart);
-                               }
+                               int lastIndex = 0, index;
+                               MatchCollection matches = rxStart.Matches (block.Content);
+                               bool foundMatches = matches.Count > 0;
+                               foreach (Match match in matches) {
+                                       foundMatches = true;
+                                       index = match.Index;
+                                       if (lastIndex < index)
+                                               ret.Add (new TextBlock (TextBlockType.Verbatim, block.Content.Substring (lastIndex, index - lastIndex)));
 
-                               if (commentEnd == textMaxIndex)
-                                       break;
-                               
-                               commentLastStart = commentEnd + 3;
-                               if (commentLastStart > textMaxIndex)
-                                       break;
-                               
-                               commentStart = text.IndexOf ("<!--", commentLastStart);
-                               if (commentStart == -1) {
-                                       int tailLength = textMaxIndex - commentLastStart;
-                                       if (tailLength > 0) {
-                                               commentRanges.Add (commentLastStart);
-                                               commentRanges.Add (tailLength);
+                                       string value = match.Value;
+                                       if (rxEnd != null && checkEnd (value)) {
+                                               int startFrom = index + value.Length;
+                                               Match m = rxEnd.Match (block.Content, startFrom);
+                                               if (m.Success)
+                                                       value += block.Content.Substring (startFrom, m.Index - startFrom) + m.Value;
                                        }
-                                       break;
+
+                                       if (!discardBlocks)
+                                               ret.Add (new TextBlock (typeForMatches, value));
+                                       lastIndex = index + value.Length;
                                }
+
+                               if (lastIndex > 0 && lastIndex < block.Content.Length)
+                                       ret.Add (new TextBlock (TextBlockType.Verbatim, block.Content.Substring (lastIndex)));
+
+                               if (!foundMatches)
+                                       ret.Add (block);
                        }
 
-                       if (commentRanges != null) {
-                               if (commentRanges.Count == 0)
-                                       return;
-                               
-                               StringBuilder sb = new StringBuilder ();
-                               for (int i = 0; i < commentRanges.Count; i += 2) {
+                       return ret;
+               }
+               
+               IList SplitTextIntoBlocks (string text)
+               {
 #if NET_2_0
-                                       sb.Append (text.Substring (commentRanges [i], commentRanges [i + 1]));
+                       var ret = new List <TextBlock> ();
 #else
-                                       sb.Append (text.Substring ((int)commentRanges [i], (int)commentRanges [i + 1]));
+                       ArrayList ret = new ArrayList ();
 #endif
-                               }
 
-                               string noComments = sb.ToString ().Trim ();
-                               if (noComments.Length == 0)
-                                       return;
+                       ret.Add (new TextBlock (TextBlockType.Verbatim, text));
+                       ret = FindRegexBlocks (clientCommentRegex, null, null, ret, TextBlockType.Comment, false);
+                       ret = FindRegexBlocks (runatServer, endOfTag, CheckTagEndNeeded, ret, TextBlockType.Tag, false);
+                       ret = FindRegexBlocks (expressionRegex, null, null, ret, TextBlockType.Expression, false);
 
-                               text = noComments;
-                       }
+                       return ret;
+               }
+
+               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);
+                       if (inScript) {
+                               this.text.Append (text);
+                               FlushText (true);
                                return;
                        }
+                       
+                       IList blocks = SplitTextIntoBlocks (text);
+                       foreach (TextBlock block in blocks) {
+                               switch (block.Type) {
+                                       case TextBlockType.Verbatim:
+                                               this.text.Append (block.Content);
+                                               break;
 
-                       int startIndex = 0, index = 0;
-                       Match match;
+                                       case TextBlockType.Expression:
+                                               if (this.text.Length > 0)
+                                                       FlushText (true);
+                                               CodeRenderParser r = new CodeRenderParser (block.Content, stack.Builder, location);
+                                               r.AddChildren (this);
+                                               break;
 
-                       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;
+                                       case TextBlockType.Tag:
+                                               ParseAttributeTag (block.Content, location);
+                                               break;
 
-                               if (index < textLen)
-                                       index = text.IndexOf ('<', index);
-                               else
-                                       break;
+                                       case TextBlockType.Comment: {
+                                               this.text.Append ("<!--");
+                                               FlushText (true);
+                                               AspParser parser = new AspParser ("@@comment_code@@",
+                                                                                 new StringReader (block.Content.Substring (4, block.Length - 7)),
+                                                                                 location.BeginLine - 1,
+                                                                                 location as AspParser);
+                                               parser.Error += new ParseErrorHandler (ParseError);
+                                               parser.TagParsed += new TagParsedHandler (TagParsed);
+                                               parser.TextParsed += new TextParsedHandler (TextParsed);
+                                               parser.Parse ();
+                                               this.text.Append ("-->");
+                                               FlushText (true);
+                                               break;
+                                       }
+                               }
                        }
-                       
-                       this.text.Append (text.Substring (startIndex));
-                       //PrintLocation (location);
                }
 
                void FlushText ()
@@ -1331,7 +1383,7 @@ namespace System.Web.Compilation
                                        CheckLanguage (language);
                                        string src = (string) attributes ["src"];
                                        if (src != null) {
-                                               if (src == "")
+                                               if (src.Length == 0)
                                                        throw new ParseException (Parser,
                                                                "src cannot be an empty string");
 
@@ -1498,11 +1550,13 @@ namespace System.Web.Compilation
                        string str;
                        ControlBuilder builder;
                        AspGenerator generator;
+                       ILocation location;
                        
-                       public CodeRenderParser (string str, ControlBuilder builder)
+                       public CodeRenderParser (string str, ControlBuilder builder, ILocation location)
                        {
                                this.str = str;
                                this.builder = builder;
+                               this.location = location;
                        }
 
                        public void AddChildren (AspGenerator generator)
@@ -1549,7 +1603,7 @@ namespace System.Web.Compilation
                        
                        void DoParse (string str)
                        {
-                               AspParser parser = new AspParser ("@@nested_tag@@", new StringReader (str));
+                               AspParser parser = new AspParser ("@@code_render@@", new StringReader (str), location.BeginLine - 1, location as AspParser);
                                parser.Error += new ParseErrorHandler (ParseError);
                                parser.TagParsed += new TagParsedHandler (TagParsed);
                                parser.TextParsed += new TextParsedHandler (TextParsed);
index cc706f8185e7e0660c3d6ec6064a458fcfd2340d..2f7398477bc5f839ba0fa20616bbd789e1468d12 100644 (file)
@@ -65,6 +65,9 @@ namespace System.Web.Compilation
                string verbatimID;
                string fileText;
                StringReader fileReader;
+               bool _internal;
+               int _internalLineOffset;
+               AspParser outer;
                
                EventHandlerList events = new EventHandlerList ();
                
@@ -95,9 +98,18 @@ namespace System.Web.Compilation
                        this.filename = filename;
                        this.fileText = input.ReadToEnd ();
                        this.fileReader = new StringReader (this.fileText);
+                       this._internalLineOffset = 0;
                        tokenizer = new AspTokenizer (this.fileReader);
                }
 
+               public AspParser (string filename, TextReader input, int startLineOffset, AspParser outer)
+                       : this (filename, input)
+               {
+                       this._internal = true;
+                       this._internalLineOffset = startLineOffset;
+                       this.outer = outer;
+               }
+               
 #if NET_2_0
                public byte[] MD5Checksum {
                        get {
@@ -110,7 +122,12 @@ namespace System.Web.Compilation
 #endif
                
                public int BeginLine {
-                       get { return beginLine; }
+                       get {
+                               if (Internal)
+                                       return beginLine + InternalLineOffset;
+
+                               return beginLine;
+                       }
                }
 
                public int BeginColumn {
@@ -118,19 +135,38 @@ namespace System.Web.Compilation
                }
 
                public int EndLine {
-                       get { return endLine; }
+                       get {
+                               if (Internal)
+                                       return endLine + InternalLineOffset;
+                               return endLine;
+                       }
                }
 
                public int EndColumn {
                        get { return endColumn; }
                }
 
+               public bool Internal {
+                       get { return _internal; }
+                       set { _internal = value; }
+               }
+
+               public int InternalLineOffset {
+                       get { return _internalLineOffset; }
+                       set { _internalLineOffset = value; }
+               }
+               
                public string FileText {
                        get {
-                               if (fileText != null)
-                                       return fileText;
+                               string ret = null;
                                
-                               return null;
+                               if (Internal && outer != null)
+                                       ret = outer.FileText;
+                               
+                               if (ret == null && fileText != null)
+                                       ret = fileText;
+                               
+                               return ret;
                        }
                }
                
@@ -139,12 +175,31 @@ namespace System.Web.Compilation
                                if (beginPosition >= endPosition || fileText == null)
                                        return null;
 
-                               return fileText.Substring (beginPosition, endPosition - beginPosition);
+                               string text = FileText;
+                               int start, len;
+                               
+                               if (Internal && outer != null) {
+                                       start = beginPosition + InternalLineOffset;
+                                       len = (endPosition + InternalLineOffset) - start;
+                               } else {
+                                       start = beginPosition;
+                                       len = endPosition - beginPosition;
+                               }
+                               
+                               if (text != null)
+                                       return text.Substring (start, len);
+
+                               return null;
                        }
                }
 
                public string Filename {
-                       get { return filename; }
+                       get {
+                               if (Internal && outer != null)
+                                       return outer.Filename;
+                               
+                               return filename;
+                       }
                }
 
                public string VerbatimID {
index 662bf98f47eab29abaeef7fa55763e113c819766..0e1b2ecdd7ba2fdae1e0867674089ba4c6ad9b2e 100644 (file)
@@ -1,3 +1,22 @@
+2009-08-18  Marek Habersack  <mhabersack@novell.com>
+
+       * AspParser.cs: added a constructor which creates an internal
+       parser, nested within the outer one, and adjusts its ILocation
+       members to report correct locations in the outer parser for better
+       error reporting. Inner parser also returns the outer's FileText,
+       if available.
+
+       * AspGenerator.cs: restored part of r138474 reverted in r138657,
+       r138658 and r138659 to fix bug #525104
+       BuilderLocation creates a copy of Location for its own use (since
+       the ILocation passed is actually AspParser, the line numbers
+       change between creating a BuilderLocation and using its Location
+       member).
+       The end of tag, expression and client comment regular expressions
+       now use lazy quantifiers. This fixes bugs #525104 and #517656
+       Client side comment blocks aren't ignored anymore, they are parsed
+       just as the other parts of the document. Fixes bug #524358
+       
 2009-08-15  Marek Habersack  <mhabersack@novell.com>
 
        * AspGenerator.cs: CodeRenderParser.DoParseExpressions - match
index 514d265701281d6c9afd41a99d74f105265c5205..63d52d8dd99af50d22bd068902b9677b513340a1 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-18  Marek Habersack  <mhabersack@novell.com>
+
+       * ControlBuilder.cs: Location property makes a copy of assigned
+       ILocation now.
+
 2009-08-14  Marek Habersack  <mhabersack@novell.com>
 
        * ControlBuilder.cs: when CreateSubBuilder is called on a builder
index c1059e800818a7e1b448228d5a13e66901598f90..c84049d6de699ebe62bec91563800734a7569a02 100644 (file)
@@ -39,6 +39,8 @@ using System.Web.Configuration;
 using System.IO;
 using System.Web.UI.WebControls;
 
+using _Location = System.Web.Compilation.Location;
+
 namespace System.Web.UI {
 
        // CAS
@@ -169,7 +171,7 @@ namespace System.Web.UI {
 
                internal ILocation Location {
                        get { return location; }
-                       set { location = value; }
+                       set { location = new _Location (value); }
                }
        
                internal ArrayList OtherTags {
@@ -634,7 +636,7 @@ namespace System.Web.UI {
                {
                        this.parser = parser;
                        if (parser != null)
-                               this.location = parser.Location;
+                               this.Location = parser.Location;
 
                        this.parentBuilder = parentBuilder;
                        this.type = type;
index 97d16cbf2188fa4ae6982530a21bbcc6f102b5d2..bbeaf758f74b35333c872325ac007e221dde2485 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-18  Marek Habersack  <mhabersack@novell.com>
+
+       * TemplateControlCompilerTest.cs: added test for bug #525104 and
+       improved test for bug #517656
+
 2009-07-08  Marek Habersack  <mhabersack@novell.com>
 
        * TemplateControlCompilerTest.cs: added test for bug #520024
index 0c93fab2837d4bdaa2ad20a2b68ffcd9058568df..4b8a6b99ebd118b2b028b4da7d7d9cc2289d2f05 100644 (file)
@@ -59,6 +59,7 @@ namespace MonoTests.System.Web.Compilation {
                        WebTest.CopyResource (GetType (), "FullTagsInText.aspx", "FullTagsInText.aspx");
                        WebTest.CopyResource (GetType (), "TagsExpressionsAndCommentsInText.aspx", "TagsExpressionsAndCommentsInText.aspx");
                        WebTest.CopyResource (GetType (), "NewlineInCodeExpression.aspx", "NewlineInCodeExpression.aspx");
+                       WebTest.CopyResource (GetType (), "DuplicateControlsInClientComment.aspx", "DuplicateControlsInClientComment.aspx");
 #if NET_2_0
                        WebTest.CopyResource (GetType (), "InvalidPropertyBind1.aspx", "InvalidPropertyBind1.aspx");
                        WebTest.CopyResource (GetType (), "InvalidPropertyBind2.aspx", "InvalidPropertyBind2.aspx");
@@ -214,12 +215,24 @@ namespace MonoTests.System.Web.Compilation {
                        HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
                }
 #endif
+
+               [Test (Description="Bug #525104")]
+               [ExpectedException (typeof (HttpException))]
+               public void DuplicateControlsInClientComment ()
+               {
+                       // Just test if it throws an exception
+                       new WebTest ("DuplicateControlsInClientCommment.aspx").Run ();
+               }
                
                [Test (Description="Bug #517656")]
                public void ServerControlInClientSideComment ()
                {
-                       // We just test if it doesn't throw an exception
-                       new WebTest ("ServerControlInClientSideComment.aspx").Run ();
+                       string pageHtml = new WebTest ("ServerControlInClientSideComment.aspx").Run ();
+                       string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
+                       string originalHtml = @"<!-- comment start
+  <input id=""testBox"" type=""checkbox"" name=""testBox"" />
+comment end -->";
+                       HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
                }
 
                [Test]
diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx b/mcs/class/System.Web/Test/mainsoft/NunitWebResources/DuplicateControlsInClientComment.aspx
new file mode 100644 (file)
index 0000000..951c36c
--- /dev/null
@@ -0,0 +1,24 @@
+<%@ Page Language="C#" AutoEventWireup="true" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" runat="server">
+    <div>
+    Hello World of mono lovers
+                <!--    <asp:Literal ID="form1" runat="server" />
+
+                        <br>                            -->
+    </div>
+    <asp:Repeater runat="server" id="r1">
+    <ItemTemplate>
+    <asp:Literal ID="form2" runat="server" />
+    </ItemTemplate>
+    </asp:Repeater>
+    </form>
+</body>
+</html>
index 84d2f5bb502279a30e7891906d4be4afa7891996..e37928ee80393eb219f71746dc37f9cfb80b05eb 100644 (file)
@@ -1,6 +1,10 @@
 <%@ Page Language = "C#" %>
 
 <html><head><title>Bug 517656</title><head><body>
+<form runat="server">
+<%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %><!-- comment start
+  <asp:Checkbox id="testBox" runat="server" />
+comment end --><%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
 <p>ASP.NET repeater control to follow...</p>
 <asp:Repeater id="censusRepeater" runat="server">
        <HeaderTemplate />
@@ -33,4 +37,5 @@
        </ItemTemplate>
        <FooterTemplate />
 </asp:Repeater>
+</form>
 </body></html>