Skip to content

Commit 2750a14

Browse files
committed
fix bug where part of template annotation line was not stripped
In #2541, logic was added to strip out the first template annotation line. Unfortunately, the template annotations in Rails span multiple lines, causing invalid Ruby to be eval'd. This fix splits the compiled source on ";", which properly isolates the template annotation for easy removal.
1 parent 5ded019 commit 2750a14

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

docs/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ nav_order: 6
1010

1111
## main
1212

13-
* Fix segfault when Ruby coverage is enabled but template annotations are disabled.
13+
* Fix segfaults when Ruby coverage is enabled.
1414

15-
*George Holborn*
15+
*George Holborn*, *Joel Hawksley*
1616

1717
* Add `protocol` parameter to `with_request_url` test helper to enable testing with HTTPS protocol.
1818

lib/view_component/template.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def compiled_source
6565
result = super
6666
# Strip the annotation line to maintain correct line numbers when coverage
6767
# is running (avoids segfault from negative lineno)
68-
result = result.sub(/\A[^\n]*\n/, "") if @strip_annotation_line
68+
result = result.partition(";").last if @strip_annotation_line
6969
result
7070
end
7171
end

0 commit comments

Comments
 (0)