From 6f6196f7dcdd17317d70f99a410d863dba4553df Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 13 Jan 2020 16:57:55 +0800 Subject: [PATCH] 1 --- app/controllers/concerns/git_helper.rb | 1 + app/controllers/shixuns_controller.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index f80434392..f22753dde 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -26,6 +26,7 @@ module GitHelper if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8 content.encode('UTF-8', 'GBK', {:invalid => :replace, :undef => :replace, :replace => ' '}) else + Rails.logger.info("####encoding:#{content.encoding}") content.force_encoding('UTF-8') end end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 4e26475fe..8ca36cd22 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -3,6 +3,7 @@ class ShixunsController < ApplicationController include ApplicationHelper include ElasticsearchAble include CoursesHelper + include GitCommon before_action :require_login, :check_auth, except: [:download_file, :index, :menus, :show, :show_right, :ranking_list, :discusses, :collaborators, :fork_list, :propaedeutics] @@ -877,7 +878,7 @@ class ShixunsController < ApplicationController end end - include GitCommon + def update_file content = params[:content]