Changeset 2498
- Timestamp:
- 02/14/09 15:36:06 (4 years ago)
- Location:
- trunk/core/lib/Foswiki
- Files:
-
- 3 edited
-
Meta.pm (modified) (6 diffs)
-
Templates.pm (modified) (6 diffs)
-
UI/Preview.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/lib/Foswiki/Meta.pm
r1779 r2498 78 78 sub new { 79 79 my ( $class, $session, $web, $topic, $text ) = @_; 80 80 81 # $text - optional raw text to convert to meta-data form 81 82 my $this = bless( { _session => $session }, $class ); … … 140 141 141 142 sub web { 142 my ( $this, $web) = @_;143 my ( $this, $web ) = @_; 143 144 $this->{_web} = $web if defined $web; 144 145 return $_[0]->{_web}; … … 155 156 156 157 sub topic { 157 my ( $this, $topic) = @_;158 my ( $this, $topic ) = @_; 158 159 $this->{_topic} = $topic if defined $topic; 159 160 return $this->{_topic}; … … 635 636 =begin TML 636 637 637 ---++ ObjectMethod renderFormForDisplay( ) -> $html638 ---++ ObjectMethod renderFormForDisplay( $templates ) -> $html 638 639 639 640 Render the form contained in the meta for display. … … 642 643 643 644 sub renderFormForDisplay { 644 my $this = shift; 645 my ( $this, $templates ) = @_; 646 647 # NOTE: param $templates is not used 645 648 646 649 my $fname = $this->getFormName(); … … 695 698 if ($fname) { 696 699 require Foswiki::Form; 697 my $form = new Foswiki::Form( $this->{_session}, $this->{_web}, $fname ); 700 my $form = 701 new Foswiki::Form( $this->{_session}, $this->{_web}, $fname ); 698 702 if ($form) { 699 703 my $field = $form->getField($name); -
trunk/core/lib/Foswiki/Templates.pm
r1794 r2498 109 109 $tmpls->expandTemplate('"blah"); 110 110 $tmpls->expandTemplate('context="view" then="sigh" else="humph"'); 111 </verbatim> 111 112 112 113 =cut … … 247 248 } 248 249 $key = $1; 250 249 251 # SMELL: unchecked implicit untaint? 250 252 $val = $2; … … 257 259 $key = ''; 258 260 $val = ''; 261 259 262 # SMELL: unchecked implicit untaint? 260 263 $result .= $1; … … 303 306 my $userdirname = $name; 304 307 if ( $name =~ /^(.+)\.(.+?)$/ ) { 308 305 309 # ucfirst taints if use locale is in force 306 $userdirweb = Foswiki::Sandbox::untaintUnchecked( ucfirst($1));307 $userdirname = Foswiki::Sandbox::untaintUnchecked( ucfirst($2));310 $userdirweb = Foswiki::Sandbox::untaintUnchecked( ucfirst($1) ); 311 $userdirname = Foswiki::Sandbox::untaintUnchecked( ucfirst($2) ); 308 312 309 313 # if the name can be parsed into $web.$name, then this is an attempt … … 320 324 } 321 325 else { 326 322 327 # ucfirst taints if use locale is in force 323 $userdirweb = Foswiki::Sandbox::untaintUnchecked(ucfirst($userdirweb)); 324 $userdirname = Foswiki::Sandbox::untaintUnchecked(ucfirst($userdirname)); 328 $userdirweb = 329 Foswiki::Sandbox::untaintUnchecked( ucfirst($userdirweb) ); 330 $userdirname = 331 Foswiki::Sandbox::untaintUnchecked( ucfirst($userdirname) ); 325 332 } 326 333 … … 329 336 330 337 my @templatePath = split( /\s*,\s*/, $Foswiki::cfg{TemplatePath} ); 331 if (($Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{Enabled}) 332 && (lc($name) eq 'foswiki') 333 && defined($Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TemplatePath}) 334 ) { 338 if ( 339 ( $Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{Enabled} ) 340 && ( lc($name) eq 'foswiki' ) 341 && defined( 342 $Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TemplatePath} 343 ) 344 ) 345 { 346 335 347 #TWikiCompatibility, need to test to see if there is a twiki.skin tmpl 336 @templatePath = @{$Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TemplatePath}}; 348 @templatePath = 349 @{ $Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TemplatePath} }; 337 350 } 338 351 -
trunk/core/lib/Foswiki/UI/Preview.pm
r1779 r2498 25 25 # Note: param(formtemplate) has already been decoded by buildNewTopic 26 26 # so the $meta entry reflects if it was used. 27 # get form fields to pass on 27 28 my $formFields = ''; 28 29 my $form = $meta->get('FORM') || ''; 30 my $formName; 29 31 if ($form) { 30 $form = $form->{name}; # used later on as well32 $formName = $form->{name}; # used later on as well 31 33 require Foswiki::Form; 32 my $formDef = new Foswiki::Form( $session, $web, $form );34 my $formDef = new Foswiki::Form( $session, $web, $formName ); 33 35 unless ($formDef) { 34 36 throw Foswiki::OopsException( … … 37 39 web => $session->{webName}, 38 40 topic => $session->{topicName}, 39 params => [ $web, $form ]41 params => [ $web, $formName ] 40 42 ); 41 43 } … … 45 47 $session->{plugins}->dispatch( 'afterEditHandler', $text, $topic, $web ); 46 48 47 my $skin = $session->getSkin(); 48 my $template = 49 $session->{prefs}->getPreferencesValue('VIEW_TEMPLATE') 49 my $skin = $session->getSkin(); 50 my $template = $session->{prefs}->getPreferencesValue('VIEW_TEMPLATE') 50 51 || 'preview'; 51 52 my $tmpl = $session->templates->readTemplate( $template, $skin ); … … 56 57 $tmpl = $session->templates->readTemplate( 'preview', $skin ); 57 58 } 59 60 my $content = ''; 61 if ( $template eq 'preview' ) { 62 $content = $text; 63 } 64 else { 65 66 # only get the contents of TMPL:DEF{"content"} 67 $content = $session->templates->expandTemplate('content'); 68 69 # put the text we have inside this template's content 70 $content =~ s/%TEXT%/$text/go; 71 72 # now we are ready to put the expanded and styled topic content in the 73 # 'normal' preview template 74 } 75 76 $tmpl = $session->templates->readTemplate( 'preview', $skin ); 58 77 59 78 if ( $saveOpts->{minor} ) { … … 75 94 $tmpl =~ s/%REDIRECTTO%/$redirectTo/go; 76 95 77 $tmpl =~ s/%FORMTEMPLATE%/$form /g;96 $tmpl =~ s/%FORMTEMPLATE%/$formName/g if $formName; 78 97 79 98 my $parent = $meta->get('TOPICPARENT'); … … 84 103 $session->enterContext( 'can_render_meta', $meta ); 85 104 86 my $dispText = $text; 87 $dispText = $session->handleCommonTags( $dispText, $web, $topic, $meta ); 88 $dispText = 89 $session->renderer->getRenderedVersion( $dispText, $web, $topic ); 105 my $displayText = $content; 106 $displayText = 107 $session->handleCommonTags( $displayText, $web, $topic, $meta ); 108 $displayText = 109 $session->renderer->getRenderedVersion( $displayText, $web, $topic ); 90 110 91 111 # Disable links and inputs in the text 92 $disp Text =~112 $displayText =~ 93 113 s#<a\s[^>]*>(.*?)</a>#<span class="foswikiEmulatedLink">$1</span>#gis; 94 $dispText =~ s/<(input|button|textarea) /<$1 disabled="disabled" /gis; 95 $dispText =~ s(</?form(|\s.*?)>)()gis; 96 $dispText =~ s/(<[^>]*\bon[A-Za-z]+=)('[^']*'|"[^"]*")/$1''/gis; 114 $displayText =~ s/<(input|button|textarea) /<$1 disabled="disabled" /gis; 115 $displayText =~ s(</?form(|\s.*?)>)()gis; 116 $displayText =~ s/(<[^>]*\bon[A-Za-z]+=)('[^']*'|"[^"]*")/$1''/gis; 117 118 # let templates know the context so they can act on it 119 $session->enterContext( 'preview', 1 ); 120 121 # note: preventing linkage in rendered form can only happen in templates 122 # see formtables.tmpl 97 123 98 124 $tmpl = $session->handleCommonTags( $tmpl, $web, $topic, $meta ); 99 125 $tmpl = $session->renderer->getRenderedVersion( $tmpl, $web, $topic ); 100 $tmpl =~ s/%TEXT%/$dispText/go; 126 $tmpl =~ s/%TEXT%/$displayText/go; 127 128 # write the hidden form fields 101 129 $tmpl =~ s/%FORMFIELDS%/$formFields/go; 102 130 … … 108 136 $tmpl =~ s/<\/?(nop|noautolink)\/?>//gis; 109 137 110 #I don't know _where_ these should be done, so I'll do them as late as possible 138 # I don't know _where_ these should be done, 139 # so I'll do them as late as possible 111 140 my $originalrev = $query->param('originalrev'); # rev edit started on 112 141 #ASSERT($originalrev ne '%ORIGINALREV%') if DEBUG;
Note: See TracChangeset
for help on using the changeset viewer.
