fix: decode error

This commit is contained in:
yystopf 2021-09-30 19:49:17 +08:00
parent 9685c97177
commit 588850440e
3 changed files with 3 additions and 2 deletions

View File

@ -74,6 +74,7 @@ class RepositoriesController < ApplicationController
def sub_entries
file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip))
@path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
if @project.educoder?
if params[:type] === 'file'

View File

@ -6,7 +6,7 @@ module RepositoriesHelper
def render_decode64_content(str)
return nil if str.blank?
Base64.decode64(str).force_encoding("UTF-8")
Base64.decode64(str).force_encoding("UTF-8").encode("UTF-8", invalid: :replace)
end
def download_type(str)

View File

@ -9,7 +9,7 @@ if @project.forge?
json.type entry['type']
json.size entry['size']
json.content decode64_content(entry, @owner, @repository, @ref)
json.content decode64_content(entry, @owner, @repository, @ref, @path)
json.target entry['target']
download_url =