HomebrewでインストールしたGollum 2.7.0がベース
git config --global core.quotepath false
が必要
##Gitlab-Grit
grit/git.rb
def native(cmd, options = {}, *args, &block)
if raise_errors && !status.success?
raise CommandFailed.new(argv.join(' '), status.exitstatus, process.err)
elsif process_info
- [status.exitstatus, process.out, process.err]
+ [status.exitstatus, process.out.force_encoding('utf-8'), process.err]
else
- process.out
+ process.out.force_encoding('utf-8')
end
rescue TimeoutExceeded, MaximumOutputExceeded
raise GitTimeout, argv.join(' ')
grit/index.rb
def write_tree(tree = nil, now_tree = nil)
# fill in original tree
now_tree = read_tree(now_tree) if(now_tree && now_tree.is_a?(String))
now_tree.contents.each do |obj|
- sha = [obj.id].pack("H*")
+ sha = [obj.id].pack("H*").force_encoding('utf-8')
k = obj.name
k += '/' if (obj.class == Grit::Tree)
tmode = obj.mode.to_i.to_s ## remove zero-padding
when Array
sha, mode = v
if sha.size == 40 # must be a sha
- sha = [sha].pack("H*")
+ sha = [sha].pack("H*").force_encoding('utf-8')
mode = mode.to_i.to_s # leading 0s not allowed
k = k.split('/').last # slashes not allowed
str = "%s %s\0%s" % [mod, k, sha]
tree_contents[k] = str
end
when String
sha = write_blob(v)
- sha = [sha].pack("H*")
+ sha = [sha].pack("H*").force_encoding('utf-8')
str = "%s %s\0%s" % ['100644', k, sha]
tree_contents[k] = str
when Hash
ctree = now_tree/k if now_tree
sha = write_tree(v, ctree)
- sha = [sha].pack("H*")
+ sha = [sha].pack("H*").force_encoding('utf-8')
str = "%s %s\0%s" % ['40000', k, sha]
tree_contents[k + '/'] = str
when false
gollum/app.rb
String#def to_url
alias :upstream_to_url :to_url
# _Header => header which causes errors
def to_url
- return nil if self.nil?
- upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar'], :force_downcase => false
+ #return nil if self.nil?
+ #upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar'], :force_downcase => false
+ self
end
end
gollum/app.rb
post '/create' do
wiki.write_page(name, format, params[:content], commit_message, path)
page_dir = settings.wiki_options[:page_file_dir].to_s
- redirect to("/#{clean_url(::File.join(page_dir, path, name))}")
+ redirect to("/#{clean_url(encodeURIComponent(::File.join(page_dir, path, name)))}")
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
mustache :error
gollum/app.rb
post '/compare/*' do
end
post '/compare/*' do
- @file = params[:splat].first
+ @file = encodeURIComponent(params[:splat].first)
@versions = params[:versions] || []
if @versions.size < 2
redirect to("/history/#{@file}")
gollum/public/gollum/javascript/gollum.js
$('#minibutton-new-page').click(function(e) {
path = path.replace(/^pages\/?/,'')
// For consistency remove the trailing /
path = path.replace(/\/$/,'')
+ path = decodeURIComponent(path)
}
var context_blurb =
"Page will be created under " +
gollum-lib/commiter.rb
def add_to_index(dir, name, format, data, allow_same_ext = false)
end
end
- fullpath = fullpath.force_encoding('ascii-8bit') if fullpath.respond_to?(:force_encoding)
+ fullpath = fullpath.force_encoding('utf-8') if fullpath.respond_to?(:force_encoding)
begin
data = @wiki.normalize(data)
gollum-lib/commiter.rb
def update_working_dir(dir, name, format)
::File.join(dir, @wiki.page_file_name(name, format))
end
- path = path.force_encoding('ascii-8bit') if path.respond_to?(:force_encoding)
+ path = path.force_encoding('utf-8') if path.respond_to?(:force_encoding)
Dir.chdir(::File.join(@wiki.repo.path, '..')) do
if file_path_scheduled_for_deletion?(index.tree, path)
gollum-lib/commiter.rb
def method_missing(name, *args)
# Proxies methods t
def method_missing(name, *args)
- args.map! { |item| item.respond_to?(:force_encoding) ? item.force_encoding('ascii-8bit') : item }
+ args.map! { |item| item.respond_to?(:force_encoding) ? item.force_encoding('utf-8') : item }
index.send(name, *args)
end
end