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

Đang mở Phù hợp với người mới
#2,130 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@sebxt đang làm issue này rồi.

Từ ngày 18/10/2026.

  • #2131 của @sebxt — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách tìm Condition#liquid_blank? và các bài kiểm tra so sánh với blank. Kiểm tra cách biểu thức khoảng trắng của chuỗi xử lý các ví dụ Unicode trong issue, sau đó chạy các bài kiểm tra condition liên quan. Công việc hoàn tất khi các chuỗi khoảng trắng Unicode được so sánh là blank cả khi có và không tải ActiveSupport.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Ruby
Star
11.9k
Fork
1.6k
Merge trung bình
11 giờ 20 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Shopify/liquid

Tất cả issue của Shopify/liquid

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.