Prevent Renaming to a Null Page Name

Fix http://rubyforge.org/tracker/index.php?func=detail&aid=27649&group_id=186&atid=783
This commit is contained in:
Jacques Distler 2010-01-07 08:12:22 -06:00
parent c8ef0a3dd4
commit d67ce28855
2 changed files with 3 additions and 1 deletions

View file

@ -273,6 +273,7 @@ class WikiController < ApplicationController
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

View file

@ -55,7 +55,8 @@ function toggleVisibility() {
}
function addRedirect(){
if (document.getElementById('new_name').value != "<%= escape_javascript(@page.name) %>" ) {
var e = document.getElementById('new_name').value;
if ( e != "<%= escape_javascript(@page.name) %>" && e != '') {
var content = document.getElementById('content');
content.value = '[[!redirects <%= escape_javascript(@page.name) %>]]\n' + content.value
}