Project

General

Profile

Feature #4050 » application_controller.diff

Toshi MARUYAMA, 2011-04-28 13:59

View differences:

app/controllers/application_controller.rb
35 35
      return false
36 36
    end
37 37
  end
38

  
39
  before_filter :params_filter
40
  def params_filter
41
    if RUBY_VERSION >= '1.9'
42
      self.utf8nize(params)
43
    end
44
  end
45

  
46
  def utf8nize(obj)
47
    if obj.is_a? String
48
      if obj.respond_to?(:force_encoding)
49
        obj.force_encoding("UTF-8")
50
      else
51
        obj
52
      end
53
    elsif obj.is_a? Hash
54
      obj.each {|key, val|
55
              obj[key] = self.utf8nize(val)
56
          }
57
    elsif obj.is_a? Array
58
      obj.map {|val| self.utf8nize(val)}
59
    else
60
      obj
61
    end
62
  end
38 63
  
39 64
  before_filter :user_setup, :check_if_login_required, :set_localization
40 65
  filter_parameter_logging :password
(13-13/14)