summaryrefslogtreecommitdiff
path: root/ext/json/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/lib')
-rw-r--r--ext/json/lib/json/pure/generator.rb2
-rw-r--r--ext/json/lib/json/pure/parser.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/ext/json/lib/json/pure/generator.rb b/ext/json/lib/json/pure/generator.rb
index 0fe73be41a7..c8bbfd09eeb 100644
--- a/ext/json/lib/json/pure/generator.rb
+++ b/ext/json/lib/json/pure/generator.rb
@@ -40,7 +40,7 @@ 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]/) { |c| MAP[c] }
+ string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] }
string.gsub!(/(
(?:
[\xc2-\xdf][\x80-\xbf] |
diff --git a/ext/json/lib/json/pure/parser.rb b/ext/json/lib/json/pure/parser.rb
index e886ba8d2c2..39bee542690 100644
--- a/ext/json/lib/json/pure/parser.rb
+++ b/ext/json/lib/json/pure/parser.rb
@@ -122,7 +122,8 @@ module JSON
def parse_string
if scan(STRING)
return '' if self[1].empty?
- self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
+ self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do
+ c = $&
if u = UNESCAPE_MAP[c[1]]
u
else # \uXXXX