`blank` treats Unicode whitespace differently depending on whether ActiveSupport is loaded
维护者通常 1 天内回复
评估
调研方向
首先找到 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 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Shopify/liquid 的其他 Issue
-
Fix Utils module to not expect arguments for inspect可能已有人在做 @Hashim1999164 于 103 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 62/100
维护者通常 1 天内回复
-
Wiki link update未关闭
难度 1/5 1 小时以内 新手友好度 65/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
hanami/hanami-action#536 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
Shopify/product-taxonomy#1054 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 13 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
docker/model-runner#1118 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
TarteelAI/quranic-universal-library#1111 ·
维护者通常 1 天内回复