You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Eliminate the use of inline styles, making it compatible with strict CSP for style. (#634)
Thank you for making this project easy to build and fork.
With this PR MiniProfiler will run under a strict CSP that disallows inline styles and scripts (by using nonce) with zero errors.
It accomplish this by putting dynamically generated style tag values as data attributes, and then later after appending the miniprofiler html, it queries for them and manipulates the style object on Element directly, thus eliminating the need for inline style.
Co-authored-by: Nick Craver <[email protected]>
@@ -131,6 +137,7 @@ public static string Includes(
131
137
/// <param name="maxTracesToShow">The maximum number of profilers to show (before the oldest is removed - defaults to <see cref="MiniProfilerBaseOptions.PopupMaxTracesToShow"/>).</param>
132
138
/// <param name="showControls">Whether to show the controls (defaults to <see cref="MiniProfilerBaseOptions.ShowControls"/>).</param>
133
139
/// <param name="startHidden">Whether to start hidden (defaults to <see cref="MiniProfilerBaseOptions.PopupStartHidden"/>).</param>
140
+
/// <param name="nonce">Content script policy nonce value to use for script and style tags generated.</param>
134
141
publicstaticstringIncludes(
135
142
MiniProfilerprofiler,
136
143
stringpath,
@@ -141,7 +148,8 @@ public static string Includes(
141
148
bool?showTimeWithChildren=null,
142
149
int?maxTracesToShow=null,
143
150
bool?showControls=null,
144
-
bool?startHidden=null)
151
+
bool?startHidden=null,
152
+
string?nonce=null)
145
153
{
146
154
varsb=StringBuilderCache.Get();
147
155
varoptions=profiler.Options;
@@ -150,6 +158,12 @@ public static string Includes(
0 commit comments