diff options
Diffstat (limited to 'mcs')
6 files changed, 116 insertions, 13 deletions
diff --git a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs index cfb73d938ad..52a8f4fcf03 100644 --- a/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs +++ b/mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs @@ -11,6 +11,7 @@ using System.Collections; using System.IO; using System.Text; using System.Web.UI; +using System.Web.Util; namespace System.Web.Compilation { @@ -57,10 +58,50 @@ namespace System.Web.Compilation } } + class ParserStack + { + Hashtable files; + Stack parsers; + AspParser current; + + public ParserStack () + { + files = new Hashtable (); // may be this should be case sensitive for windows + parsers = new Stack (); + } + + public bool Push (AspParser parser) + { + if (files.Contains (parser.Filename)) + return false; + + files [parser.Filename] = true; + parsers.Push (parser); + current = parser; + return true; + } + + public AspParser Pop () + { + if (parsers.Count == 0) + return null; + + files.Remove (current.Filename); + return (AspParser) parsers.Pop (); + } + + public AspParser Parser { + get { return current; } + } + + public string Filename { + get { return current.Filename; } + } + } + class AspGenerator { - string filename; - AspParser parser; + ParserStack pstack; BuilderLocationStack stack; TemplateParser tparser; StringBuilder text; @@ -72,15 +113,23 @@ namespace System.Web.Compilation public AspGenerator (TemplateParser tparser) { this.tparser = tparser; - this.filename = Path.GetFullPath (tparser.InputFile); tparser.AddDependency (tparser.InputFile); text = new StringBuilder (); stack = new BuilderLocationStack (); rootBuilder = new RootBuilder (tparser); stack.Push (rootBuilder, null); tparser.RootBuilder = rootBuilder; + pstack = new ParserStack (); } + public AspParser Parser { + get { return pstack.Parser; } + } + + public string Filename { + get { return pstack.Filename; } + } + BaseCompiler GetCompilerFromType () { Type type = tparser.GetType (); @@ -96,19 +145,32 @@ namespace System.Web.Compilation throw new Exception ("Got type: " + type); } - public Type GetCompiledType () + void InitParser (string filename) { //FIXME: use the encoding of the file or the one specified in the machine.config/web.config file. StreamReader reader = new StreamReader (filename, Encoding.Default); - parser = new AspParser (filename, reader); + AspParser parser = new AspParser (filename, reader); parser.Error += new ParseErrorHandler (ParseError); parser.TagParsed += new TagParsedHandler (TagParsed); parser.TextParsed += new TextParsedHandler (TextParsed); + if (!pstack.Push (parser)) + throw new ParseException (Location, "Infinite recursion detected including file: " + filename); + tparser.AddDependency (filename); + } - parser.Parse (); + void DoParse () + { + pstack.Parser.Parse (); if (text.Length > 0) FlushText (); + pstack.Pop (); + } + + public Type GetCompiledType () + { + InitParser (Path.GetFullPath (tparser.InputFile)); + DoParse (); #if DEBUG PrintTree (rootBuilder, 0); #endif @@ -207,7 +269,14 @@ namespace System.Web.Compilation if (!isvirtual) file = attributes ["file"] as string; - TextParsed (location, tparser.ProcessInclude (isvirtual, file)); + if (isvirtual) { + file = tparser.MapPath (file); + } else if (!Path.IsPathRooted (file)) { + file = UrlUtils.Combine (tparser.BaseVirtualDir, file); + } + + InitParser (file); + DoParse (); break; default: break; @@ -251,11 +320,25 @@ namespace System.Web.Compilation ControlBuilder builder = null; BuilderLocation bl = null; Hashtable htable = (atts != null) ? atts.GetDictionary (null) : emptyHash; - if (stack.Count > 1) - builder = parent.CreateSubBuilder (tagid, htable, null, tparser, location); + if (stack.Count > 1) { + try { + builder = parent.CreateSubBuilder (tagid, htable, null, tparser, location); + } catch (TypeLoadException e) { + throw new ParseException (Location, "Type not found.", e); + } catch (Exception e) { + throw new ParseException (Location, e.Message, e); + } + } - if (builder == null && atts != null && atts.IsRunAtServer ()) - builder = rootBuilder.CreateSubBuilder (tagid, htable, null, tparser, location); + if (builder == null && atts != null && atts.IsRunAtServer ()) { + try { + builder = rootBuilder.CreateSubBuilder (tagid, htable, null, tparser, location); + } catch (TypeLoadException e) { + throw new ParseException (Location, "Type not found.", e); + } catch (Exception e) { + throw new ParseException (Location, e.Message, e); + } + } if (builder == null) return false; @@ -280,7 +363,7 @@ namespace System.Web.Compilation { if (tagtype != TagType.Close && attributes != null && attributes.IsRunAtServer ()) { if (tagtype == TagType.Tag) { - parser.VerbatimID = "script"; + Parser.VerbatimID = "script"; inScript = true; } //else if (tagtype == TagType.SelfClosing) // load script file here diff --git a/mcs/class/System.Web/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/System.Web.Compilation/ChangeLog index 234d7d2fbe8..2e179e2efa0 100644 --- a/mcs/class/System.Web/System.Web.Compilation/ChangeLog +++ b/mcs/class/System.Web/System.Web.Compilation/ChangeLog @@ -1,3 +1,8 @@ +2003-05-06 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * AspGenerator.cs: fully support including files, ie., treat them just + as C treats #includes. + 2003-05-04 Gonzalo Paniagua Javier <gonzalo@ximian.com> * AspGenerator.cs: diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index 654e9f2a13c..8d51ad1fa39 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -1,3 +1,8 @@ +2003-05-06 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * RootBuilder.cs: throw exception when the tagprefix is not valid or + not found. + 2003-05-05 Gonzalo Paniagua Javier <gonzalo@ximian.com> * TemplateControlParser.cs: return after processing @Register. diff --git a/mcs/class/System.Web/System.Web.UI/RootBuilder.cs b/mcs/class/System.Web/System.Web.UI/RootBuilder.cs index e2d96015d40..133ce52b5c8 100644 --- a/mcs/class/System.Web/System.Web.UI/RootBuilder.cs +++ b/mcs/class/System.Web/System.Web.UI/RootBuilder.cs @@ -65,6 +65,9 @@ namespace System.Web.UI string cname; int colon = tagName.IndexOf (':'); if (colon != -1) { + if (colon == 0) + throw new Exception ("Empty TagPrefix is not valid"); + if (colon + 1 == tagName.Length) return null; @@ -78,6 +81,8 @@ namespace System.Web.UI Type t = foundry.GetComponentType (prefix, cname); if (t != null) return t; + else if (prefix != "") + throw new Exception ("TagPrefix " + prefix + " not registered"); return LookupHtmlControls (tagName, attribs); } diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog index 450fec0328c..3502fa50eea 100644 --- a/mcs/class/System.Web/System.Web/ChangeLog +++ b/mcs/class/System.Web/System.Web/ChangeLog @@ -1,3 +1,8 @@ +2003-05-06 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * HttpException.cs: encode as HTML the inner exception that + is appended as a comment at the end of error pages. + 2003-05-03 Gonzalo Paniagua Javier <gonzalo@ximian.com> * HttpWriter.cs: don't do anything in Flush. Fixes #42249. diff --git a/mcs/class/System.Web/System.Web/HttpException.cs b/mcs/class/System.Web/System.Web/HttpException.cs index f9b821d6377..21705c9a576 100644 --- a/mcs/class/System.Web/System.Web/HttpException.cs +++ b/mcs/class/System.Web/System.Web/HttpException.cs @@ -152,7 +152,7 @@ namespace System.Web } builder.Append ("<hr>\n</body>\n</html>\n"); - builder.AppendFormat ("<!--\n{0}\n-->\n", exc.ToString ()); + builder.AppendFormat ("<!--\n{0}\n-->\n", HtmlEncode (exc.ToString ())); return builder.ToString (); } |