Skip to content

Commit b515e89

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 49aed4f commit b515e89

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

app/views/layouts/application.html.slim

Lines changed: 6 additions & 6 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')
@@ -18,13 +18,13 @@ html lang=I18n.locale data-default-locale=I18n.default_locale
1818
= javascript_include_tag('application', 'data-turbolinks-track': 'reload', integrity: true, crossorigin: 'anonymous')
1919
= yield(:head)
2020
= csrf_meta_tags
21-
= csp_meta_tag
22-
meta name='sentry' data-enabled=SentryJavascript.active?.to_s data-release=SentryJavascript.release data-dsn=SentryJavascript.dsn data-environment=SentryJavascript.environment
23-
meta name='current-user' content=current_user&.to_page_context&.to_json
24-
meta name='current-contributor' content=current_contributor&.to_page_context&.to_json
21+
/= csp_meta_tag
22+
meta name='sentry' data-enabled=SentryJavascript.active?.to_s data-release=SentryJavascript.release data-dsn=SentryJavascript.dsn data-environment=SentryJavascript.environment content=''
23+
meta name='current-user' content=current_user&.to_page_context&.to_json.to_s
24+
meta name='current-contributor' content=current_contributor&.to_page_context&.to_json.to_s
2525
body
2626
- unless @embed_options[:hide_navbar]
27-
nav.navbar.bg-dark.navbar-expand-md.mb-4.py-1 role='navigation' data-bs-theme="dark"
27+
nav.navbar.bg-dark.navbar-expand-md.mb-4.py-1 data-bs-theme="dark"
2828
.container
2929
.navbar-brand
3030
i.fa-solid.fa-code

config/initializers/content_security_policy.rb

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

109110
# Report violations without enforcing the policy.
110111
# config.content_security_policy_report_only = true

0 commit comments

Comments
 (0)