Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`wrap` layer expansion can loop forever when the core content contains `{CORE_TEMPLATE}`

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

Chưa có ai nhận issue này.

Đá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
84/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ệ
bash
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu tại scripts/bash/common.sh:606 và kiểm tra vòng lặp mở rộng placeholder của chiến lược wrap. Thực thi một lớp wrap có nội dung lõi chứa literal {CORE_TEMPLATE}, sau đó xác nhận rằng quá trình mở rộng kết thúc trong khi thay thế placeholder của từng lớp và giữ nguyên nội dung xung quanh.

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

Mô tả

Affected: scripts/bash/common.sh:606, confirmed present at tag v0.11.9
(fetched from raw.githubusercontent.com/github/spec-kit/v0.11.9/scripts/bash/common.sh).

The wrap strategy substitutes the core content into the layer at each {CORE_TEMPLATE}
placeholder:

case "$layer_content" in
    *'{CORE_TEMPLATE}'*) ;;
    *) echo "Error: wrap strategy missing {CORE_TEMPLATE} placeholder" >&2; return 1 ;;
esac
while [[ "$layer_content" == *'{CORE_TEMPLATE}'* ]]; do
    local before="${layer_content%%\{CORE_TEMPLATE\}*}"
    local after="${layer_content#*\{CORE_TEMPLATE\}}"
    layer_content="${before}${content}${after}"
done

The loop condition re-tests the string it just substituted into. If $content itself
contains the literal {CORE_TEMPLATE}, every iteration reintroduces the placeholder, the
condition never goes false, and layer_content grows by ${#content} each pass — an
unbounded loop that ends in memory exhaustion rather than an error message.

The guard above it does not cover this: it rejects a layer that is missing the
placeholder, and says nothing about the content being substituted in.

Suggested fix — scan left to right and never re-scan what was already substituted, which
also preserves the multi-placeholder behaviour the loop exists for:

out=""; rest="$layer_content"
while [[ "$rest" == *'{CORE_TEMPLATE}'* ]]; do
    out="${out}${rest%%\{CORE_TEMPLATE\}*}${content}"
    rest="${rest#*\{CORE_TEMPLATE\}}"
done
layer_content="${out}${rest}"

Reachability / why we are reporting rather than patching. Found while adopting a
Spec Kit-based plugin in a downstream repo. It is not reachable through that plugin: it
ships nothing that declares {CORE_TEMPLATE}, so $content never carries the placeholder
on that path (grep -rl CORE_TEMPLATE over the plugin returns nothing). It is reachable for
any consumer that authors a wrap template layer whose core content includes the literal
token — which is a normal thing to do by accident when a template documents its own
placeholder syntax.

Ngôn ngữ chính
Python
Star
138k
Fork
12.4k
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
145

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 github/spec-kit

Tất cả issue của github/spec-kit

Issue tương tự

Thêm issue về Python

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.