From fb7ed0bb69b8135a612b3275d67d6c01eef69730 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 12 Apr 2016 18:14:17 +0800 Subject: [PATCH] fix encoding --- app/controllers/announcements_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index b4a7774..3eb229f 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -237,7 +237,7 @@ class AnnouncementsController < ApplicationController "tag" => tag.name , "url" => OrbitHelper.page_for_tag(tag) } } rescue [] - files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path).encode('utf-8') : file.title rescue '') } } rescue [] + files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? URI.unescape(File.basename(file.file.path)) : file.title rescue '') } } rescue [] links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] update_user = announcement.update_user.member_profile.name rescue "" @@ -285,7 +285,7 @@ class AnnouncementsController < ApplicationController } } - files = announcement["bulletin_files"].map{|file| { "file_url" => file["url"], "file_title" => (file["title_translations"][locale] == "" ? File.basename(file["url"]).encode('utf-8') : file["title_translations"][locale] rescue '') } } rescue [] + files = announcement["bulletin_files"].map{|file| { "file_url" => file["url"], "file_title" => (file["title_translations"][locale] == "" ? URI.unescape(File.basename(file["url"])) : file["title_translations"][locale] rescue '') } } rescue [] links = announcement["bulletin_links"].map{|link| { "link_url" => link["url"], "link_title" => (link["title_translations"][locale] == "" ? link["url"] : link["title_translations"][locale]) } } rescue []