From bafa7743f16e0befce57f093ff3046ec69880703 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 26 Jan 2010 00:18:30 -0600 Subject: [PATCH] Allow Periods in Page Names Thanks to Jeff Zellman. --- app/controllers/wiki_controller.rb | 2 -- config/routes.rb | 2 +- lib/url_generator.rb | 1 - public/stylesheets/instiki.css | 10 --------- test/functional/routes_test.rb | 5 ++++- test/functional/wiki_controller_test.rb | 28 +++++-------------------- test/test_helper.rb | 1 - test/unit/page_test.rb | 2 +- 8 files changed, 11 insertions(+), 40 deletions(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index b4b82948..6fafac2c 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -292,13 +292,11 @@ EOL the_content = params['content'].purify prev_content = '' filter_spam(the_content) - raise Instiki::ValidationError.new('Your name cannot contain a "."') if author_name.include? '.' cookies['author'] = { :value => author_name.dup.as_bytes, :expires => Time.utc(2030) } if @page new_name = params['new_name'] ? params['new_name'].purify : @page_name new_name = @page_name if new_name.empty? prev_content = @page.current_revision.content - raise Instiki::ValidationError.new('Your new title cannot contain a "."') if new_name.include? '.' raise Instiki::ValidationError.new('A page named "' + new_name.escapeHTML + '" already exists.') if @page_name != new_name && @web.has_page?(new_name) wiki.revise_page(@web_name, @page_name, new_name, the_content, Time.now, diff --git a/config/routes.rb b/config/routes.rb index 7d19313c..c1ae35f7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,7 +30,7 @@ ActionController::Routing::Routes.draw do |map| connect_to_web map, ':web/revision/:id/:rev', :controller => 'wiki', :action => 'revision', :requirements => { :rev => /\d*/} connect_to_web map, ':web/list/:category', :controller => 'wiki', :action => 'list', :requirements => { :category => /.*/}, :category => nil connect_to_web map, ':web/recently_revised/:category', :controller => 'wiki', :action => 'recently_revised', :requirements => { :category => /.*/}, :category => nil - connect_to_web map, ':web/:action/:id', :controller => 'wiki' + connect_to_web map, ':web/:action/:id', :controller => 'wiki', :requirements => {:id => /.*/} connect_to_web map, ':web/:action', :controller => 'wiki' connect_to_web map, ':web', :controller => 'wiki', :action => 'index' diff --git a/lib/url_generator.rb b/lib/url_generator.rb index b6da0a15..66c3b897 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -91,7 +91,6 @@ class UrlGenerator < AbstractUrlGenerator end def page_link(mode, name, text, web_address, known_page) - return %{Illegal link (target contains a '.'): #{name}} if name.include?('.') case mode when :export if known_page diff --git a/public/stylesheets/instiki.css b/public/stylesheets/instiki.css index a62c48db..804e128b 100644 --- a/public/stylesheets/instiki.css +++ b/public/stylesheets/instiki.css @@ -412,16 +412,6 @@ margin:0; padding:0; } -span.wikilink-error { - border: solid 2px red; - background-color: pink; -} - -span.wikilink-error b { - font-size: 80%; - color: #009; -} - textarea#content { font-size: 1em; line-height: 1.125; diff --git a/test/functional/routes_test.rb b/test/functional/routes_test.rb index f16645db..517a8551 100644 --- a/test/functional/routes_test.rb +++ b/test/functional/routes_test.rb @@ -12,7 +12,10 @@ class RoutesTest < ActionController::TestCase assert_routing('x/y', :controller => 'wiki', :web => 'x', :action => 'y') assert_routing('x/y/z', :controller => 'wiki', :web => 'x', :action => 'y', :id => 'z') assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y'}, 'x/y/') - assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z'}, 'x/y/z/') + assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z'}, 'x/y/z') + assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z/'}, 'x/y/z/') + assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z/'}, 'x/y/z%2F') + assert_recognizes({:web => 'x', :controller => 'wiki', :action => 'y', :id => 'z.w'}, 'x/y/z.w') end def test_parse_uri_interestng_cases diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 9282ce39..ebd1166d 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -833,37 +833,19 @@ class WikiControllerTest < ActionController::TestCase assert_equal 'AnonymousCoward', another_page.author end - def test_save_revised_content_invalid_author_name + def test_save_revised_content_author_name_with_period r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => 'Contents of a very new page', 'author' => 'foo.bar' - assert_redirected_to :action => 'edit', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage', - :content => 'Contents of a very new page' - assert r.flash[:error].to_s == 'Your name cannot contain a "."' - - r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => 'a'*10184, - 'author' => 'foo.bar' - assert_redirected_to :action => 'edit', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage' - assert r.flash[:error].to_s == 'Your name cannot contain a "."' - - r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page', - 'author' => 'foo.bar' - assert_redirected_to :action => 'new', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage', - :content => 'Contents of a new page' - assert r.flash[:error].to_s == 'Your name cannot contain a "."' + assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage' + assert_equal 'foo.bar', @wiki.read_page('wiki1', 'HomePage').author r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'a'*10184, 'author' => 'foo.bar' - assert_redirected_to :action => 'new', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage' - assert r.flash[:error].to_s == 'Your name cannot contain a "."' + assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage' + assert_equal 'foo.bar', @wiki.read_page('wiki1', 'NewPage').author end def test_save_invalid_author_name - r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page', - 'author' => 'foo.bar' - assert_redirected_to :action => 'new', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage', - :content => 'Contents of a new page' - assert r.flash[:error].to_s == 'Your name cannot contain a "."' - r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page', 'author' => "Fu\000Manchu" diff --git a/test/test_helper.rb b/test/test_helper.rb index ca143480..0820eb2b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -131,7 +131,6 @@ class StubUrlGenerator < AbstractUrlGenerator def page_link(mode, name, text, web_address, known_page) link = CGI.escape(name) - return %{Illegal link (target contains a '.'): #{name}} if name.include?('.') title = web_address == 'wiki1' ? '' : " title='#{web_address}'" case mode when :export diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index b0b415de..8e2499fd 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb @@ -172,7 +172,7 @@ class PageTest < ActiveSupport::TestCase "

Reference to H\303\241ppy Page" assert_equal( s + " and to Wanted Page2?.pdf " + - "and Illegal link (target contains a '.'): foo.pdf

", + "and foo.pdf?

", x_test_renderer(new_page.revisions.last).display_content(true) ) assert_equal 3, references.size # now it works.