From 4302dc247ee8961b4fde32c83d8e5601e482168d Mon Sep 17 00:00:00 2001 From: Ubiratan Pires Alberton Date: Fri, 22 Jan 2010 11:59:57 -0200 Subject: [PATCH] [#1112] Fix "redundant UTF08 sequence" in String#to_json This is an update of a patch submitted by Jamis Buck to Rails Lightouse ticket #1112 --- activesupport/lib/active_support/json/encoding.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index ffd2050..ff325c0 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -53,7 +53,7 @@ module ActiveSupport string = string.dup.force_encoding(::Encoding::BINARY) if string.respond_to?(:force_encoding) json = string. gsub(escape_regex) { |s| ESCAPED_CHARS[s] }. - gsub(/([\xC0-\xDF][\x80-\xBF]| + gsub(/([\xC2-\xDF][\x80-\xBF]| [\xE0-\xEF][\x80-\xBF]{2}| [\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s| s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/n, '\\\\u\&') -- 1.6.6