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

未关闭 适合新手
#2,130 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sebxt 已经在做这个了。

开始于 2026年10月18日。

  • #2131 来自 @sebxt —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ruby
领域
backend

调研方向

首先找到 Condition#liquid_blank? 和 blank 比较的测试。检查它的字符串空白表达式如何处理 issue 中的 Unicode 示例,然后运行相关的条件测试。无论是否加载 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 分钟
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Shopify/liquid 的其他 Issue

查看 Shopify/liquid 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。