Tagging a string as html safe may be a security risk
RuboCop(0.48.1) で Tagging a string as html safe may be a security risk
と怒られた
htmlタグを直書きせずにcontent_tagを使えということらしい↓
# bad "<p>#{text}</p>".html_safe # good content_tag(:p, text) # bad out = "" out << content_tag(:li, "one") out << content_tag(:li, "two") out.html_safe # good out = [] out << content_tag(:li, "one") out << content_tag(:li, "two") safe_join(out)
引用元
Class: RuboCop::Cop::Rails::OutputSafety — Documentation for rubocop (0.41.2)
RailsでHSTS includeSubDomainsを外す方法
Rails5からforce_sslを設定しているHSTSでサブドメインまで対象にされてしまうようで設定から外したい
config/initializers/new_framework_defaults.rb
に以下を追加でサブドメインを外すことができます
Rails.application.config.ssl_options = { hsts: { subdomains: false } }
参考
ssl - How can I turn off includeSubDomains for HSTS in rails? - Stack Overflow
Chromeでhttpからhttpsに勝手にリダイレクトされる問題の解消[SSL]
なぜかChromeだけhttpからhttpsにリダイレクトされるサイトがあり原因を探していたらこちらの記事を発見
ChromeがSSLサイトのドメインを覚えて勝手にリダイレクトしてくれているらしい
HTTP Strict Transport Security(HSTS)め…
設定次第ではサブドメインまで勝手にSSLにされるという余計なお世話感
HSTSをリセットする方法
以下のURLにアクセス
chrome://net-internals/#hsts
Delete domainで対象ドメインを削除
参考
https://i-think-it.net/chrome-http-https-force-redirect-approache/
Rails GroupでまとめてCountした結果をHavingを使って絞り込む [ActiveRecord]
COUNT(*)
した結果で絞り込む方法
Havingを使う
Hoge.group(:user_id).having('count(*) > ?', 5).count