Skip to content

Commit

Permalink
Fix issue where updating annotations that include text that looks lik…
Browse files Browse the repository at this point in the history
…e special characters (e.g backslash-something) is incorrectly escaped
  • Loading branch information
alexpech12 committed Aug 5, 2024
1 parent 1cfbaac commit 13f3cb7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ def annotate_one_file(file_name, info_block, position, options = {})
space_match = old_annotation.match(/\A(?<start>\s*).*?\n(?<end>\s*)\z/m)
new_annotation = space_match[:start] + wrapped_info_block + space_match[:end]

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

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

0 comments on commit 13f3cb7

Please sign in to comment.