- my $file=$page.$config{default_pageext};
- if (exists $pagesources{lc($page)}) {
- $file=$pagesources{lc($page)};
+ 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});
+ }
+ $type=$config{default_pageext} unless defined $type;
+ $file=$page.".".$type;