<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>thr3a</author_name>
  <author_url>https://blog.hatena.ne.jp/thr3a/</author_url>
  <blog_title>動かざることバグの如し</blog_title>
  <blog_url>https://blog.turai.work/</blog_url>
  <categories>
    <anon>rails</anon>
  </categories>
  <description>環境 Rails 8.0 safe_joinサンプルコード Railsのビューで複数の文字列をHTMLタグで結合したい場面がある。たとえば複数行のテキストを&lt;br&gt;区切りで表示したいとき、素朴に書くとこうなる。 lines.join(&quot;&lt;br&gt;&quot;).html_safe これで動くにはするが、html_safeを使うと全体のHTMLエスケープが無効になり、linesの中にユーザー入力が混入していると XSS の温床になる。そこで使うのがsafe_joinだ。 module ApplicationHelper def make_sample_lines lines = [] lines &lt;&lt; &quot;り…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.turai.work%2Fentry%2F20260610%2F1781045455&quot; title=&quot;安易にhtml_safe使うな safe_join使え - 動かざることバグの如し&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2026-06-10 07:50:55</published>
  <title>安易にhtml_safe使うな safe_join使え</title>
  <type>rich</type>
  <url>https://blog.turai.work/entry/20260610/1781045455</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
