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

features generate-docs: `$` sequences in NOTES.md and descriptions are expanded as String.replace patterns, splicing the README template into the output

Đang mở Phù hợp với người mới
#1,325 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

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
82/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ệ
typescript
Lĩnh vực
cli

Hướng nghiên cứu

Mẫu được điền trong src/spec-node/collectionCommonUtils/generateDocsCommandImpl.ts quanh các dòng 170-182, nơi .replace() được gọi với các giá trị chuỗi. Hãy thay các lời gọi đó, với nội dung do người dùng cung cấp (notes, name, description, mô tả tùy chọn), bằng một hàm replacer, rồi chạy lại repro: một NOTES.md có chứa $ phải xuất hiện nguyên văn trong README.md được tạo ra, không có bản sao thứ hai của mẫu. Hoàn thành khi đầu ra khớp với văn bản mong đợi và $', $&, $$ cũng được giữ nguyên không đổi.

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

Mô tả

Problem

If a Feature's NOTES.md contains $` (for example the markdown `$`), the generated README.md gets a second copy of the README template at that point: the title, the description, and an "Example Usage" block with literal #{Registry}/#{Namespace}/<id>:#{Version} and #{Customizations}. $', $& and $$ also misbehave, and so do name, description and option descriptions in devcontainer-feature.json.

Repro (CLI 0.89.0; same on main at 155f8b2)

mkdir -p src/demo
echo '{ "id": "demo", "version": "1.0.0", "name": "Demo", "description": "A demo." }' > src/demo/devcontainer-feature.json
echo 'Escape quotes, `$` or backslashes.' > src/demo/NOTES.md
devcontainer features generate-docs -p src -n x/y
  • Expected: Escape quotes, `$` or backslashes.
  • Actual: Escape quotes, `, then the template copy (# Demo (demo), ## Example Usage, #{Registry}/#{Namespace}/demo:#{Version}, #{Customizations}), then ` or backslashes.

Cause

src/spec-node/collectionCommonUtils/generateDocsCommandImpl.ts:170-182 fills the template with .replace('#{…}', value). With a string replacement, String.prototype.replace expands $`, $', $& and $$ (MDN). The same code is in devcontainers/action src/generateDocs.ts:152-162.

Suggested fix

Pass a replacer function, as in .replace('#{Notes}', () => generateNotesMarkdown()), for every placeholder that takes user content.

Not the same as #1324, which is about how option values are sourced at build time.

Ngôn ngữ chính
TypeScript
Star
3k
Fork
462
Merge trung bình
13 giờ 28 phút
Pull request đã merge (30 ngày)
2

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 devcontainers/cli

Tất cả issue của devcontainers/cli

Issue tương tự

Thêm issue về TypeScript

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.