diff options
| author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-07 07:50:43 +0000 |
|---|---|---|
| committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-07 07:50:43 +0000 |
| commit | 980541b7fcce7d1a1664841139988b11d18e0a07 (patch) | |
| tree | 6eb0d1d12e815dca5bc7c522e2544363c91b1807 /ext/json/lib | |
| parent | 12085ae85e6fc981aea70241fbd50a3510f8d508 (diff) | |
| download | ruby-980541b7fcce7d1a1664841139988b11d18e0a07.tar.gz ruby-980541b7fcce7d1a1664841139988b11d18e0a07.tar.xz ruby-980541b7fcce7d1a1664841139988b11d18e0a07.zip | |
* ext/json/lib/json/pure/generator.rb (utf8_to_json):
force_encoding before gsub.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/lib')
| -rw-r--r-- | ext/json/lib/json/pure/generator.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/json/lib/json/pure/generator.rb b/ext/json/lib/json/pure/generator.rb index b44e42ac4..abc24bf72 100644 --- a/ext/json/lib/json/pure/generator.rb +++ b/ext/json/lib/json/pure/generator.rb @@ -40,8 +40,8 @@ module JSON # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with # UTF16 big endian characters as \u????, and return it. def utf8_to_json(string) # :nodoc: - string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] } - string.force_encoding(Encoding::ASCII_8BIT) + string = string.dup.force_encoding(Encoding::ASCII_8BIT) + string.gsub!(/["\\\/\x0-\x1f]/) { MAP[$&] } string.gsub!(/( (?: [\xc2-\xdf][\x80-\xbf] | |
