Skip to content

Commit 855d40a

Browse files
Add editor link scheme to the CSP
1 parent fff870b commit 855d40a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/better_errors/editor.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def url(raw_path, line)
8484
url_proc.call(file, line)
8585
end
8686

87+
def scheme
88+
url('/fake', 42).sub(/:.*/, ':')
89+
end
90+
8791
private
8892

8993
attr_reader :url_proc

lib/better_errors/middleware.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def show_error_page(env, exception=nil)
122122
# Inline style is required by the syntax highlighter.
123123
"style-src 'self' 'unsafe-inline'",
124124
"connect-src 'self'",
125+
"navigate-to 'self' #{BetterErrors.editor.scheme}",
125126
].join('; '),
126127
}
127128

0 commit comments

Comments
 (0)