From 6c56712573a7330c77158a4e7a5f9ec26a728b7f Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:51:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=87=BD=E6=95=B0=E4=BD=BF=E7=94=A8?= =?UTF-8?q?uri.escape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/commits_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/commits_controller.rb b/app/controllers/api/v1/projects/commits_controller.rb index b80d09750..141bbf789 100644 --- a/app/controllers/api/v1/projects/commits_controller.rb +++ b/app/controllers/api/v1/projects/commits_controller.rb @@ -12,7 +12,7 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController def files if params[:filepath].present? - @result_object = $gitea_hat_client.get_repos_commits_files_by_owner_repo_sha_filepath(@project&.owner.login, @project&.identifier, params[:sha], CGI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) + @result_object = $gitea_hat_client.get_repos_commits_files_by_owner_repo_sha_filepath(@project&.owner.login, @project&.identifier, params[:sha], URI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) else @result_object = $gitea_hat_client.get_repos_commits_files_by_owner_repo_sha(@project&.owner.login, @project&.identifier, params[:sha], {query: {token: current_user&.gitea_token, page: page, limit: limit}}) end From c8b80c04d6a7ac6cfe2722541b73dfe00b290594 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 28 Jan 2026 15:53:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=87=BD=E6=95=B0=E4=BD=BF=E7=94=A8?= =?UTF-8?q?uri.escape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/runs_controller.rb | 2 +- app/controllers/api/v1/projects/pulls/pulls_controller.rb | 2 +- app/controllers/repositories_controller.rb | 2 +- app/helpers/projects_helper.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/runs_controller.rb b/app/controllers/api/v1/projects/actions/runs_controller.rb index 474ab8d91..9119b73e4 100644 --- a/app/controllers/api/v1/projects/actions/runs_controller.rb +++ b/app/controllers/api/v1/projects/actions/runs_controller.rb @@ -51,7 +51,7 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::B domain = GiteaService.gitea_config[:domain] api_url = GiteaService.gitea_config[:hat_base_url] - url = "/repos/#{@owner.login}/#{@repository.identifier}/actions/runs/#{CGI.escape(params[:run_id])}/jobs/#{CGI.escape(params[:job])}/logs" + url = "/repos/#{@owner.login}/#{@repository.identifier}/actions/runs/#{URI.escape(params[:run_id])}/jobs/#{URI.escape(params[:job])}/logs" file_path = [domain, api_url, url].join file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("?") diff --git a/app/controllers/api/v1/projects/pulls/pulls_controller.rb b/app/controllers/api/v1/projects/pulls/pulls_controller.rb index af6a36c2b..9f8db2f42 100644 --- a/app/controllers/api/v1/projects/pulls/pulls_controller.rb +++ b/app/controllers/api/v1/projects/pulls/pulls_controller.rb @@ -37,7 +37,7 @@ class Api::V1::Projects::Pulls::PullsController < Api::V1::BaseController def files if params[:filepath].present? - @result_object = $gitea_hat_client.get_repos_pulls_files_by_owner_repo_index_filepath(@project&.owner.login, @project&.identifier, @pull_request.gitea_number, CGI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) + @result_object = $gitea_hat_client.get_repos_pulls_files_by_owner_repo_index_filepath(@project&.owner.login, @project&.identifier, @pull_request.gitea_number, URI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}}) else @result_object = $gitea_hat_client.get_repos_pulls_files_by_owner_repo_index(@project&.owner.login, @project&.identifier, @pull_request.gitea_number, {query: {isNew: "true",token: current_user&.gitea_token, page: page, limit: limit}}) end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ad7acc986..6d1887550 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -309,7 +309,7 @@ class RepositoriesController < ApplicationController api_url = GiteaService.gitea_config[:base_url] tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt") - url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{CGI.escape(params[:filepath])}?ref=#{CGI.escape(params[:ref])}" + url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{URI.escape(params[:filepath])}?ref=#{URI.escape(params[:ref])}" file_path = [domain, api_url, url].join file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("&") diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ed5f67212..7e511df93 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -22,7 +22,7 @@ module ProjectsHelper end def render_download_file_url(owner, repository, filepath, ref) - [base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{CGI.escape(filepath)}?ref=#{CGI.escape(ref)}"].join + [base_url, "/api/#{owner&.login}/#{repository.identifier}/raw/#{URI.escape(filepath)}?ref=#{URI.escape(ref)}"].join end def render_http_url(project)