- my $file=$page.$config{default_pageext};
- my $newfile=1;
- if (exists $pagesources{lc($page)}) {
- $file=$pagesources{lc($page)};
- $newfile=0;
+ my $from;
+ if (defined $form->field('from')) {
+ ($from)=$form->field('from')=~/$config{wiki_file_regexp}/;
+ }
+
+ my $file;
+ my $type;
+ if (exists $pagesources{$page}) {
+ $file=$pagesources{$page};
+ $type=pagetype($file);
+ }
+ else {
+ $type=$form->param('type');
+ if (defined $type && length $type && $hooks{htmlize}{$type}) {
+ $type=possibly_foolish_untaint($type);
+ }
+ elsif (defined $from) {
+ # favor the type of linking page
+ $type=pagetype($pagesources{$from});
+ }
+ else {
+ $type=$config{default_pageext};
+ }
+ $file=$page.".".$type;
+ }
+
+ my $newfile=0;
+ if (! -e "$config{srcdir}/$file") {
+ $newfile=1;