`blank` treats Unicode whitespace differently depending on whether ActiveSupport is loaded

オープン 初心者向け
#2,130 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@sebxt がすでに取り組んでいます。

2026年10月18日 から。

  • #2131 @sebxt による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
ruby
領域
backend

調査の方向性

まず Condition#liquid_blank? と blank の比較テストを見つけます。文字列の空白を扱う式が issue の Unicode の例をどのように処理するか確認し、その後、関連する condition テストを実行します。ActiveSupport が読み込まれている場合も読み込まれていない場合も、Unicode の空白文字列が blank と比較されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

What happens

Without ActiveSupport, a string made only of Unicode whitespace (for example a non-breaking space " " or an ideographic space " ") is not blank. With ActiveSupport loaded, the same string is blank.

require 'liquid'
t = Liquid::Template.parse("{% if x == blank %}blank{% else %}not{% endif %}")
t.render!('x' => " ") # => "not"

require 'active_support/core_ext/object/blank'
t.render!('x' => " ") # => "blank"

What should happen

Both should return "blank". Condition#call_method_literal emulates ActiveSupport's blank? so that templates behave the same whether or not ActiveSupport is loaded, and the comment on liquid_blank? says it matches ActiveSupport.

Root cause

Condition#liquid_blank? checks strings with /\A\s*\z/. In Ruby \s only matches ASCII whitespace. ActiveSupport's String#blank? uses /\A[[:space:]]*\z/, which also matches Unicode space characters such as U+00A0, U+2003 and U+3000.

Non-breaking spaces are common in merchant content pasted from rich text editors, so a check like {% if block.settings.text == blank %} can give a different answer between environments.

主要言語
Ruby
スター
11.9k
フォーク
1.6k
平均マージ
11時間 20分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Shopify/liquid のほかの issue

Shopify/liquid の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。