File tree Expand file tree Collapse file tree 4 files changed +7
-8
lines changed
Expand file tree Collapse file tree 4 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 4141namespace :style do
4242 desc "Build main.css from the SASS sources"
4343 task :build do
44- css = BetterErrors ::ErrorPageStyle . compiled_style ( true )
44+ css = BetterErrors ::ErrorPageStyle . compiled_css ( true )
4545 File . open ( File . expand_path ( "lib/better_errors/templates/main.css" , File . dirname ( __FILE__ ) ) , "w" ) do |f |
4646 f . write ( css )
4747 end
Original file line number Diff line number Diff line change 33module BetterErrors
44 # @private
55 module ErrorPageStyle
6- def self . compiled_style ( for_deployment = false )
6+ def self . compiled_css ( for_deployment = false )
77 style_dir = File . expand_path ( "style" , File . dirname ( __FILE__ ) )
88 style_file = "#{ style_dir } /main.scss"
99
@@ -17,14 +17,14 @@ def self.compiled_style(for_deployment = false)
1717 engine . render
1818 end
1919
20- def self . style_tag
20+ def self . style_tag ( csp_nonce )
2121 style_file = File . expand_path ( "templates/main.css" , File . dirname ( __FILE__ ) )
2222 css = if File . exist? ( style_file )
2323 File . open ( style_file ) . read
2424 else
25- compiled_style ( false )
25+ compiled_css ( false )
2626 end
27- "<style type='text/css'>\n #{ css } \n </style>"
27+ "<style type='text/css' nonce=' #{ csp_nonce } ' >\n #{ css } \n </style>"
2828 end
2929 end
3030end
Original file line number Diff line number Diff line change @@ -119,8 +119,7 @@ def show_error_page(env, exception=nil)
119119 # for older browsers without nonce support.
120120 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
121121 "script-src 'self' 'nonce-#{ csp_nonce } ' 'unsafe-inline'" ,
122- # Inline style is required by the syntax highlighter.
123- "style-src 'self' 'unsafe-inline'" ,
122+ "style-src 'self' 'nonce-#{ csp_nonce } ' 'unsafe-inline'" ,
124123 "connect-src 'self'" ,
125124 "navigate-to 'self' #{ BetterErrors . editor . scheme } " ,
126125 ] . join ( '; ' ) ,
Original file line number Diff line number Diff line change 55</ head >
66< body class ="better-errors-javascript-not-loaded ">
77 <%# Stylesheets are placed in the <body> for Turbolinks compatibility. %>
8- <%== ErrorPageStyle . style_tag %>
8+ <%== ErrorPageStyle . style_tag ( csp_nonce ) %>
99
1010 <%# IE8 compatibility crap %>
1111 < script nonce ="<%= csp_nonce %> ">
You can’t perform that action at this time.
0 commit comments