]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/editpage.pm
fix uninitilized value warning on bad page name
[git.ikiwiki.info.git] / IkiWiki / Plugin / editpage.pm
index 8915211d48279ea33f36eeb4739ed1bec99a641d..8c78e853cfc188927a4c1c225dca7a1267fdc7b4 100644 (file)
@@ -75,7 +75,7 @@ sub cgi_editpage ($$) {
                required => [qw{editcontent}],
                javascript => 0,
                params => $q,
                required => [qw{editcontent}],
                javascript => 0,
                params => $q,
-               action => $config{cgiurl},
+               action => IkiWiki::cgiurl(),
                header => 0,
                table => 0,
                template => { template("editpage.tmpl") },
                header => 0,
                table => 0,
                template => { template("editpage.tmpl") },
@@ -91,14 +91,14 @@ sub cgi_editpage ($$) {
        # This untaint is safe because we check file_pruned and
        # wiki_file_regexp.
        my ($page)=$form->field('page')=~/$config{wiki_file_regexp}/;
        # This untaint is safe because we check file_pruned and
        # wiki_file_regexp.
        my ($page)=$form->field('page')=~/$config{wiki_file_regexp}/;
-       $page=possibly_foolish_untaint($page);
-       my $absolute=($page =~ s#^/+##); # absolute name used to force location
        if (! defined $page || ! length $page ||
            file_pruned($page)) {
                error(gettext("bad page name"));
        }
        if (! defined $page || ! length $page ||
            file_pruned($page)) {
                error(gettext("bad page name"));
        }
+       $page=possibly_foolish_untaint($page);
+       my $absolute=($page =~ s#^/+##); # absolute name used to force location
 
 
-       my $baseurl = urlto($page, undef, 1);
+       my $baseurl = urlto($page);
 
        my $from;
        if (defined $form->field('from')) {
 
        my $from;
        if (defined $form->field('from')) {
@@ -156,13 +156,13 @@ sub cgi_editpage ($$) {
        my $previewing=0;
        if ($form->submitted eq "Cancel") {
                if ($form->field("do") eq "create" && defined $from) {
        my $previewing=0;
        if ($form->submitted eq "Cancel") {
                if ($form->field("do") eq "create" && defined $from) {
-                       redirect($q, urlto($from, undef));
+                       redirect($q, urlto($from));
                }
                elsif ($form->field("do") eq "create") {
                        redirect($q, baseurl(undef));
                }
                else {
                }
                elsif ($form->field("do") eq "create") {
                        redirect($q, baseurl(undef));
                }
                else {
-                       redirect($q, urlto($page, undef));
+                       redirect($q, $baseurl);
                }
                exit;
        }
                }
                exit;
        }
@@ -262,7 +262,7 @@ sub cgi_editpage ($$) {
                                        @page_locs=$page;
                                }
                                else {
                                        @page_locs=$page;
                                }
                                else {
-                                       redirect($q, urlto($page, undef));
+                                       redirect($q, $baseurl);
                                        exit;
                                }
                        }
                                        exit;
                                }
                        }
@@ -291,7 +291,7 @@ sub cgi_editpage ($$) {
                                value => $best_loc);
                        $form->field(name => "type", type => 'select',
                                options => \@page_types);
                                value => $best_loc);
                        $form->field(name => "type", type => 'select',
                                options => \@page_types);
-                       $form->title(sprintf(gettext("creating %s"), pagetitle($page)));
+                       $form->title(sprintf(gettext("creating %s"), pagetitle(basename($page))));
                        
                }
                elsif ($form->field("do") eq "edit") {
                        
                }
                elsif ($form->field("do") eq "edit") {
@@ -309,11 +309,10 @@ sub cgi_editpage ($$) {
                        $form->tmpl_param("page_select", 0);
                        $form->field(name => "page", type => 'hidden');
                        $form->field(name => "type", type => 'hidden');
                        $form->tmpl_param("page_select", 0);
                        $form->field(name => "page", type => 'hidden');
                        $form->field(name => "type", type => 'hidden');
-                       $form->title(sprintf(gettext("editing %s"), pagetitle($page)));
+                       $form->title(sprintf(gettext("editing %s"), pagetitle(basename($page))));
                }
                
                }
                
-               showform($form, \@buttons, $session, $q,
-                       forcebaseurl => $baseurl, page => $page);
+               showform($form, \@buttons, $session, $q, page => $page);
        }
        else {
                # save page
        }
        else {
                # save page
@@ -331,7 +330,7 @@ sub cgi_editpage ($$) {
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
-                               forcebaseurl => $baseurl, page => $page);
+                               page => $page);
                        exit;
                }
                elsif ($form->field("do") eq "create" && $exists) {
                        exit;
                }
                elsif ($form->field("do") eq "create" && $exists) {
@@ -346,7 +345,7 @@ sub cgi_editpage ($$) {
                                         "\n\n\n".$form->field("editcontent"),
                                force => 1);
                        showform($form, \@buttons, $session, $q,
                                         "\n\n\n".$form->field("editcontent"),
                                force => 1);
                        showform($form, \@buttons, $session, $q,
-                               forcebaseurl => $baseurl, page => $page);
+                               page => $page);
                        exit;
                }
                        
                        exit;
                }
                        
@@ -387,7 +386,7 @@ sub cgi_editpage ($$) {
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
-                               forcebaseurl => $baseurl, page => $page);
+                               page => $page);
                        exit;
                }
                
                        exit;
                }
                
@@ -429,12 +428,12 @@ sub cgi_editpage ($$) {
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
-                               forcebaseurl => $baseurl, page => $page);
+                               page => $page);
                }
                else {
                        # The trailing question mark tries to avoid broken
                        # caches and get the most recent version of the page.
                }
                else {
                        # The trailing question mark tries to avoid broken
                        # caches and get the most recent version of the page.
-                       redirect($q, urlto($page, undef)."?updated");
+                       redirect($q, $baseurl."?updated");
                }
        }
 
                }
        }