Skip to content

Commit

Permalink
Fix text string escaping so that strings with embedded braces are esc…
Browse files Browse the repository at this point in the history
…aped properly.
  • Loading branch information
rmagick committed Jul 12, 2005
1 parent cbd5031 commit 3112b12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions lib/RMagick.rb
@@ -1,4 +1,4 @@
# $Id: RMagick.rb,v 1.24 2005/07/04 23:11:04 rmagick Exp $
# $Id: RMagick.rb,v 1.25 2005/07/12 23:34:04 rmagick Exp $
#==============================================================================
# Copyright (C) 2005 by Timothy P. Hunter
# Name: RMagick.rb
Expand Down Expand Up @@ -550,9 +550,8 @@ def text(x, y, text)
elsif !(text['{'] || text['}'])
text = '{'+text+'}'
else
# escape existing braces, surround with braces
text.gsub!(/([}])/) { |b| '\\' + b }
text = '{' + text + '}'
# escape existing braces, surround with braces
text = '{' + text.gsub(/[}]/) { |b| '\\' + b } + '}'
end
primitive "text #{x},#{y} #{text}"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rvg/misc.rb
@@ -1,4 +1,4 @@
# $Id: misc.rb,v 1.6 2005/07/04 23:11:04 rmagick Exp $
# $Id: misc.rb,v 1.7 2005/07/12 23:34:04 rmagick Exp $
# Copyright (C) 2005 Timothy P. Hunter
class Magick::RVG

Expand Down Expand Up @@ -95,7 +95,7 @@ def enquote(text)
end

# escape existing braces, surround with braces
text.gsub!(/([}])/) { |b| '\\' + b }
text.gsub!(/[}]/) { |b| '\\' + b }
return '{' + text + '}'
end

Expand Down

0 comments on commit 3112b12

Please sign in to comment.