forked from Trustie/forgeplus
fixed 增加代码库文本内容显示敏感词检测3
This commit is contained in:
parent
b02cf8fe79
commit
981dde45ef
|
@ -255,9 +255,13 @@ module RepositoriesHelper
|
|||
content = entry['content'].present? ? entry['content'] : Gitea::Repository::Entries::GetService.call(owner, repo.identifier, URI.escape(entry['path']), ref: ref)['content']
|
||||
# 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?
|
||||
return Base64.decode64(content).force_encoding('UTF-8')
|
||||
text = Base64.decode64(content).force_encoding('UTF-8')
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
elsif entry['is_text_file'] == true
|
||||
return render_decode64_content(entry['content'])
|
||||
text = render_decode64_content(entry['content'])
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
else
|
||||
file_type = File.extname(entry['name'].to_s)[1..-1]
|
||||
if image_type?(file_type)
|
||||
|
@ -266,7 +270,7 @@ module RepositoriesHelper
|
|||
if download_type(file_type)
|
||||
return entry['content']
|
||||
end
|
||||
text = render_decode64_content(entry['content'])
|
||||
text = render_decode64_content(entry['content'])
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue