Skip to content

Commit 13f3cb7

Browse files
committed
Fix issue where updating annotations that include text that looks like special characters (e.g backslash-something) is incorrectly escaped
1 parent 1cfbaac commit 13f3cb7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/annotate/annotate_models.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ def annotate_one_file(file_name, info_block, position, options = {})
469469
space_match = old_annotation.match(/\A(?<start>\s*).*?\n(?<end>\s*)\z/m)
470470
new_annotation = space_match[:start] + wrapped_info_block + space_match[:end]
471471

472-
new_content = old_content.sub(annotate_pattern(options), new_annotation)
472+
# use the block version of sub to avoid interpreting special characters
473+
new_content = old_content.sub(annotate_pattern(options)) { |_match| new_annotation }
473474
end
474475

475476
File.open(file_name, 'wb') { |f| f.puts new_content }

0 commit comments

Comments
 (0)