禁用敏感词

This commit is contained in:
xxq250 2025-12-13 17:08:34 +08:00
parent 5ff91b0510
commit 53307632ae
1 changed files with 4 additions and 4 deletions

View File

@ -255,7 +255,7 @@ module RepositoriesHelper
content = entry['content'].present? ? entry['content'] : Gitea::Repository::Entries::GetService.call(owner, repo.identifier, URI.escape(entry['path']), ref: ref)['content']
# readme_render_decode64_content(content, owner, repo, ref)
text = new_readme_render_decode64_content(content, owner, repo, ref, entry['path'], entry['name'])
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
# text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
text
end
@ -266,11 +266,11 @@ module RepositoriesHelper
# Rails.logger.info("content===#{content}")
return Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding?
text = Base64.decode64(content).force_encoding('UTF-8')
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
# text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
text
elsif entry['is_text_file'] == true
text = render_decode64_content(entry['content'])
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
# text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
text
else
file_type = File.extname(entry['name'].to_s)[1..-1]
@ -281,7 +281,7 @@ module RepositoriesHelper
return entry['content']
end
text = render_decode64_content(entry['content'])
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
# text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
text
end
end