/
NotRestrictingParserFilter.cs
188 lines (155 loc) · 5.23 KB
/
NotRestrictingParserFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Reflection;
using System.Web.UI;
using System.Collections;
public class NotRestrictingParserFilter : PageParserFilter
{
public override bool AllowCode
{
get { return true; }
}
public override int NumberOfControlsAllowed
{
get { return int.MaxValue; }
}
public override int NumberOfDirectDependenciesAllowed
{
get { return int.MaxValue; }
}
public override int TotalNumberOfDependenciesAllowed
{
get { return int.MaxValue; }
}
public override bool AllowBaseType(Type baseType)
{
return true;
}
public override bool AllowControl(Type controlType, ControlBuilder builder)
{
return true;
}
public override bool AllowServerSideInclude(string includeVirtualPath)
{
return true;
}
public override bool AllowVirtualReference(string referenceVirtualPath, VirtualReferenceType referenceType)
{
return true;
}
public override CompilationMode GetCompilationMode(CompilationMode current)
{
return base.GetCompilationMode(current);
}
public override Type GetNoCompileUserControlType()
{
return base.GetNoCompileUserControlType();
}
public override void PreprocessDirective(string directiveName, System.Collections.IDictionary attributes)
{
base.PreprocessDirective(directiveName, attributes);
}
public override bool ProcessCodeConstruct(CodeConstructType codeType, string code)
{
return base.ProcessCodeConstruct(codeType, code);
}
public override bool ProcessDataBindingAttribute(string controlId, string name, string value)
{
return base.ProcessDataBindingAttribute(controlId, name, value);
}
public override bool ProcessEventHookup(string controlId, string eventName, string handlerName)
{
return base.ProcessEventHookup(controlId, eventName, handlerName);
}
public override void ParseComplete(ControlBuilder rootBuilder)
{
base.ParseComplete(rootBuilder);
}
protected override void Initialize()
{
base.Initialize();
}
const BindingFlags InstPubNonpub = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
protected ControlBuilder GetParentBuilder(ControlBuilder controlBuilder)
{
if (controlBuilder == null)
{
throw new ArgumentNullException("controlBuilder");
}
return (ControlBuilder)controlBuilder.GetType().GetProperty("ParentBuilder", InstPubNonpub).GetValue(controlBuilder, null);
}
protected ControlBuilder GetRootBuilder(ControlBuilder controlBuilder)
{
if (controlBuilder == null)
{
throw new ArgumentNullException("controlBuilder");
}
while (GetParentBuilder(controlBuilder) != null)
{
controlBuilder = GetParentBuilder(controlBuilder);
}
return controlBuilder;
}
protected ArrayList GetSubBuilders(ControlBuilder controlBuilder)
{
if (controlBuilder == null)
{
throw new ArgumentNullException("controlBuilder");
}
return (ArrayList)controlBuilder.GetType().GetProperty("SubBuilders", InstPubNonpub).GetValue(controlBuilder, null);
}
protected ControlBuilder GetDefaultPropertyBuilder(ControlBuilder controlBuilder)
{
if (controlBuilder == null)
{
throw new ArgumentNullException("controlBuilder");
}
PropertyInfo pi = null;
Type type = controlBuilder.GetType();
while (type != null && (InlineAssignHelper(ref pi, type.GetProperty("DefaultPropertyBuilder", InstPubNonpub))) == null)
{
type = type.BaseType;
}
return (ControlBuilder)pi.GetValue(controlBuilder, null);
}
protected ArrayList GetTemplatePropertyEntries(ControlBuilder controlBuilder)
{
if (controlBuilder == null)
{
throw new ArgumentNullException("controlBuilder");
}
ICollection tpes = (ICollection)controlBuilder.GetType().GetProperty("TemplatePropertyEntries", InstPubNonpub).GetValue(controlBuilder, null);
if (tpes == null || tpes.Count == 0)
{
return new ArrayList(0);
}
else
{
return (ArrayList)tpes;
}
}
protected ArrayList GetComplexPropertyEntries(ControlBuilder controlBuilder)
{
if (controlBuilder == null)
{
throw new ArgumentNullException("controlBuilder");
}
ICollection cpes = (ICollection)controlBuilder.GetType().GetProperty("ComplexPropertyEntries", InstPubNonpub).GetValue(controlBuilder, null);
if (cpes == null || cpes.Count == 0)
{
return new ArrayList(0);
}
else
{
return (ArrayList)cpes;
}
}
protected T InlineAssignHelper<T>(ref T target, T value)
{
target = value;
return value;
}
}