Skip to content

Respect ERB tag boundaries when detecting magic comments - #152

Merged
byroot merged 1 commit into
ruby:masterfrom
ydah:fix-magic-comment-matching
Oct 6, 2026
Merged

byroot merged 1 commit into
ruby:masterfrom
ydah:fix-magic-comment-matching

Conversation

@ydah

@ydah ydah commented Oct 5, 2026

Copy link
Copy Markdown
Member

The greedy regexp used to detect magic comments consumes multiple ERB tags on the same line. This can apply an encoding comment after executable code or ignore a frozen_string_literal comment following an encoding comment.

Use non-greedy matching for ERB comments in both regular and percent modes. Add regression tests verifying that encoding comments after code are ignored and adjacent encoding and frozen_string_literal comments are recognized separately.

@byroot
byroot merged commit 934d51e into ruby:master Oct 6, 2026
16 checks passed
@ydah
ydah deleted the fix-magic-comment-matching branch October 6, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants