Merge pull request #424 from bootstraponline/unicode_to_ascii
Ensure page file names are ASCII.
This commit is contained in:
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency('sanitize', "~> 2.0.0")
|
||||
s.add_dependency('nokogiri', "~> 1.4")
|
||||
s.add_dependency('useragent', "~> 0.4.9")
|
||||
s.add_dependency('stringex', "~> 1.4.0")
|
||||
|
||||
s.add_development_dependency('RedCloth')
|
||||
s.add_development_dependency('mocha')
|
||||
|
||||
@@ -3,6 +3,7 @@ require 'sinatra'
|
||||
require 'gollum'
|
||||
require 'mustache/sinatra'
|
||||
require 'useragent'
|
||||
require 'stringex'
|
||||
|
||||
require 'gollum/frontend/views/layout'
|
||||
require 'gollum/frontend/views/editable'
|
||||
@@ -142,7 +143,7 @@ module Precious
|
||||
end
|
||||
|
||||
post '/create' do
|
||||
name = params[:page]
|
||||
name = params[:page].to_url
|
||||
path = sanitize_empty_params(params[:path])
|
||||
format = params[:format].intern
|
||||
|
||||
|
||||
+5
-5
@@ -113,7 +113,7 @@ context "Frontend" do
|
||||
test "creates pages with escaped characters in title" do
|
||||
post "/create", :content => 'abc', :page => 'Title with spaces',
|
||||
:format => 'markdown', :message => 'foo'
|
||||
assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location']
|
||||
assert_equal 'http://example.org/title-with-spaces', last_response.headers['Location']
|
||||
get "/Title-with-spaces"
|
||||
assert_match /abc/, last_response.body
|
||||
end
|
||||
@@ -275,13 +275,13 @@ context "Frontend with lotr" do
|
||||
test "create pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
||||
get "/Mordor/Orc"
|
||||
assert_match /big smelly creatures/, last_response.body
|
||||
|
||||
post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
|
||||
assert_equal 'http://example.org/Mordor/Uruk-Hai', last_response.headers['Location']
|
||||
assert_equal 'http://example.org/Mordor/uruk-hai', last_response.headers['Location']
|
||||
get "/Mordor/Uruk-Hai"
|
||||
assert_match /really big smelly creatures/, last_response.body
|
||||
end
|
||||
@@ -289,11 +289,11 @@ context "Frontend with lotr" do
|
||||
test "edit pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
||||
|
||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
||||
|
||||
get "/Mordor/Orc"
|
||||
assert_match /not so big smelly creatures/, last_response.body
|
||||
|
||||
+11
-22
@@ -16,16 +16,16 @@ context "Unicode Support" do
|
||||
end
|
||||
|
||||
test "create and read non-latin page" do
|
||||
@wiki.write_page("한글 test", :markdown, "# 한글")
|
||||
@wiki.write_page("test", :markdown, "# 한글")
|
||||
|
||||
page = @wiki.page("한글 test")
|
||||
page = @wiki.page("test")
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert_equal "# 한글", utf8(page.raw_data)
|
||||
end
|
||||
|
||||
test "unicode with existing format rules" do
|
||||
@wiki.write_page("한글 test", :markdown, "# 한글")
|
||||
assert_equal @wiki.page("한글 test").path, @wiki.page("한글-test").path
|
||||
@wiki.write_page("test", :markdown, "# 한글")
|
||||
assert_equal @wiki.page("test").path, @wiki.page("test").path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,24 +43,13 @@ context "Frontend Unicode support" do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
test "creates korean page" do
|
||||
post "/create", :content => 'english text', :page => "한글",
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
page = @wiki.page('한글')
|
||||
assert_equal 'english text', page.raw_data
|
||||
assert_equal 'def', page.version.message
|
||||
end
|
||||
|
||||
test "creates korean page which contains korean content" do
|
||||
post "/create", :content => '한글 text', :page => "한글",
|
||||
post "/create", :content => '한글 text', :page => "k",
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
page = @wiki.page('한글')
|
||||
page = @wiki.page('k')
|
||||
assert_equal '한글 text', utf8(page.raw_data)
|
||||
assert_equal 'def', page.version.message
|
||||
end
|
||||
@@ -86,23 +75,23 @@ context "Frontend Unicode support" do
|
||||
end
|
||||
|
||||
test "heavy use 2" do
|
||||
post "/create", :content => '한글 text', :page => "한글",
|
||||
post "/create", :content => '한글 text', :page => "k",
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.update_page(@wiki.page('한글'), nil, nil, '다른 text', {})
|
||||
@wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {})
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
page = @wiki.page('한글')
|
||||
page = @wiki.page('k')
|
||||
assert_equal '다른 text', utf8(page.raw_data)
|
||||
|
||||
post '/edit/' + CGI.escape('한글'), :page => '한글', :content => '바뀐 text',
|
||||
post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text',
|
||||
:format => 'markdown', :message => 'ghi'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
page = @wiki.page('한글')
|
||||
page = @wiki.page('k')
|
||||
assert_equal '바뀐 text', utf8(page.raw_data)
|
||||
assert_equal 'ghi', page.version.message
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user