From 3112b1289878958f7b69f4aa8e78ef68b95782cd Mon Sep 17 00:00:00 2001 From: rmagick Date: Tue, 12 Jul 2005 23:34:04 +0000 Subject: [PATCH] Fix text string escaping so that strings with embedded braces are escaped properly. --- lib/RMagick.rb | 7 +++---- lib/rvg/misc.rb | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/RMagick.rb b/lib/RMagick.rb index e6fdf1aa8..dff4e75fd 100644 --- a/lib/RMagick.rb +++ b/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 @@ -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 diff --git a/lib/rvg/misc.rb b/lib/rvg/misc.rb index 016accd88..6fbd72abc 100644 --- a/lib/rvg/misc.rb +++ b/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 @@ -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