From d67ce288557bc805f9625c7d9d82784b594f98e0 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Thu, 7 Jan 2010 08:12:22 -0600 Subject: [PATCH] Prevent Renaming to a Null Page Name Fix http://rubyforge.org/tracker/index.php?func=detail&aid=27649&group_id=186&atid=783 --- app/controllers/wiki_controller.rb | 1 + app/views/wiki/edit.rhtml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index b4d247f2..221586ba 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -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 diff --git a/app/views/wiki/edit.rhtml b/app/views/wiki/edit.rhtml index 6644f7e9..a09bb005 100644 --- a/app/views/wiki/edit.rhtml +++ b/app/views/wiki/edit.rhtml @@ -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 }