DEV: For now, re-enable unsafe-eval in development mode

This allows us to use `sourceURL` which otherwise does not work. In the
future we hope to have proper source maps in development mode and
disable this again.
This commit is contained in:
Robin Ward 2020-01-24 13:18:03 -05:00
parent b0f2f1cfb6
commit 5c3f994c80
2 changed files with 5 additions and 1 deletions

View File

@ -51,6 +51,7 @@ class ContentSecurityPolicy
"#{base_url}/mini-profiler-resources/",
*script_assets
].tap do |sources|
sources << :unsafe_eval if Rails.env.development? # TODO remove this once we have proper source maps in dev
sources << 'https://www.google-analytics.com/analytics.js' if SiteSetting.ga_universal_tracking_code.present?
sources << 'https://www.googletagmanager.com/gtm.js' if SiteSetting.gtm_container_id.present?
end

View File

@ -16,6 +16,9 @@ class SourceURL < Tilt::Template
end
def evaluate(scope, locals, &block)
"#{data.rstrip} //# sourceURL=#{scope.logical_path}\n\n"
code = +"eval("
code << data.inspect
code << " + \"\\n//# sourceURL=#{scope.logical_path}\""
code << ");\n"
end
end