Skip to content

Commit c261cfd

Browse files
committed
Fix HTML validator errors for main page
In Slim any attribute with a `nil` value is omitted (completely). An empty string is also treated specifically, since the attribute name is still included but without any assignment. The first handling (omitting the attribute at all) is not HTML compliant.
1 parent 99b7790 commit c261cfd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

app/views/layouts/application.html.slim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
doctype html
22
html lang=I18n.locale data-default-locale=I18n.default_locale
33
head
4-
meta charset='utf8'
4+
meta charset='utf-8'
55
meta name='viewport' content='width=device-width, initial-scale=1'
66
meta name='mobile-web-app-capable' content='yes'
77
= render('breadcrumbs_and_title')
@@ -17,13 +17,13 @@ html lang=I18n.locale data-default-locale=I18n.default_locale
1717
= javascript_include_tag('application', 'data-turbolinks-track': 'reload', integrity: true, crossorigin: 'anonymous')
1818
= yield(:head)
1919
= csrf_meta_tags
20-
= csp_meta_tag
21-
meta name='sentry' data-enabled=SentryJavascript.active?.to_s data-release=SentryJavascript.release data-dsn=SentryJavascript.dsn data-environment=SentryJavascript.environment
22-
meta name='current-user' content=current_user&.to_page_context&.to_json
20+
/= csp_meta_tag
21+
meta name='sentry' data-enabled=SentryJavascript.active?.to_s data-release=SentryJavascript.release data-dsn=SentryJavascript.dsn data-environment=SentryJavascript.environment content=''
22+
meta name='current-user' content=current_user&.to_page_context&.to_json.to_s
2323
body.d-flex.flex-column
2424
#content
2525
header.sticky-top
26-
nav.navbar.bg-light.navbar-expand-lg.text-bg-light role='navigation'
26+
nav.navbar.bg-light.navbar-expand-lg.text-bg-light
2727
.container
2828
= link_to home_index_path, class: 'navbar-brand'
2929
i.fa-solid.fa-anchor.me-2.text-secondary

config/initializers/content_security_policy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def self.get_host_source(url)
115115
# Generate session nonces for permitted importmap, inline scripts, and inline styles.
116116
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
117117
# config.content_security_policy_nonce_directives = %w(script-src style-src)
118+
# Once configured, keep in mind to uncomment `csp_meta_tag` in `views/layouts/application.html.slim`.
118119

119120
# Report violations without enforcing the policy.
120121
# config.content_security_policy_report_only = true

0 commit comments

Comments
 (0)