Changeset 3219 for trunk

Show
Ignore:
Timestamp:
12/03/08 07:58:25 (12 months ago)
Author:
fumiakiy
Message:

Merging the latest of fireball branch to trunk. svn merge -r3095:3215 http://code.sixapart.com/svn/movabletype/branches/fireball . (two conflicts resolved; MT.pm, mt.php and mt-check.cgi merged manually.)

Location:
trunk
Files:
70 modified

Legend:

Unmodified
Added
Removed
  • trunk/default_templates/about_this_page.mtml

    r2706 r3219  
    4646<mt:If name="author_archive"> 
    4747    <mt:If name="datebased_archive"> 
    48         <p class="first"><__trans phrase="This page is an archive of recent entries written by <strong>[_1]</strong> in <strong>[_2]</strong>." params="<$mt:AuthorDisplayName$>%%<$mt:ArchiveDate format="%B %Y"$>"></p> 
     48        <p class="first"><__trans phrase="This page is an archive of recent entries written by <strong>[_1]</strong> in <strong>[_2]</strong>." params="<$mt:AuthorDisplayName encode_html="1"$>%%<$mt:ArchiveDate format="%B %Y"$>"></p> 
    4949        <mt:ArchivePrevious> 
    5050        <p><__trans phrase="<a href="[_1]">[_2]</a> is the previous archive." params="<$mt:ArchiveLink$>%%<$mt:ArchiveTitle$>"></p> 
     
    5454        </mt:ArchiveNext> 
    5555    <mt:Else> 
    56         <p class="first"><__trans phrase="This page is an archive of recent entries written by <strong>[_1]</strong>." params="<$mt:AuthorDisplayName$>"></p> 
     56        <p class="first"><__trans phrase="This page is an archive of recent entries written by <strong>[_1]</strong>." params="<$mt:AuthorDisplayName encode_html="1"$>"></p> 
    5757    </mt:If> 
    5858</mt:If> 
  • trunk/default_templates/commenter_confirm.mtml

    r2604 r3219  
    1212 
    1313<__trans phrase="Sincerely,"> 
    14 <mt:If tag="AuthorDisplayName"><$mt:AuthorDisplayName$><mt:Else>Movable Type</mt:If> 
     14<mt:If tag="AuthorDisplayName"><$mt:AuthorDisplayName encode_html="1"$><mt:Else>Movable Type</mt:If> 
    1515 
    1616<$mt:Include module="<__trans phrase="Mail Footer">"$> 
  • trunk/default_templates/current_author_monthly_archive_list.mtml

    r2648 r3219  
    33        <mt:ArchiveListHeader> 
    44<div class="widget-archive-current-author-monthly widget-archive widget"> 
    5     <h3 class="widget-header"><__trans phrase="[_1]: Monthly Archives" params="<$mt:AuthorDisplayName$>"></h3> 
     5    <h3 class="widget-header"><__trans phrase="[_1]: Monthly Archives" params="<$mt:AuthorDisplayName encode_html="1"$>"></h3> 
    66    <div class="widget-content"> 
    77        <ul> 
  • trunk/lib/MT.pm

    r3085 r3219  
    3030    $plugins_installed = 0; 
    3131 
    32     ( $VERSION, $SCHEMA_VERSION ) = ( '4.21', '4.0068' ); 
     32    ( $VERSION, $SCHEMA_VERSION ) = ( '4.23', '4.0068' ); 
    3333    ( $PRODUCT_NAME, $PRODUCT_CODE, $PRODUCT_VERSION, $VERSION_ID, $PORTAL_URL ) = ( 
    3434        '__PRODUCT_NAME__', 'MT', 
    35         '4.21', '4.21', 
     35        '4.23', '4.23', 
    3636        '__PORTAL_URL__' 
    3737    ); 
     
    21592159                my $label = $c->label || $pack->{label}; 
    21602160                $label = $label->() if ref($label) eq 'CODE'; 
     2161                # if the component did not declare a label, 
     2162                # it isn't wanting to be visible on the app footer. 
     2163                next if $label eq $c->{plugin_sig}; 
    21612164                push @packs_installed, { 
    21622165                    label => $label, 
     
    28732876=back 
    28742877 
    2875 =head2 $mt->init 
     2878=head2 $mt->init(%params) 
    28762879 
    28772880Initializes the Movable Type instance, including registration of basic 
     
    28792882and C<init_plugins> methods. 
    28802883 
     2884=head2 $mt->init_core() 
     2885 
     2886A method that the base MT class uses to initialize all the 'core' 
     2887functionality of Movable Type. If you want to subclass MT and extensively 
     2888modify it's core behavior, this method can be overridden to do that. 
     2889The L<MT::Core> module is a L<MT::Component> that defines the core 
     2890features of MT, and this method loads that component. Non-core components 
     2891are loaded by the L<init_addons> method. 
     2892 
     2893=head2 $mt->init_paths() 
     2894 
     2895Establishes some key file paths for the MT environment. Assigns 
     2896C<$MT_DIR>, C<$APP_DIR> and C<$CFG_FILE> package variables. 
     2897 
     2898=head2 $mt->init_permissions() 
     2899 
     2900Loads the L<MT::Permission> class and runs the 
     2901MT::Permission->init_permissions method to establish system permissions. 
     2902 
     2903=head2 $mt->init_schema() 
     2904 
     2905Completes the initialization of the Movable Type schema following the 
     2906loading of plugins. After this method runs, any MT object class may 
     2907safely be used. 
     2908 
    28812909=head2 MT->instance 
    28822910 
     
    28852913MT->new() is now an alias to instance_of. 
    28862914 
     2915=head2 MT->app 
     2916 
     2917An alias for the 'instance' method. 
     2918 
    28872919=head2 $class->instance_of 
    28882920 
     
    28972929Assigns the active MT instance object. This value is returned when 
    28982930C<MT-E<gt>instance> is invoked. 
     2931 
     2932=head2 MT->run_app( $pkg, $params ) 
     2933 
     2934Instantiates and runs a MT application (identified by C<$pkg>), passing 
     2935the C<$params> hashref as the parameters to the constructor method. This 
     2936method is a self-contained version found in L<MT::Bootstrap> and will 
     2937eventually be the manner in which MT applications are run (eliminating 
     2938the need for the bootstrap module). The MT::import module calls this 
     2939method when the MT module is used with an 'App' parameter. So, you can 
     2940write a mt.cgi script that looks like this: 
     2941 
     2942    #!/usr/bin/perl 
     2943    use strict; 
     2944    use lib $ENV{MT_HOME} ? "$ENV{MT_HOME}/lib" : 'lib'; 
     2945    use MT App => 'MT::App::CMS'; 
    28992946 
    29002947=head2 $mt->find_config($params) 
     
    29072954=head2 $mt->init_config($params) 
    29082955 
    2909 Reads the MT configuration settingss from the MT configuration file 
    2910 and settings from database (L<MT::Config>). 
     2956Reads the MT configuration settingss from the MT configuration file. 
    29112957 
    29122958The C<$params> parameter is a reference to the hash of settings passed to 
    29132959the MT constructor. 
    29142960 
    2915 =head2 $mt->init_plugins 
     2961=head2 $mt->init_config_from_db($param) 
     2962 
     2963Reads any MT configuration settings from the MT database (L<MT::Config>). 
     2964 
     2965The C<$params> parameter is a reference to the hash of settings passed to 
     2966the MT constructor. 
     2967 
     2968=head2 $mt->init_addons(%param) 
     2969 
     2970Loads any discoverable addons that are available. This is called from 
     2971the C<init> method, after C<init_config> method has loaded the 
     2972configuration settings, but prior to making a database connection. 
     2973 
     2974=head2 $mt->init_plugins(%param) 
    29162975 
    29172976Loads any discoverable plugins that are available. This is called from 
     
    29192978configuration settings. 
    29202979 
    2921 =head2 $mt->init_tasks 
     2980=head2 $mt->init_callbacks() 
     2981 
     2982Installs any MT callbacks. This is called from the C<init> method very, 
     2983early; prior to loading any addons or plugins. 
     2984 
     2985=head2 $mt->init_tasks() 
    29222986 
    29232987Registers the standard set of periodic tasks that Movable Type provides 
     
    29292993through L<MT::TaskMgr> to run any registered tasks that are pending 
    29302994execution. See L<MT::TaskMgr> for further documentation. 
     2995 
     2996=head2 MT->find_addons( $type ) 
     2997 
     2998Returns an array of all 'addons' that are found within the MT 'addons' 
     2999directory of the given C<$type>. What is returned is an array reference 
     3000of hash data. Each hash will contain these elements: 'label' (the name 
     3001of the addon), 'id' (the unique identifier of the addon), 'envelope' 
     3002(the subpath of the addon, relative to the MT home directory), and 'path' 
     3003(the full path to the addon subdirectory). 
    29313004 
    29323005=head2 MT->unplug 
     
    32423315C<callback_error> routine. 
    32433316 
     3317=head2 MT->handler_to_coderef($handler[, $delayed]) 
     3318 
     3319Translates a registry handler signature into a Perl coderef. Handlers 
     3320are in one of the following forms: 
     3321 
     3322    $<COMPONENTID>::<PERL_PACKAGE>::<SUBROUTINE> 
     3323 
     3324    <PERL_PACKAGE>::<SUBROUTINE> 
     3325 
     3326    <PERL_PACKAGE>-><SUBROUTINE> 
     3327 
     3328    sub { ... } 
     3329 
     3330When invoked with a '-E<gt>' operator, the subroutine is invoked as 
     3331a package method. 
     3332 
     3333When the handler is a string that starts with 'sub {', it is eval'd 
     3334to compile it, and the resulting coderef is returned. 
     3335 
     3336The coderef that is returned can be passed any parameters you wish. 
     3337 
     3338When the coderef is invoked, any component that was identified in 
     3339the handler signature becomes the active component when running the 
     3340code (this affects how strings are translated, and the search paths 
     3341for templates that are loaded). 
     3342 
     3343If the C<$delayed> parameter is given, a special coderef is constructed 
     3344that will delay the 'require' of the identified Perl package until 
     3345the coderef is actually invoked. 
     3346 
     3347=head2 MT->registry( @path ) 
     3348 
     3349Queries the Movable Type registry data structure for a given resource 
     3350path. The MT registry is a collection of hash structures that contain 
     3351resources MT and/or plugins can utilize. 
     3352 
     3353When this method is invoked, it actually issues a registry request 
     3354against each component registered with MT, then merges the resulting 
     3355hashes and returns them. See L<MT::Component> for further details. 
     3356 
     3357=head2 MT->component( $id ) 
     3358 
     3359Returns a loaded L<MT::Component> based on the requested C<$id> parameter. 
     3360For example: 
     3361 
     3362    # Returns the MT 'core' component 
     3363    MT->component('core'); 
     3364 
     3365=head2 MT->model( $id ) 
     3366 
     3367Returns a Perl package name for the MT object type identified by C<$id>. 
     3368For example: 
     3369 
     3370    # Assigns (by default) 'MT::Blog' to $blog_class 
     3371    my $blog_class = MT->model('blog'); 
     3372 
     3373It is a recommended practice to utilize the model method to derive the 
     3374implementation package name, instead of hardcoding Perl package names. 
     3375 
     3376=head2 MT->models( $id ) 
     3377 
     3378Returns a list of object types that are registered as sub-types. For 
     3379instance, the MT 'asset' object type has several sub-types associated 
     3380with it: 
     3381 
     3382    my @types = MT->models('asset'); 
     3383    # @types now contains ('asset', 'asset.image', 'asset.video', etc.) 
     3384 
    32443385=head2 MT->product_code 
    32453386 
     
    32583399and C<version_number> methods as they report the API version information. 
    32593400 
     3401=head2 MT->VERSION 
     3402 
     3403Returns the API version of MT. When using the MT module with the version 
     3404requirement, this method will also load the suitable API 'compatibility' 
     3405module, if available. For instance, if your plugin declares: 
     3406 
     3407    use MT 4; 
     3408 
     3409Then, once MT 5 is available, that statement will cause the C<VERSION> method 
     3410to attempt to load a module named "MT::Compat::v4". This module would contain 
     3411compatibility support for MT 4-based plugins. 
     3412 
    32603413=head2 MT->version_id 
    32613414 
     
    32723425Returns the version of the MT database schema. 
    32733426 
     3427=head2 $mt->id 
     3428 
     3429Provides an identifier for the application, one that relates to the 
     3430'application' paths of the MT registry. This method may be overridden 
     3431for any subclass of MT to provide the appropriate identifier. By 
     3432default, the base 'id' method will return an id taken from the 
     3433Perl package name, by stripping off any 'MT::App::' prefix, and lowercasing 
     3434the remaining string. 
     3435 
    32743436=head2 MT->version_slug 
    32753437 
     
    32963458An alias to L<MT::WeblogPublisher::rebuild_indexes>. See 
    32973459L<MT::WeblogPublisher> for documentation of this method. 
     3460 
     3461=head2 $mt->rebuild_archives 
     3462 
     3463An alias to L<MT::WeblogPublisher::rebuild_archives>. See 
     3464L<MT::WeblogPublisher> for documentation of this method. 
     3465 
     3466=head2 $app->template_paths 
     3467 
     3468Returns an array of directory paths where application templates exist. 
     3469 
     3470=head2 $app->find_file(\@paths, $filename) 
     3471 
     3472Returns the path and filename for a file found in any of the given paths. 
     3473If the file cannot be found, it returns undef. 
     3474 
     3475=head2 $app->load_tmpl($file[, @params]) 
     3476 
     3477Loads a L<MT::Template> template using the filename specified. See the 
     3478documentation for the C<build_page> method to learn about how templates 
     3479are located. The optional C<@params> are passed to the L<MT::Template> 
     3480constructor. 
     3481 
     3482=head2 $app->set_default_tmpl_params($tmpl) 
     3483 
     3484Assigns standard parameters to the given L<MT::Template> C<$tmpl> object. 
     3485Refer to the L<STANDARD APPLICATION TEMPLATE PARAMETERS> section for a 
     3486complete list of these parameters. 
     3487 
     3488=head2 $app->charset( [$charset] ) 
     3489 
     3490Gets or sets the application's character set based on the "PublishCharset" 
     3491configuration setting or the encoding of the active language 
     3492(C<$app-E<gt>current_language>). 
     3493 
     3494=head2 $app->build_page($tmpl_name, \%param) 
     3495 
     3496Builds an application page to be sent to the client; the page name is specified 
     3497in C<$tmpl_name>, which should be the name of a template containing valid 
     3498L<MT::Template> markup. C<\%param> is a hash ref whose keys and values will 
     3499be passed to L<MT::Template::param> for use in the template. 
     3500 
     3501On success, returns a scalar containing the page to be sent to the client. On 
     3502failure, returns C<undef>, and the error message can be obtained from 
     3503C<$app-E<gt>errstr>. 
     3504 
     3505=head3 How does build_page find a template? 
     3506 
     3507The C<build_page> function looks in several places for an app 
     3508template. Two configuration directives can modify these search paths, 
     3509and application and plugin code can also affect them. 
     3510 
     3511The I<TemplatePath> config directive is an absolute path to the directory 
     3512where MT's core application templates live. It defaults to the I<mt_dir> 
     3513plus an additional path segment of 'tmpl'. 
     3514 
     3515The optional I<AltTemplatePath> config directive is a path (absolute 
     3516or relative) to a directory where some 'override templates' may 
     3517live. An override template takes the place of one of MT's core 
     3518application templates, and is used interchangeably with the core 
     3519template. This allows power users to customize the look and feel of 
     3520the MT application. If I<AltTemplatePath> is relative, its base path 
     3521is the value of the Movable Type configuration file. 
     3522 
     3523Next, any application built on the C<MT::App> foundation can define 
     3524its own I<template_dir> parameter, which identifies a subdirectory of 
     3525TemplatePath (or AltTemplatePath) where that application's templates 
     3526can be found. I<template_dir> defaults to C<cms>. Most templates will 
     3527be found in this directory, but sometimes the template search will 
     3528fall through to the parent directory, where a default error template 
     3529is found, for example. I<template_dir> should rightly have been named 
     3530I<application_template_dir>, since it is application-specific. 
     3531 
     3532Finally, a plugin can specify its I<plugin_template_path>, which 
     3533locates a directory where the templates for that plugin's own 
     3534interface are found. If the I<plugin_template_path> is relative, it 
     3535may be relative to either the I<app_dir>, or the I<mt_dir>; the former 
     3536takes precedence if it exists. (for a definition of I<app_dir> and 
     3537I<mt_dir>, see L<MT>) 
     3538 
     3539Given these values, the order of search is as follows: 
     3540 
     3541=over 4 
     3542 
     3543=item * I<plugin_template_path> 
     3544 
     3545=item * I<AltTemplatePath> 
     3546 
     3547=item * I<AltTemplatePath>F</>I<template_dir> 
     3548 
     3549=item * I<TemplatePath>/I<template_dir> 
     3550 
     3551=item * I<TemplatePath> 
     3552 
     3553=back 
     3554 
     3555If a template with the given name is not found in any of these 
     3556locations, an ugly error is thrown to the user. 
     3557 
     3558=head2 $app->build_page_in_mem($tmpl, \%param) 
     3559 
     3560Used internally by the L<build_page> method to render the output 
     3561of a L<MT::Template> object (the first parameter) using the parameter 
     3562data (the second parameter). It additionally calls the L<process_mt_template> 
     3563method (to process any E<lt>MT_ACTIONE<gt> and E<lt>MT_X:YE<gt> marker tags) 
     3564and then L<translate_templatized> (to process any E<lt>MT_TRANSE<gt> tags). 
     3565 
     3566=head2 $app->process_mt_template($str) 
     3567 
     3568Processes the E<lt>__action<gt> tags that are present in C<$str>. These tags 
     3569are in the following format: 
     3570 
     3571    <__action mode="mode_name" parameter="value"> 
     3572 
     3573The mode parameter is required (and must be the first attribute). The 
     3574following attributes are appended as regular query parameters. 
     3575 
     3576The MT_ACTION tag is a preferred way to specify application links rather 
     3577than using this syntax: 
     3578 
     3579    <mt:var name="script_url">?__mode=mode_name&parameter=value 
     3580 
     3581C<process_mt_templates> also strips the C<$str> variable of any tags in 
     3582the format of C<E<lt>MT_\w+:\w+E<gt>>. These are 'marker' tags that are 
     3583used to identify specific portions of the template page and used in 
     3584conjunction with the transformer callback helper methods C<tmpl_prepend>, 
     3585C<tmpl_append>, C<tmpl_replace>, C<tmpl_select>. 
    32983586 
    32993587=head2 $mt->build_email($file, $param) 
     
    33103598entry that is scheduled for publishing. The return value is the timestamp 
    33113599in UTC time in the format "YYYY-MM-DDTHH:MM:SSZ". 
     3600 
     3601=head2 $mt->commenter_authenticator($id) 
     3602 
     3603Returns a specific comment authenication option using the identifier 
     3604C<$id> parameter. 
     3605 
     3606=head2 $mt->commenter_authenticators() 
     3607 
     3608Returns the available comment authentication identifiers that are 
     3609installed in the MT registry. 
     3610 
     3611=head2 $mt->core_commenter_authenticators() 
     3612 
     3613A method that returns the MT-supplied comment authentication registry 
     3614data. 
     3615 
     3616=head2 $mt->init_commenter_authenticators() 
     3617 
     3618Initializes the list of installed MT comment authentication options, 
     3619drawing from the MT registry. 
     3620 
     3621=head2 $mt->captcha_provider($id) 
     3622 
     3623Returns a specific CAPTCHA provider configuration using the identifier 
     3624C<$id> parameter. This is a convenience method that accesses the CAPTCHA 
     3625providers installed into the MT registry. 
     3626 
     3627=head2 $mt->captcha_providers() 
     3628 
     3629Returns the available CAPTCHA providers. This is a convenience method 
     3630that accesses the MT registry for available CAPTCHA providers (it also 
     3631invokes the 'condition' key for each provider to filter the list). 
     3632 
     3633=head2 $mt->core_captcha_providers() 
     3634 
     3635A method that returns the MT-supplied CAPTCHA provider registry data. 
     3636 
     3637=head2 $mt->init_captcha_providers() 
     3638 
     3639Initializes the list of installed CAPTCHA providers, drawing from 
     3640the MT registry. 
     3641 
     3642=head2 $mt->effective_captcha_provider() 
     3643 
     3644Returns the Perl package name for the configured CAPTCHA provider. 
     3645 
     3646=head2 $app->static_path() 
     3647 
     3648Returns the application's static web path. 
     3649 
     3650=head2 $app->static_file_path() 
     3651 
     3652Returns the application's static file path. 
     3653 
     3654=head2 MT::core_upload_file_to_sync 
     3655 
     3656A MT callback handler routine that forwards to the L<upload_file_to_sync> 
     3657method. 
     3658 
     3659=head2 MT->upload_file_to_sync(%param) 
     3660 
     3661A routine that will make record of a file that is to be transmitted 
     3662to one or more servers (typically via rsync). This method runs when 
     3663the C<SyncTarget> MT configuration setting is configured. Normally 
     3664published files are automatically processed for syncing operations, 
     3665but this routine is used for files that are created through other 
     3666means, such as uploading an asset. 
     3667 
     3668=head2 MT->help_url( [ $suffix ] ) 
     3669 
     3670Returns a help URL for the application. This method is used to construct 
     3671the URL directing users to online documentation. If called without any 
     3672parameters, it returns the base URL for providing help. If a parameter is 
     3673given, the URL is appended with the given subpath. The base URL by default 
     3674is 'http://www.movabletype.org/documentation/'. This string is passed 
     3675through MT's localization modules, so it can be changed on a per-language 
     3676basis. The C<$suffix> parameter, however, is always appended to this base URL. 
     3677 
     3678=head2 MT->get_timer 
     3679 
     3680Returns an instance of L<MT::Util::ReqTimer> for use in timing MT's 
     3681operations. 
     3682 
     3683=head2 MT->log_times 
     3684 
     3685Used as part of Movable Type's performance logging framework. This method 
     3686is called internally, once at the startup of Movable Type, and once as it 
     3687is shutting down. 
     3688 
     3689=head2 MT->time_this($string, $code) 
     3690 
     3691Utility method to time a particular routine. This will log the execution 
     3692time of the C<$code> coderef with the identifying phrase C<$string> using 
     3693MT's performance logging framework. 
     3694 
     3695=head2 MT::refresh_cache($cb) 
     3696 
     3697A callback handler that invalidates the cache of MT's caching driver. 
     3698See L<MT::Cache::Negotiate>. 
     3699 
     3700=head2 MT->register_refresh_cache_event($callback) 
     3701 
     3702Registers a callback that will cause the MT cache to invalidate itself. 
     3703See L<MT::Cache::Negotiate>. 
    33123704 
    33133705=head1 ERROR HANDLING 
  • trunk/lib/MT/App.pm

    r3082 r3219  
    19741974 
    19751975        $url = $q->param('url'); 
    1976         if ( $url && !is_url($url) ) { 
     1976        if ( $url && (!is_url($url) || ($url =~ m/[<>]/)) ) { 
    19771977            return $app->error( $app->translate("URL is invalid.") ); 
    19781978        } 
     
    19871987        return $app->error( $app->translate("User requires username.") ); 
    19881988    } 
     1989    if ( $name =~ m/([<>])/) { 
     1990        return $app->error( $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Username"), encode_html( $1 ) ) ); 
     1991    } 
    19891992 
    19901993    my $existing = MT::Author->exist( { name => $name } ); 
     
    19961999    unless ($nickname) { 
    19972000        return $app->error( $app->translate("User requires display name.") ); 
     2001    } 
     2002    if ( $nickname =~ m/([<>])/) { 
     2003        return $app->error( $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Display Name"), encode_html( $1 ) ) ); 
    19982004    } 
    19992005 
     
    20042010            return $app->error( 
    20052011                $app->translate("Email Address is invalid.") ); 
     2012        } 
     2013 
     2014        if ( $email =~ m/([<>])/) { 
     2015            return $app->error( $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Email Address"), encode_html( $1 ) ) ); 
    20062016        } 
    20072017    } 
     
    23992409    my $url     = $app->uri; 
    24002410    my $blog_id = $app->param('blog_id'); 
     2411 
    24012412    if ( ref $param ne 'HASH' ) { 
    2402  
    24032413        # old scalar signature 
    24042414        $param = { error => $param }; 
    24052415    } 
    24062416 
    2407     if ( $MT::DebugMode && $@ ) { 
    2408         $param->{error} = '<pre>' . encode_html( $param->{error} ) . '</pre>'; 
     2417    my $error = $param->{error}; 
     2418 
     2419    if ( $MT::DebugMode ) { 
     2420        if ( $@ ) { 
     2421            # Use 'pre' tag to wrap Perl error 
     2422            $error = '<pre>' . encode_html( $error ) . '</pre>'; 
     2423        } 
    24092424    } 
    24102425    else { 
    2411         $param->{error} = encode_html( $param->{error} ); 
    2412         $param->{error} 
     2426        if ($error =~ m/^(.+?)( at .+? line \d+)(.*)$/s) { 
     2427            # Hide any module path info from perl error message 
     2428            # Information could be revealing info about where MT app 
     2429            # resides on server, and what version is being used, which 
     2430            # may be helpful forensics to an attacker. 
     2431            $error = $1; 
     2432        } 
     2433        $error = encode_html( $error ); 
     2434        $error 
    24132435            =~ s!(https?://\S+)!<a href="$1" target="_blank">$1</a>!g; 
    24142436    } 
    2415     $tmpl = $app->load_tmpl('error.tmpl') 
    2416         or return "Can't load error template; got error '" 
    2417         . encode_html( $app->errstr ) 
    2418         . "'. Giving up. Original error was <pre>$param->{error}</pre>"; 
     2437 
     2438    $tmpl = $app->load_tmpl('error.tmpl'); 
     2439    if (!$tmpl) { 
     2440        $error = '<pre>' . $error . '</pre>' unless $error =~ m/<pre>/; 
     2441        return "Can't load error template; got error '" 
     2442            . encode_html( $app->errstr ) 
     2443            . "'. Giving up. Original error was: $error"; 
     2444    } 
    24192445    my $type = $app->param('__type') || ''; 
    24202446    if ( $type eq 'dialog' ) { 
     
    24282454        $param->{value}  ||= $app->{value}  || $app->translate("Go Back"); 
    24292455    } 
     2456    local $param->{error} = $error; 
    24302457    $tmpl->param($param); 
    24312458    my $out = $tmpl->output; 
    24322459    if ( !defined $out ) { 
     2460        $error = '<pre>' . $error . '</pre>' unless $error =~ m/<pre>/; 
    24332461        return 
    24342462              "Can't build error template; got error '" 
    24352463            . encode_html( $tmpl->errstr ) 
    2436             . "'. Giving up. Original error was <pre>$param->{error}</pre>"; 
     2464            . "'. Giving up. Original error was: $error"; 
    24372465    } 
    24382466    return $app->l10n_filter($out); 
  • trunk/lib/MT/App/ActivityFeeds.pm

    r2986 r3219  
    1111use MT::Author qw(AUTHOR); 
    1212use MT::Util qw(perl_sha1_digest_hex ts2epoch epoch2ts ts2iso iso2ts 
    13     encode_html); 
     13    encode_html encode_url); 
    1414use HTTP::Date qw(time2isoz str2time time2str); 
    1515 
     
    260260    my $str = qq(); 
    261261    for my $key ( $app->param ) { 
    262         $str .= "&amp;$key=" . $app->param($key); 
     262        $str .= "&amp;" . encode_url($key) . "=" . encode_url($app->param($key)); 
    263263    } 
    264264    $str =~ s/^&amp;(.+)$/?$1/; 
  • trunk/lib/MT/App/Comments.pm

    r3098 r3219  
    17501750    my ( $sess_obj, $commenter ) = $app->get_commenter_session(); 
    17511751    if ($commenter) { 
     1752        $app->user($commenter); 
    17521753        $app->{session} = $sess_obj; 
    17531754 
     
    17761777            hint     => $commenter->hint, 
    17771778            url      => $commenter->url, 
     1779            blog_id  => $blog_id, 
    17781780            $entry_id ? ( entry_url => $url ) : ( return_url => $url ), 
    17791781        }; 
     
    17991801    my %param 
    18001802        = map { $_ => scalar( $q->param($_) ) } 
    1801         qw( name nickname email password pass_verify hint url entry_url return_url external_auth); 
     1803        qw( name nickname email password pass_verify hint url entry_url return_url external_auth blog_id ); 
     1804    $param{blog_id} =~ s/\D//g if defined $param{blog_id}; 
    18021805 
    18031806    $param{ 'auth_mode_' . $cmntr->auth_type } = 1; 
     
    18051808    $app->user($cmntr); 
    18061809    $app->{session} = $sess_obj; 
     1810 
    18071811    my $original = $cmntr->clone(); 
    18081812 
     
    18111815 
    18121816    unless ( $param{external_auth} ) { 
    1813         unless ( $param{nickname} && $param{email} && $param{hint} ) { 
     1817        my $nickname = $param{nickname}; 
     1818        unless ( $nickname && $param{email} && $param{hint} ) { 
    18141819            $param{error} = $app->translate( 
    18151820                'All required fields must have valid values.'); 
    18161821            return $app->build_page( 'profile.tmpl', \%param ); 
    18171822        } 
     1823        if ( $nickname =~ m/([<>])/) { 
     1824            $param{error} = $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Display Name"), encode_html( $1 ) ); 
     1825            return $app->build_page( 'profile.tmpl', \%param ); 
     1826        } 
    18181827        if ( $param{password} ne $param{pass_verify} ) { 
    18191828            $param{error} = $app->translate('Passwords do not match.'); 
     
    18211830        } 
    18221831    } 
    1823     if ( $param{email} && !is_valid_email( $param{email} ) ) { 
     1832    my $email = $param{email}; 
     1833    if ( $email && !is_valid_email( $email ) ) { 
    18241834        $param{error} = $app->translate('Email Address is invalid.'); 
    18251835        return $app->build_page( 'profile.tmpl', \%param ); 
    18261836    } 
    1827     if ( $param{url} && !is_url( $param{url} ) ) { 
     1837    if ( $email && $email =~ m/([<>])/) { 
     1838        $param{error} = $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Email Address"), encode_html( $1 ) ); 
     1839        return $app->build_page( 'profile.tmpl', \%param ); 
     1840    } 
     1841    if ( $param{url} && (!is_url( $param{url} ) || ($param{url} =~ m/[<>]/) ) ) { 
    18281842        $param{error} = $app->translate('URL is invalid.'); 
    18291843        return $app->build_page( 'profile.tmpl', \%param ); 
  • trunk/lib/MT/App/Search.pm

    r3082 r3219  
    8484 
    8585    my $q = $app->param; 
     86 
     87    # These parameters are strictly numeric; invalid request if they 
     88    # are given and are not 
     89    foreach my $param ( qw( blog_id limit offset SearchMaxResults ) ) { 
     90        my $val = $q->param($param); 
     91        next unless defined $val && ($val ne ''); 
     92        return $app->errtrans( 'Invalid [_1] parameter.', $param ) 
     93            if $val !~ m/^\d+$/; 
     94    } 
     95    foreach my $param ( qw( IncludeBlogs ExcludeBlogs ) ) { 
     96        my $val = $q->param($param); 
     97        next unless defined $val && ($val ne ''); 
     98        return $app->errtrans( 'Invalid [_1] parameter.', $param ) 
     99            if $val !~ m/^(\d+,?)+$/; 
     100    } 
    86101 
    87102    my $params = $app->registry( $app->mode, 'params' ); 
  • trunk/lib/MT/ArchiveType/Author.pm

    r2227 r3219  
    99use strict; 
    1010use base qw( MT::ArchiveType ); 
     11 
     12use MT::Util qw( remove_html encode_html ); 
    1113 
    1214sub name { 
     
    5052    my ($ctx) = @_; 
    5153    my $a = $ctx->stash('author'); 
    52     $a ? $a->nickname || MT->translate( '(Display Name not set)' ) : ''; 
     54    encode_html( remove_html( $a ? $a->nickname || MT->translate( '(Display Name not set)' ) : '' ) ); 
    5355} 
    5456 
  • trunk/lib/MT/ArchiveType/Category.pm

    r2737 r3219  
    99use strict; 
    1010use base qw( MT::ArchiveType ); 
     11 
     12use MT::Util qw( remove_html encode_html ); 
    1113 
    1214sub name { 
     
    5052    my ($ctx) = @_; 
    5153    my $c = $ctx->stash('category'); 
    52     $c ? $c->label : ''; 
     54    encode_html( remove_html( $c ? $c->label : '' ) ); 
    5355} 
    5456 
  • trunk/lib/MT/ArchiveType/Individual.pm

    r1741 r3219  
    99use strict; 
    1010use base qw( MT::ArchiveType ); 
     11 
     12use MT::Util qw( remove_html encode_html ); 
    1113 
    1214sub name { 
     
    5355sub archive_title { 
    5456    my $obj = shift; 
    55     $_[1]->title; 
     57    encode_html( remove_html( $_[1]->title ) ); 
    5658} 
    5759 
  • trunk/lib/MT/Bootstrap.pm

    r1833 r3219  
    9090                eval { 
    9191                    # line __LINE__ __FILE__ 
     92                    if (!$MT::DebugMode && ($err =~ m/^(.+?)( at .+? line \d+)(.*)$/s)) { 
     93                        $err = $1; 
     94                    } 
    9295                    my %param = ( error => $err ); 
    9396                    if ($err =~ m/Bad ObjectDriver/) { 
     
    130133                    } 
    131134                } 
    132                 print "Content-Type: text/plain; charset=$charset\n\n"; 
    133                 print $app ? $app->translate("Got an error: [_1]", $app->translate($err)) : "Got an error: $err\n"; 
    134135            } 
     136            if (!$MT::DebugMode && ($err =~ m/^(.+?)( at .+? line \d+)(.*)$/s)) { 
     137                $err = $1; 
     138            } 
     139            print "Content-Type: text/plain; charset=$charset\n\n"; 
     140            print $app 
     141              ? $app->translate( "Got an error: [_1]", $err ) 
     142              : "Got an error: $err"; 
    135143        } 
    136144    } 
  • trunk/lib/MT/CMS/Blog.pm

    r3098 r3219  
    10081008            or return $app->error($app->translate('Can\'t load entry #[_1].', $entry_id)); 
    10091009        $param{build_type_name} = 
    1010           $app->translate( "[_1] '[_2]'", $entry->class_label, $entry->title ); 
     1010          $app->translate( "[_1] '[_2]'", $entry->class_label, MT::Util::encode_html($entry->title) ); 
    10111011        $param{is_entry} = 1; 
    10121012        $param{entry_id} = $entry_id; 
  • trunk/lib/MT/CMS/Dashboard.pm

    r3082 r3219  
    22 
    33use strict; 
    4 use MT::Util qw( epoch2ts ); 
     4use MT::Util qw( epoch2ts encode_html ); 
    55 
    66sub dashboard { 
     
    137137        $param->{last_post_id}      = $last_post->id; 
    138138        $param->{last_post_blog_id} = $last_post->blog_id; 
    139         $param->{last_post_blog_name} = $last_post->blog->name; 
     139        $param->{last_post_blog_name} = encode_html($last_post->blog->name); 
    140140        $param->{last_post_ts}      = $last_post->authored_on; 
    141141    } 
  • trunk/lib/MT/CMS/Entry.pm

    r3098 r3219  
    189189    my $cats = $q->param('category_ids'); 
    190190    if ( defined $cats ) { 
    191         if ( my @cats = split /,/, $cats ) { 
     191        if ( my @cats = grep { $_ =~ /^\d+/ } split /,/, $cats ) { 
    192192            $cat_id = $cats[0]; 
    193193            %places = map { $_ => 1 } @cats; 
     
    19301930    my $script = qq!javascript:d=document;w=window;t='';if(d.selection)t=d.selection.createRange().text;else{if(d.getSelection)t=d.getSelection();else{if(w.getSelection)t=w.getSelection()}}void(w.open('$uri&title='+encodeURIComponent(d.title)+'&text='+encodeURIComponent(d.location.href)+encodeURIComponent('<br/><br/>')+encodeURIComponent(t),'_blank','scrollbars=yes,status=yes,resizable=yes,location=yes'))!; 
    19311931    # Translate the phrase here to avoid ActivePerl DLL bug. 
    1932     $app->translate('<a href="[_1]">QuickPost to [_2]</a> - Drag this link to your browser\'s toolbar then click it when you are on a site you want to blog about.', encode_html($script), $blog->name); 
     1932    $app->translate('<a href="[_1]">QuickPost to [_2]</a> - Drag this link to your browser\'s toolbar then click it when you are on a site you want to blog about.', encode_html($script), encode_html($blog->name)); 
    19331933} 
    19341934 
  • trunk/lib/MT/CMS/Search.pm

    r2890 r3219  
    394394    my %param = %$list_pref; 
    395395    my $limit = $q->param('limit') || 125;    # FIXME: mt.cfg setting? 
     396    $limit =~ s/\D//g; 
    396397    my $matches; 
    397398    $date_col = $api->{date_column} || 'created_on'; 
  • trunk/lib/MT/CMS/Tools.pm

    r3098 r3219  
    622622    my @tsnow    = gmtime(time); 
    623623    my $metadata = { 
    624         backup_by => $app->user->name . '(ID: ' . $app->user->id . ')', 
     624        backup_by => MT::Util::encode_xml($app->user->name, 1) . '(ID: ' . $app->user->id . ')', 
    625625        backup_on => sprintf( 
    626626            "%04d-%02d-%02dT%02d:%02d:%02d", 
  • trunk/lib/MT/CMS/User.pm

    r3039 r3219  
    15661566        return $eh->error( $app->translate("User requires username") ) 
    15671567          if ( !$name ); 
     1568 
     1569        if ( $name =~ m/([<>])/) { 
     1570            return $eh->error( $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Username"), encode_html( $1 ) ) ); 
     1571        } 
    15681572    } 
    15691573 
     
    15761580        return $eh->error( $app->translate("User requires display name") ) 
    15771581          if ( !length( $nickname ) ); 
     1582 
     1583        if ( $nickname =~ m/([<>])/) { 
     1584            return $eh->error( $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Display Name"), encode_html( $1 ) ) ); 
     1585        } 
    15781586    } 
    15791587 
     
    16141622          if ( !$app->param('hint') ); 
    16151623    } 
     1624    my $email = $app->param('email'); 
    16161625    return $eh->error( 
    16171626        MT->translate("Email Address is required for password recovery") ) 
    1618       unless $app->param('email'); 
     1627      unless $email; 
     1628    if ( $email =~ m/([<>])/) { 
     1629        return $eh->error( $app->translate("[_1] contains an invalid character: [_2]", $app->translate("Email Address"), encode_html( $1 ) ) ); 
     1630    } 
     1631 
    16191632    if ( $app->param('url') ) { 
    16201633        my $url = $app->param('url'); 
    1621         return $eh->error( MT->translate("Website URL is invalid") ) 
    1622           unless is_url($url); 
     1634        return $eh->error( MT->translate("URL is invalid.") ) 
     1635          if !is_url($url) || ($url =~ m/[<>]/); 
    16231636    } 
    16241637    1; 
  • trunk/lib/MT/DefaultTemplates.pm

    r2755 r3219  
    332332            foreach my $tmpl_id (keys %{ $tmpl_hash->{$tmpl_set} }) { 
    333333                next if $tmpl_id eq 'plugin'; 
    334  
    335334                my $p = $tmpl_hash->{plugin} || $tmpl_hash->{$tmpl_set}{plugin}; 
    336335                my $base_path = $def_tmpl->{base_path} || $tmpl_hash->{$tmpl_set}{base_path}; 
     
    359358                $tmpl->{key} = $tmpl_id; 
    360359                $tmpl->{identifier} = $tmpl_id; 
    361  
    362                 # load template if it hasn't been loaded already 
    363                 if (!exists $tmpl->{text}) { 
    364                     local (*FIN, $/); 
    365                     my $filename = $tmpl->{filename} || ($tmpl_id . '.mtml'); 
    366                     my $file = File::Spec->catfile($base_path, $filename); 
    367                     if ((-e $file) && (-r $file)) { 
    368                         open FIN, "<$file"; my $data = <FIN>; close FIN; 
    369                         $tmpl->{text} = $data; 
    370                     } else { 
    371                         $tmpl->{text} = ''; 
    372                     } 
    373                 } 
    374360 
    375361                if ( exists $tmpl->{widgets} ) { 
     
    385371                    } 
    386372                    $tmpl->{widgets} = \@widgets if @widgets; 
     373                } else { 
     374                    # load template if it hasn't been loaded already 
     375                    if (!exists $tmpl->{text}) { 
     376                        local (*FIN, $/); 
     377                        my $filename = $tmpl->{filename} || ($tmpl_id . '.mtml'); 
     378                        my $file = File::Spec->catfile($base_path, $filename); 
     379                        if ((-e $file) && (-r $file)) { 
     380                            open FIN, "<$file"; my $data = <FIN>; close FIN; 
     381                            $tmpl->{text} = $data; 
     382                        } else { 
     383                            $tmpl->{text} = ''; 
     384                        } 
     385                    } 
    387386                } 
    388387 
    389388                my $local_global_tmpls = $tmpl->{global} ? \%global_tmpls : \%tmpls; 
    390                 if (exists $local_global_tmpls->{$tmpl_id}) { 
     389                my $tmpl_key = $type . ":" . $tmpl_id; 
     390                if (exists $local_global_tmpls->{$tmpl_key}) { 
    391391                    # allow components/plugins to override core 
    392392                    # templates 
    393                     $local_global_tmpls->{$tmpl_id} = $tmpl if $p && ($p->id ne 'core'); 
     393                    $local_global_tmpls->{$tmpl_key} = $tmpl if $p && ($p->id ne 'core'); 
    394394                } 
    395395                else { 
    396                     $local_global_tmpls->{$tmpl_id} = $tmpl; 
     396                    $local_global_tmpls->{$tmpl_key} = $tmpl; 
    397397                } 
    398398            } 
  • trunk/lib/MT/ImportExport.pm

    r1174 r3219  
    1414use base qw( MT::ErrorHandler ); 
    1515use MT::I18N qw( first_n_text const encode_text ); 
     16use MT::Util qw( encode_html ); 
    1617 
    1718use vars qw( $SEP $SUB_SEP ); 
     
    136137                                    $author->password('(none)'); 
    137138                                } 
    138                                 $cb->(MT->translate("Creating new user ('[_1]')...", $val)); 
     139                                $cb->(MT->translate("Creating new user ('[_1]')...", encode_html($val))); 
    139140                                if ($author->save) { 
    140141                                    $cb->(MT->translate("ok") . "\n"); 
     
    173174                                    $cat->author_id($entry->author_id); 
    174175                                    $cat->parent(0); 
    175                                     $cb->(MT->translate("Creating new category ('[_1]')...", $val)); 
     176                                    $cb->(MT->translate("Creating new category ('[_1]')...", encode_html($val))); 
    176177                                    if ($cat->save) { 
    177178                                        $cb->(MT->translate("ok") . "\n"); 
     
    239240                            next ENTRY_BLOCK; 
    240241                        } else { 
    241                             $cb->(MT->translate("Importing into existing entry [_1] ('[_2]')", $entry->id, $entry->title) . "\n"); 
     242                            $cb->(MT->translate("Importing into existing entry [_1] ('[_2]')", $entry->id, encode_html($entry->title)) . "\n"); 
    242243                        } 
    243244                    } 
     
    371372                    ## Save entry. 
    372373                    unless ($no_save) { 
    373                         $cb->(MT->translate("Saving entry ('[_1]')...", $entry->title)); 
     374                        $cb->(MT->translate("Saving entry ('[_1]')...", encode_html($entry->title))); 
    374375                        if ($entry->save) { 
    375376                            $cb->(MT->translate("ok (ID [_1])", $entry->id) . "\n"); 
     
    427428                    for my $comment (@comments) { 
    428429                        $comment->entry_id($entry->id); 
    429                         $cb->(MT->translate("Creating new comment (from '[_1]')...", $comment->author)); 
     430                        $cb->(MT->translate("Creating new comment (from '[_1]')...", encode_html($comment->author))); 
    430431                        if ($comment->save) { 
    431432                            $cb->(MT->translate("ok (ID [_1])", $comment->id) . "\n"); 
     
    444445                        for my $ping (@pings) { 
    445446                            $ping->tb_id($tb->id); 
    446                             $cb->(MT->translate("Creating new ping ('[_1]')...", $ping->title)); 
     447                            $cb->(MT->translate("Creating new ping ('[_1]')...", encode_html($ping->title))); 
    447448                            if ($ping->save) { 
    448449                                $cb->(MT->translate("ok (ID [_1])", $ping->id) . "\n"); 
  • trunk/lib/MT/L10N/ja.pm

    r3082 r3219  
    815815        'User requires username.' => 'ナヌザヌ名は忠
    816816須です。', 
     817        '[_1] contains an invalid character: [_2]' => '[_1]に䞍正な文字( [_2] )が含たれおいたす。', 
    817818        'A user with the same name already exists.' => '同名のナヌザヌがすでに存圚したす。', 
    818819        'User requires display name.' => '衚瀺名は忠
  • trunk/lib/MT/Sanitize.pm

    r1174 r3219  
    107107                                $dec_val =~ s/&#x0*3[Aa](?:=;|[^a-fA-F0-9])/:/; 
    108108 
    109                                 if ((my $prot) = $dec_val =~ m/^(.+?):/) { 
     109                                if ((my $prot) = $dec_val =~ m/^([\s\S]+?):/) { 
    110110                                    next if $prot =~ m/[\r\n\t]/; 
    111111                                    $prot =~ s/\s+//gs; 
  • trunk/lib/MT/Template/ContextHandlers.pm

    r3094 r3219  
    17031703    my $show_actions = exists $args->{show_actions} ? $args->{show_actions} : 1; 
    17041704    my $return_args = $ctx->var('return_args') || ''; 
     1705    $return_args = encode_html( $return_args ); 
    17051706    $return_args = qq{\n        <input type="hidden" name="return_args" value="$return_args" />} if $return_args; 
    17061707    my $blog_id = $ctx->var('blog_id') || ''; 
     
    19871988    my $header_class = $tabbed ? 'widget-header-tabs' : ''; 
    19881989    my $return_args = $app->make_return_args; 
     1990    $return_args = encode_html( $return_args ); 
    19891991    my $cgi = $app->uri; 
    19901992    if ($hosted_widget && (!$insides !~ m/<form\s/i)) { 
     
    91639165    my $type = $args->{type} || ''; 
    91649166 
    9165     my $displayname = $a->nickname || ''; 
     9167    my $displayname = encode_html( remove_html( $a->nickname || '' ) ); 
    91669168    my $show_email = $args->{show_email} ? 1 : 0; 
    91679169    my $show_url = 1 unless exists $args->{show_url} && !$args->{show_url}; 
     
    91799181            # Add vcard properties to link if requested (with hcard="1") 
    91809182            my $hcard = $args->{show_hcard} ? ' class="fn url"' : ''; 
    9181             return sprintf qq(<a%s href="%s"%s>%s</a>), $hcard, $a->url, $target, $displayname; 
     9183            return sprintf qq(<a%s href="%s"%s>%s</a>), $hcard, encode_html( $a->url ), $target, $displayname; 
    91829184        } 
    91839185    } elsif ($type eq 'email') { 
     
    91859187            # Add vcard properties to email if requested (with hcard="1") 
    91869188            my $hcard = $args->{show_hcard} ? ' class="fn email"' : ''; 
    9187             my $str = "mailto:" . $a->email; 
     9189            my $str = "mailto:" . encode_html( $a->email ); 
    91889190            $str = spam_protect($str) if $args->{'spam_protect'}; 
    91899191            return sprintf qq(<a%s href="%s">%s</a>), $hcard, $str, $displayname; 
     
    1080810810    $name ||= $args->{default_name}; 
    1080910811    $name ||= MT->translate("Anonymous"); 
     10812    $name = encode_html( remove_html( $name ) ); 
    1081010813    my $show_email = $args->{show_email} ? 1 : 0; 
    1081110814    my $show_url = 1 unless exists $args->{show_url} && !$args->{show_url}; 
     
    1081810821 
    1081910822    if ( $cmntr ) { 
     10823        $name = encode_html( remove_html( $cmntr->nickname ) ) if $cmntr->nickname; 
    1082010824        if ($cmntr->url) { 
    1082110825            return sprintf(qq(<a title="%s" href="%s"%s>%s</a>), 
    10822                            $cmntr->url, $cmntr->url, $target, $name);  
     10826                           encode_html( $cmntr->url ), encode_html( $cmntr->url ), $target, $name);  
    1082310827        } 
    1082410828        return $name; 
     
    1082910833        $name = remove_html($name); 
    1083010834        my $url = remove_html($c->url); 
    10831         $url =~ s/>/&gt;/g; 
    1083210835        if ($c->id && !$args->{no_redirect} && !$args->{nofollowfy}) { 
    1083310836            return sprintf(qq(<a title="%s" href="%s%s?__mode=red;id=%d"%s>%s</a>), 
    10834                            $url, $cgi_path, $comment_script, $c->id, $target, $name); 
     10837                           encode_html( $url ), $cgi_path, $comment_script, $c->id, $target, $name); 
    1083510838        } else { 
    1083610839            # In the case of preview, show URL directly without a redirect 
     
    1084010843    } elsif ($show_email && $c->email && MT::Util::is_valid_email($c->email)) { 
    1084110844        my $email = remove_html($c->email); 
    10842         my $str = "mailto:" . $email; 
     10845        my $str = "mailto:" . encode_html( $email ); 
    1084310846        $str = spam_protect($str) if $args->{'spam_protect'}; 
    1084410847        return sprintf qq(<a href="%s">%s</a>), $str, $name; 
     
    1123911242 
    1124011243    my $label = $args->{label} || $args->{text} || MT->translate('Reply'); 
    11241     my $comment_author = MT::Util::encode_js($comment->author); 
     11244    my $comment_author = MT::Util::encode_html( MT::Util::encode_js($comment->author) ); 
    1124211245    my $onclick = sprintf( $args->{onclick} || "mtReplyCommentOnClick(%d, '%s')", $comment->id, $comment_author); 
    1124311246 
     
    1258012583=item * Category 
    1258112584 
    12582 The label of the category. 
     12585The label of the category. Note that any HTML tags present in the label 
     12586will be removed. 
    1258312587 
    1258412588=item * Daily 
     
    1259612600=item * Individual 
    1259712601 
    12598 The title of the entry. 
     12602The title of the entry. Note that any HTML tags present in the label will 
     12603be removed. 
     12604 
     12605= item * Author 
     12606 
     12607The display name of the author. Note that any HTML tags present in the 
     12608display name will be removed. 
    1259912609 
    1260012610=back 
  • trunk/lib/MT/Util.pm

    r2929 r3219  
    641641sub remove_html { 
    642642    my($text) = @_; 
    643     return $text if !defined $text;  # suppress warnings 
    644     return $text if $text =~ m/^<\!\[CDATA\[/i;  
    645     $text =~ s!<[^>]+>!!gs; 
    646     $text =~ s!<!&lt;!gs; 
    647     $text; 
     643    return '' if !defined $text;  # suppress warnings 
     644    $text =~ s/(<\!\[CDATA\[(.*?)\]\]>)|(<[^>]+>)/ 
     645        defined $1 ? $1 : '' 
     646        /geisx; 
     647    $text =~ s/<(?!\!\[CDATA\[)/&lt;/gis; 
     648    return $text; 
    648649} 
    649650 
  • trunk/php/lib/MTUtil.php

    r3082 r3219  
    15301530            if ($filter == '__default__') { 
    15311531                $filter = 'convert_breaks'; 
     1532            } elseif ($filter == '__sanitize__') { 
     1533                $filter = 'sanitize'; 
    15321534            } 
    15331535            if ($filter == 'convert_breaks') { 
  • trunk/php/lib/archive_lib.php

    r2304 r3219  
    9797 
    9898    function get_title($args, $ctx) { 
    99         return $ctx->tag('EntryTitle', $args); 
     99        return encode_html( strip_tags( $ctx->tag('EntryTitle', $args) ) ); 
    100100    } 
    101101 
     
    113113        return 'Individual'; 
    114114    } 
    115      
     115 
    116116    function &get_archive_list($ctx, $args) { 
    117117        return $ctx->mt->db->get_archive_list($args); 
     
    291291            $format or $format = "%Y"; 
    292292        } 
    293          
     293 
    294294        return $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    295295    } 
     
    486486            } 
    487487        } 
    488         return $author_name; 
    489     } 
    490      
     488        return encode_html( strip_tags( $author_name ) ); 
     489    } 
     490 
    491491    function get_archive_name() { 
    492492        return 'Author'; 
     
    793793        } 
    794794 
    795         return $author_name.$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    796     } 
    797      
     795        return encode_html( strip_tags( $author_name ) ) 
     796            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
     797    } 
     798 
    798799    function get_archive_name() { 
    799800        return 'Author-Yearly'; 
     
    877878        $format = $args['format']; 
    878879        $format or $format = "%B %Y"; 
    879         return $author_name.$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    880     } 
    881      
     880        return encode_html( strip_tags( $author_name ) ) 
     881            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
     882    } 
     883 
    882884    function get_archive_name() { 
    883885        return 'Author-Monthly'; 
     
    902904        $year_ext = $mt->db->apply_extract_date('year', 'entry_authored_on'); 
    903905        $month_ext = $mt->db->apply_extract_date('month', 'entry_authored_on'); 
    904         $ctx = $mt->context();  
     906        $ctx = $mt->context(); 
    905907        $index = $ctx->stash('index_archive'); 
    906908 
     
    981983        $format = $args['format']; 
    982984        $format or $format = "%x"; 
    983         return $author_name.$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    984     } 
    985      
     985        return encode_html( strip_tags( $author_name ) ) 
     986            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
     987    } 
     988 
    986989    function get_archive_name() { 
    987990        return 'Author-Daily'; 
     
    10881091        $format = $args['format']; 
    10891092        $format or $format = "%x"; 
    1090         return $author_name 
    1091             .$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx) 
    1092             .' - '.$ctx->_hdlr_date(array('ts' => $end, 'format' => $format), $ctx); 
    1093     } 
    1094      
     1093        return encode_html( strip_tags( $author_name ) ) 
     1094            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx) 
     1095            . ' - ' . $ctx->_hdlr_date(array('ts' => $end, 'format' => $format), $ctx); 
     1096    } 
     1097 
    10951098    function get_archive_name() { 
    10961099        return 'Author-Weekly'; 
     
    11911194    function &get_archive_list($ctx, $args) { 
    11921195        global $mt; 
    1193         list($results, $hi, $low) =  
     1196        list($results, $hi, $low) = 
    11941197            $this->get_archive_list_data($args); 
    11951198        if(is_array($results)) { 
     
    13551358    function get_title($args, $ctx) { 
    13561359        $cat_name = parent::get_category_name($ctx); 
    1357         $stamp = $ctx->stash('current_timestamp');  
     1360        $stamp = $ctx->stash('current_timestamp'); 
    13581361        list($start) = start_end_year($stamp, $ctx->stash('blog')); 
    13591362        $format = $args['format']; 
     
    13671370            $format or $format = "%Y"; 
    13681371        } 
    1369         return $cat_name.$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
     1372        return encode_html( strip_tags( $cat_name ) ) 
     1373            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    13701374    } 
    13711375 
     
    14101414            if (isset($cat)){ 
    14111415                $cat_filter = " and placement_category_id=".$cat['category_id']; 
    1412          
     1416 
    14131417            } 
    14141418        #} 
     
    14641468        $format = $args['format']; 
    14651469        $format or $format = "%B %Y"; 
    1466         return $cat_name.$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
     1470        return encode_html( strip_tags( $cat_name ) ) 
     1471            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    14671472    } 
    14681473 
     
    15081513            if(isset($cat)) { 
    15091514                $cat_filter = " and placement_category_id=".$cat['category_id']; 
    1510          
     1515 
    15111516            } 
    15121517        #} 
     
    15661571        $format = $args['format']; 
    15671572        $format or $format = "%x"; 
    1568         return $cat_name.$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
     1573        return encode_html( strip_tags( $cat_name ) ) 
     1574            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx); 
    15691575    } 
    15701576 
     
    16111617            if(isset($cat)) { 
    16121618                $cat_filter = " and placement_category_id=".$cat['category_id']; 
    1613          
     1619 
    16141620            } 
    16151621        #} 
     
    16711677        $format = $args['format']; 
    16721678        $format or $format = "%x"; 
    1673         return $cat_name 
    1674             .$ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx) 
    1675             ." - ".$ctx->_hdlr_date(array('ts' => $end, 'format' => $format), $ctx); 
     1679        return encode_html( strip_tags( $cat_name ) ) 
     1680            . $ctx->_hdlr_date(array('ts' => $start, 'format' => $format), $ctx) 
     1681            . " - " . $ctx->_hdlr_date(array('ts' => $end, 'format' => $format), $ctx); 
    16761682    } 
    16771683 
     
    17191725            if(isset($cat)) { 
    17201726                $cat_filter = " and placement_category_id=".$cat['category_id']; 
    1721          
     1727 
    17221728            } 
    17231729        #} 
  • trunk/php/lib/function.mtcommentauthorlink.php

    r2630 r3219  
    1313        $name = $args['default_name']; 
    1414    $name or $name = $mt->translate("Anonymous"); 
     15    require_once "MTUtil.php"; 
     16    $name = encode_html( $name ); 
    1517    $email = $comment['comment_email']; 
    1618    $url = $comment['comment_url']; 
     
    3335 
    3436    if ( $cmntr ) { 
    35         $name = isset($cmntr['author_nickname']) ? $cmntr['author_nickname'] : $name; 
     37        $name = isset($cmntr['author_nickname']) ? encode_html( $cmntr['author_nickname'] ) : $name; 
    3638        if ($cmntr['author_url']) 
    37             return sprintf('<a title="%s" href="%s"%s>%s</a>', $cmntr['author_url'], $cmntr['author_url'], $target, $name); 
     39            return sprintf('<a title="%s" href="%s"%s>%s</a>', encode_html( $cmntr['author_url'] ), encode_html( $cmntr['author_url'] ), $target, $name); 
    3840        return $name; 
    3941    } elseif ($show_url && $url) { 
     
    4244        $comment_script = $ctx->mt->config('CommentScript'); 
    4345        $name = strip_tags($name); 
    44         $url = strip_tags($url); 
    45         $url = preg_replace('/>/', '&gt;', $url); 
     46        $url = encode_html( strip_tags($url) ); 
    4647        if ($comment['comment_id'] && !isset($args['no_redirect']) && !isset($args['nofollowfy'])) 
    4748            return sprintf('<a title="%s" href="%s%s?__mode=red;id=%d"%s>%s</a>', $url, $cgi_path, $comment_script, $comment['comment_id'], $target, $name); 
     
    4950            return sprintf('<a title="%s" href="%s"%s>%s</a>', $url, $url, $target, $name); 
    5051    } elseif ($show_email && $email && is_valid_email($email)) { 
    51         $email = strip_tags($email); 
     52        $email = encode_html( strip_tags($email) ); 
    5253        $str = 'mailto:' . $email; 
    5354        if ($args['spam_protect']) { 
  • trunk/php/lib/function.mtcommentreplytolink.php

    r2613 r3219  
    2020    $comment_author = $comment['comment_author']; 
    2121    require_once("MTUtil.php"); 
    22     $comment_author = encode_js($comment_author); 
     22    $comment_author = encode_html(encode_js($comment_author)); 
    2323 
    2424    $onclick = sprintf($onclick, $comment['comment_id'], $comment_author); 
  • trunk/php/lib/function.mtentryauthorlink.php

    r1174 r3219  
    1111 
    1212    $type = $args['type']; 
    13     $displayname = $entry['author_nickname']; 
     13    $displayname = encode_html( $entry['author_nickname'] ); 
    1414    if (isset($args['show_email'])) 
    1515        $show_email = $args['show_email']; 
     
    2121        $show_url = 1; 
    2222 
     23    require_once("MTUtil.php"); 
    2324    # Open the link in a new window if requested (with new_window="1"). 
    2425    $target = $args['new_window'] ? ' target="_blank"' : ''; 
     
    3233    if ($type == 'url') { 
    3334        if ($entry['author_url'] && ($displayname != '')) { 
    34             return sprintf('<a href="%s"%s>%s</a>', $entry['author_url'], $target, $displayname); 
     35            return sprintf('<a href="%s"%s>%s</a>', encode_html( $entry['author_url'] ), $target, $displayname); 
    3536        } 
    3637    } elseif ($type == 'email') { 
    3738        if ($entry['author_email'] && ($displayname != '')) { 
    38             $str = "mailto:" . $entry['author_email']; 
     39            $str = "mailto:" . encode_html( $entry['author_email'] ); 
    3940            if ($args['spam_protect']) 
    4041                $str = spam_protect($str); 
     
    5051    return $displayname; 
    5152} 
    52 ?> 
  • trunk/php/lib/modifier.sanitize.php

    r1174 r3219  
    66# $Id$ 
    77 
    8 function smarty_modifier_sanitize($text, $spec) { 
     8function smarty_modifier_sanitize($text, $spec = '1') { 
    99    if ($spec == '1') { 
    1010        global $mt; 
  • trunk/php/lib/sanitize_lib.php

    • Property svk:merge deleted
  • trunk/php/mt.php

    r3085 r3219  
    66# $Id: mt.php 2703 2008-07-03 22:19:49Z bchoate $ 
    77 
    8 define('VERSION', '4.21'); 
    9 define('VERSION_ID', '4.21'); 
    10 define('PRODUCT_VERSION', '4.21'); 
     8define('VERSION', '4.23'); 
     9define('VERSION_ID', '4.23'); 
     10define('PRODUCT_VERSION', '4.23'); 
    1111 
    1212$PRODUCT_NAME = '__PRODUCT_NAME__'; 
     
    107107 
    108108        foreach ($plugin_paths as $path) { 
    109             if ($dh = opendir($path)) { 
     109            if ($dh = @opendir($path)) { 
    110110                 while (($file = readdir($dh)) !== false) { 
    111111                     if ($file == "." || $file == "..") 
  • trunk/plugins/Cloner/cloner.pl

    r1174 r3219  
    1414use MT 4; 
    1515use base 'MT::Plugin'; 
     16use MT::Util qw( encode_html ); 
    1617our $VERSION = '2.0'; 
    1718 
     
    6364    my $blog = MT::Blog->load($blog_id) 
    6465        or return $app->error($plugin->translate("Invalid blog_id")); 
    65     require MT::Util; 
    66     my $blog_name = MT::Util::encode_html($blog->name); 
     66    # double escape to survive decode_html in translate_templatized 
     67    my $blog_name = encode_html(encode_html($blog->name, 1), 1); 
    6768 
    6869    # Set up and commence app output 
  • trunk/search_templates/comments.tmpl

    r2384 r3219  
    2424 
    2525<div id="banner"> 
    26 <h1><a href="<$MTBlogURL$>" accesskey="1"><$MTBlogName$></a></h1> 
    27 <h2><$MTBlogDescription$></h2> 
     26<h1><a href="<$MTBlogURL$>" accesskey="1"><$MTBlogName encode_html="1"$></a></h1> 
     27<h2><$MTBlogDescription encode_html="1"$></h2> 
    2828</div> 
    2929 
     
    5555 
    5656<MTSearchResults> 
    57 <h3><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></h3> 
    58 <p><$MTEntryExcerpt$> <$MTEntryEditLink$></p> 
    59 <p class="posted"><MT_TRANS phrase="Posted in [_1] on [_2]" params="<$MTBlogName$>%%<$MTEntryDate$>"></p> 
     57<h3><a href="<$MTEntryPermalink$>"><$MTEntryTitle encode_html="1"$></a></h3> 
     58<p><$MTEntryExcerpt encode_html="1"$> <$MTEntryEditLink$></p> 
     59<p class="posted"><MT_TRANS phrase="Posted in [_1] on [_2]" params="<$MTBlogName encode_html="1" encode_html="1"$>%%<$MTEntryDate$>"></p> 
    6060</MTSearchResults> 
    6161 
  • trunk/search_templates/default.tmpl

    r2384 r3219  
    5757                              <h3 class="search-results-header"> 
    5858                              <MTIfStraightSearch> 
    59                                   <MT_TRANS phrase="Matching entries from [_1]" params="<$MTBlogName$>"> 
     59                                  <MT_TRANS phrase="Matching entries from [_1]" params="<$MTBlogName encode_html="1" encode_html="1"$>"> 
    6060                              </MTIfStraightSearch> 
    6161                              <MTIfTagSearch> 
    62                                   <MT_TRANS phrase="Entries from [_1] tagged with '[_2]'" params="<$MTBlogName$>%%<$MTSearchString$>"> 
     62                                  <MT_TRANS phrase="Entries from [_1] tagged with '[_2]'" params="<$MTBlogName encode_html="1" encode_html="1"$>%%<$MTSearchString encode_html="1"$>"> 
    6363                                  </MTIfTagSearch> 
    6464                              </h3> 
     
    6666                          </MTBlogResultHeader> 
    6767                       
    68                               <h3><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></h3> 
    69                               <p><$MTEntryExcerpt$> <$MTEntryEditLink$></p> 
     68                              <h3><a href="<$MTEntryPermalink$>"><$MTEntryTitle encode_html="1"$></a></h3> 
     69                              <p><$MTEntryExcerpt encode_html="1"$> <$MTEntryEditLink$></p> 
    7070                              <MTIfTagSearch> 
    7171                                  <div class="entry-tags"> 
     
    7373                                      <ul class="entry-tags-list"> 
    7474                                          <MTEntryTags> 
    75                                               <li class="entry-tag"><a href="<$MTTagSearchLink$>&amp;IncludeBlogs=<$MTSearchIncludeBlogs$>" rel="tag"><$MTTagName$></a></li> 
     75                                              <li class="entry-tag"><a href="<$MTTagSearchLink$>&amp;IncludeBlogs=<$MTSearchIncludeBlogs$>" rel="tag"><$MTTagName encode_html="1"$></a></li> 
    7676                                          </MTEntryTags> 
    7777                                      </ul> 
     
    8080                       
    8181                              <p class="entry-footer"> 
    82                                   <span class="post-footers"><MT_TRANS phrase="Posted <MTIfNonEmpty tag="EntryAuthorDisplayName">by [_1] </MTIfNonEmpty>on [_2]" params="<$MTEntryAuthorDisplayName$>%%<$MTEntryDate$>"></span> 
     82                                  <span class="post-footers"><MT_TRANS phrase="Posted <MTIfNonEmpty tag="EntryAuthorDisplayName">by [_1] </MTIfNonEmpty>on [_2]" params="<$MTEntryAuthorDisplayName encode_html="1"$>%%<$MTEntryDate$>"></span> 
    8383                              </p> 
    8484                       
     
    9797                          <h3 class="search-results-header"> 
    9898                              <MTIfStraightSearch> 
    99                                   <MT_TRANS phrase="Entries matching '[_1]'" params="<$MTSearchString$>"> 
     99                                  <MT_TRANS phrase="Entries matching '[_1]'" params="<$MTSearchString encode_html="1"$>"> 
    100100                              </MTIfStraightSearch> 
    101101                              <MTIfTagSearch> 
    102                                   <MT_TRANS phrase="Entries tagged with '[_1]'" params="<$MTSearchString$>"> 
     102                                  <MT_TRANS phrase="Entries tagged with '[_1]'" params="<$MTSearchString encode_html="1"$>"> 
    103103                              </MTIfTagSearch> 
    104104                          </h3> 
    105                           <p><MT_TRANS phrase="No pages were found containing '[_1]'." params="<$MTSearchString$>"></p> 
     105                          <p><MT_TRANS phrase="No pages were found containing '[_1]'." params="<$MTSearchString encode_html="1"$>"></p> 
    106106                      </MTNoSearchResults> 
    107107                       
     
    133133                   <MTIfTagSearch> 
    134134                       <MTSetVar name="search_feed_param" value="tag"> 
    135                        <MTSetVarBlock name="search_feed_description"><MT_TRANS phrase="If you use an RSS reader, you can subscribe to a feed of all future entries tagged '[_1]'." params="<$MTSearchString$>"></MTSetVarBlock> 
     135                       <MTSetVarBlock name="search_feed_description"><MT_TRANS phrase="If you use an RSS reader, you can subscribe to a feed of all future entries tagged '[_1]'." params="<$MTSearchString encode_html="1"$>"></MTSetVarBlock> 
    136136                    <MTElse>     
    137137                       <MTSetVar name="search_feed_param" value="search"> 
    138                        <MTSetVarBlock name="search_feed_description"><MT_TRANS phrase="If you use an RSS reader, you can subscribe to a feed of all future entries matching '[_1]'." params="<$MTSearchString$>"></MTSetVarBlock> 
     138                       <MTSetVarBlock name="search_feed_description"><MT_TRANS phrase="If you use an RSS reader, you can subscribe to a feed of all future entries matching '[_1]'." params="<$MTSearchString encode_html="1"$>"></MTSetVarBlock> 
    139139                   </MTElse>     
    140140                   </MTIfTagSearch> 
     
    166166                                 <ul class="module-list"> 
    167167                                 <MTTags> 
    168                                      <li class="module-list-item taglevel<$MTTagRank$>"><a href="<$MTTagSearchLink$>" title="<$MTTagCount$>"><$MTTagName$></a></li> 
     168                                     <li class="module-list-item taglevel<$MTTagRank$>"><a href="<$MTTagSearchLink$>" title="<$MTTagCount$>"><$MTTagName encode_html="1"$></a></li> 
    169169                                 </MTTags> 
    170170                                 </ul> 
  • trunk/search_templates/results_feed.tmpl

    r1098 r3219  
    33    xmlns="http://www.w3.org/2005/Atom"  
    44    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"> 
    5     <title><MT_TRANS phrase="Search Results for [_1]" params="<$MTSearchString remove_html="1" encode_xml="1"$>"></title> 
     5    <title><MT_TRANS phrase="Search Results for [_1]" params="<$MTSearchString remove_html="1" encode_html="1" encode_xml="1"$>"></title> 
    66    <id>tag:<$MTCGIHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTCGIRelativeURL encode_xml="1"$>/feed/<$MTSearchString remove_html="1" encode_xml="1"$></id> 
    77    <link rel="self" type="application/atom+xml" href="<$MTCGIPath$><$MTSearchScript$>?search=<$MTSearchString$>&amp;Template=<$MTSearchTemplateID$>&amp;IncludeBlogs=<$MTSearchIncludeBlogs$>" /> 
  • trunk/search_templates/results_feed_rss2.tmpl

    r1098 r3219  
    22<rss version="2.0" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"> 
    33<channel> 
    4 <title><MT_TRANS phrase="Search Results for [_1]" params="<$MTSearchString remove_html="1" encode_xml="1"$>"></title> 
     4<title><MT_TRANS phrase="Search Results for [_1]" params="<$MTSearchString remove_html="1" encode_html="1" encode_xml="1"$>"></title> 
    55<link><$MTCGIPath$><$MTSearchScript$>?search=<$MTSearchString$>&amp;Template=<$MTSearchTemplateID$>&amp;IncludeBlogs=<$MTSearchIncludeBlogs$></link> 
    66<language>en-us</language> 
  • trunk/t/08-util.t

    r2562 r3219  
    77use MT::Util qw( encode_html decode_html wday_from_ts format_ts dirify 
    88                 convert_high_ascii encode_xml decode_xml substr_wref 
    9                  trim ltrim rtrim ); 
     9                 trim ltrim rtrim remove_html ); 
    1010use MT::I18N qw( encode_text ); 
    1111use strict; 
     
    1414$mt->config('NoHTMLEntities', 1); 
    1515 
    16 BEGIN { plan tests => 92 }; 
     16BEGIN { plan tests => 96 }; 
    1717 
    1818ok(substr_wref("Sabado", 0, 3), "Sab"); #1 
     
    134134ok(trim(' sunday monday '), 'sunday monday'); #92 
    135135 
     136ok(remove_html('<![CDATA[foo]]>'), '<![CDATA[foo]]>', "remove html preserves CDATA"); 
     137ok(remove_html('<![CDATA[]]><script>alert("foo")</script><![CDATA[]]>'), '<![CDATA[]]>alert("foo")<![CDATA[]]>', "remove html prevents abuse"); 
     138ok(remove_html('<![CDATA[one]]><script>alert("foo")</script><![CDATA[two]]>'), '<![CDATA[one]]>alert("foo")<![CDATA[two]]>', "remove html prevents abuse, saves plain text"); 
     139ok(remove_html('<![CDATA[<foo>]]><script>alert("foo")</script><![CDATA[two]]>'), '<![CDATA[&lt;foo>]]>alert("foo")<![CDATA[two]]>', "remove html prevents abuse, saves plain text, escapes inner < characters"); 
    136140 
    137141=pod 
  • trunk/t/11-sanitize.t

    r2562 r3219  
    77use lib 'extlib'; 
    88 
    9 use Test::More tests => 53; 
     9use Test::More tests => 54; 
    1010 
    1111use MT; 
     
    106106### this one breaks... 
    107107is(MT::Sanitize->sanitize('<? /* ?> */ readfile("/etc/passwd") ?>'), ' */ readfile("/etc/passwd") ?>', 'php cloaking attempt'); 
     108 
     109is(MT::Sanitize->sanitize("<a href=' 
     110javascript:alert(123)'>boo</a>", 'a href'), '<a>boo</a>', '<a>boo</a>');  
  • trunk/t/driver-tests.pl

    r2601 r3219  
    6767          status => 1, }, 
    6868        { class => 'Bar', 
     69          __wait => 1, 
    6970          id => 1, 
    7071          foo_id => 2, 
     
    7273          status => 0, }, 
    7374        { class => 'Bar', 
     75          __wait => 1, 
    7476          id => 2, 
    7577          foo_id => 2, 
     
    7779          status => 1, }, 
    7880        { class => 'Bar', 
     81          __wait => 1, 
    7982          id => 3, 
    8083          foo_id => 1, 
     
    8588    for my $data (@obj_data) { 
    8689        my $class = delete $data->{class}; 
     90        my $wait = delete $data->{__wait}; 
    8791        my $obj = $class->new; 
    8892        $obj->set_values($data); 
     93        sleep($wait) if $wait; 
    8994        $obj->save(); 
    9095    } 
     
    194199    ($status, $id) = $agb->(); 
    195200    ok(!$status, 'avg_group_by only had two results'); 
     201} 
     202 
     203sub max_group_by : Tests(7) { 
     204    my $mgb = Bar->max_group_by(undef, { 
     205        join => Foo->join_on(undef, 
     206            { 
     207                'id' => \'=bar_foo_id', 
     208            }), 
     209        group => ['foo_id'], 
     210        max => 'created_on', 
     211    }); 
     212    my ($created_on, $foo_id) = $mgb->(); 
     213    my $f1 = Foo->load(1); 
     214    my $b3 = Bar->load(3); 
     215    is($foo_id, $f1->id, 'max_group_by had a second result'); 
     216    #is($created_on, $b3->created_on, 'max_group_by had a second result'); 
     217 
     218    my $f2 = Foo->load(2); 
     219    my $b2 = Bar->load(2); 
     220    ($created_on, $foo_id) = $mgb->(); 
     221    is($foo_id, $f2->id, 'max_group_by had a first result'); 
     222    #is($created_on, $b2->created_on, 'max_group_by had a first result'); 
     223 
     224    ($created_on, $foo_id) = $mgb->(); 
     225    ok(!$created_on, 'max_group_by only had two results'); 
     226 
     227    my $mgb2 = Bar->max_group_by(undef, { 
     228        join => Foo->join_on(undef, 
     229            { 'id' => \'=bar_foo_id' }, 
     230            { limit => 1 }, 
     231        ), 
     232        group => ['foo_id'], 
     233        max => 'created_on', 
     234    }); 
     235    ($created_on, $foo_id) = $mgb2->(); 
     236    is($foo_id, $f1->id, 'max_group_by with limit had a first result'); 
     237    #is($created_on, $b3->created_on, 'max_group_by with limit had a first result'); 
     238 
     239    ($created_on, $foo_id) = $mgb2->(); 
     240    ok(!$created_on, 'max_group_by with limit only had one result'); 
     241 
     242    my $mgb3 = Bar->max_group_by(undef, { 
     243        join => Foo->join_on(undef, 
     244            { 'id' => \'=bar_foo_id' }, 
     245            { limit => 1, offset => 1 }, 
     246        ), 
     247        group => ['foo_id'], 
     248        max => 'created_on', 
     249    }); 
     250    ($created_on, $foo_id) = $mgb3->(); 
     251    is($foo_id, $f2->id, 'max_group_by with limit and offset had a first result'); 
     252    #is($created_on, $b2->created_on, 'max_group_by with limit and offset had a first result'); 
     253 
     254    ($created_on, $foo_id) = $mgb3->(); 
     255    ok(!$created_on, 'max_group_by with limit and offset only had one result'); 
    196256} 
    197257 
     
    253313 
    254314        { __class => 'Bar', 
     315          __wait   => 1, 
    255316          name    => 'Silverlight', 
    256317          status  => 2, 
    257318          foo_id  => 3,             }, 
    258319        { __class => 'Bar', 
     320          __wait   => 1, 
    259321          name    => 'IronPython', 
    260322          status  => 3, 
    261323          foo_id  => 3,            }, 
    262324        { __class => 'Bar', 
     325          __wait   => 1, 
    263326          name    => 'IronRuby', 
    264327          status  => 0, 
     
    415478    ); 
    416479    is_deeply(\@a_foos, [], 'No Foo has Bars with status=2 and status=0 (alias)'); 
    417 }  
     480} 
    418481 
    419482sub conjunctions : Tests(4) { 
     
    454517} 
    455518 
     519sub early_ending_iterators: Tests(4) { 
     520    my $self = shift; 
     521    $self->make_pc_data(); 
     522     
     523    my ($iter, $tmp, @tmp); 
     524    my @foo = map { Foo->load($_) } (1..5); 
     525 
     526    ## Load using descending sort (newest) 
     527    $iter = Foo->load_iter(undef, 
     528        { join => [ 'Bar', 'foo_id', 
     529                    undef, 
     530                    { sort => 'created_on', 
     531                      direction => 'descend', 
     532                      unique => 1 } ] }); 
     533    $tmp = $iter->(); 
     534    is_object($tmp, $foo[0], '(early ending iterator) Foo associated with the newest Bar is Foo #1'); 
     535    eval { $iter->end(); }; 
     536    is($@, q(), 'Iterator can be ended #1'); 
     537 
     538    ## Load using ascending sort (oldest) 
     539    $iter = Foo->load_iter(undef, 
     540        { join => [ 'Bar', 'foo_id', 
     541                    undef, 
     542                    { sort => 'created_on', 
     543                      direction => 'ascend', 
     544                      unique => 1 } ] }); 
     545    $tmp = $iter->(); 
     546    is_object($tmp, $foo[2], '(early ending iterator) Foo associated with the oldest Bar is Foo #3'); 
     547    eval { $iter->end(); }; 
     548    is($@, q(), 'Iterator can be ended #2'); 
     549} 
     550 
    456551sub clean_db : Test(teardown) { 
    457552    MT::Test->reset_table_for(qw( Foo Bar )); 
     
    462557use MT::Test; 
    463558 
    464 Test::Class->runtests('Test::GroupBy', 'Test::Search', +126); 
     559Test::Class->runtests('Test::GroupBy', 'Test::Search', +137); 
    465560 
    466561my($foo, @foo, @bar); 
     
    647742is_object($tmp, $foo[0], 'Second oldest Foo is Foo #1'); 
    648743 
     744## This should load only the first Foo object (because limit is 1). 
     745@tmp = Foo->load(undef, { 
     746    direction => 'descend', 
     747    sort => 'created_on', 
     748    fetchonly => ['id'], 
     749    limit => 1 }); 
     750is($tmp[0]->id, $foo[0]->id, 'The newest Foo is Foo #1 (fetchonly)'); 
     751 
     752## Should load the first Foo object (ascend with offset of 1). 
     753@tmp = Foo->load(undef, { 
     754    direction => 'ascend', 
     755    sort => 'created_on', 
     756    fetchonly => ['id'], 
     757    limit => 1, 
     758    offset => 1 }); 
     759is($tmp[0]->id, $foo[0]->id, 'Second oldest Foo is Foo #1 (fetchonly)'); 
     760 
    649761## Now test join loads. 
    650762## First we need to create a couple of Bar objects. 
     
    691803are_objects(\@tmp, \@foo, 'unique Foos associated with Bars, oldest first'); 
    692804 
     805## Use load_iter and do the same thing. 
     806@tmp = (); 
     807$iter = Foo->load_iter(undef, 
     808    { join => [ 'Bar', 'foo_id', 
     809                undef, 
     810                { sort => 'created_on', 
     811                  direction => 'descend', 
     812                  unique => 1 } ] }); 
     813while ( my $obj = $iter->() ) { 
     814    push @tmp, $obj; 
     815} 
     816are_objects(\@tmp, \@foo, 'unique Foos associated with Bars, oldest first, by load_iter'); 
     817 
    693818## Load all Foo objects in order of most recently 
    694819## created Bar object. No uniqueness requirement. 
     
    699824                  direction => 'descend', } ] }); 
    700825are_objects(\@tmp, [ @foo, $foo[1] ], 'Foos associated with Bars, oldest first'); 
     826 
     827## Use load_iter and do the same thing. 
     828@tmp = (); 
     829$iter = Foo->load_iter(undef, 
     830    { join => [ 'Bar', 'foo_id', 
     831                undef, 
     832                { sort => 'created_on', 
     833                  direction => 'descend', } ] }); 
     834while ( my $obj = $iter->() ) { 
     835    push @tmp, $obj; 
     836} 
     837are_objects(\@tmp, [ @foo, $foo[1] ], 'Foos associated with Bars, oldest first, by load_iter'); 
    701838 
    702839## Load last 1 Foo object in order of most recently 
     
    711848are_objects(\@tmp, [ $foo[0] ], 'Foos associated with oldest Bar'); 
    712849 
     850## Use load_iter to do the same thing. 
     851@tmp = (); 
     852$iter = Foo->load_iter(undef, 
     853    { join => [ 'Bar', 'foo_id', 
     854                undef, 
     855                { sort => 'created_on', 
     856                  direction => 'descend', 
     857                  unique => 1, 
     858                  limit => 1, } ] }); 
     859while ( my $obj = $iter->() ) { 
     860    push @tmp, $obj; 
     861} 
     862are_objects(\@tmp, [ $foo[0] ], 'Foos associated with oldest Bar, by load_iter'); 
     863 
    713864## Load all Foo objects where Bar.name = 'bar0' 
    714865@tmp = Foo->load(undef, 
     
    720871are_objects(\@tmp, [ $foo[1] ], 'Foos associated with Bars named bar0'); 
    721872 
     873## Use load_iter and do the same thing. 
     874@tmp = (); 
     875$iter = Foo->load_iter(undef, 
     876    { join => [ 'Bar', 'foo_id', 
     877                { name => 'bar0' }, 
     878                { sort => 'created_on', 
     879                  direction => 'descend', 
     880                  unique => 1, } ] }); 
     881while ( my $obj = $iter->() ) { 
     882    push @tmp, $obj; 
     883} 
     884are_objects(\@tmp, [ $foo[1] ], 'Foos associated with Bars named bar0, by load_iter'); 
     885 
    722886## foo[1] is older than foo[0] because we overrode the timestamp, 
    723887## so this should load foo[0] 
     
    727891are_objects(\@tmp, [ $foo[0] ], 'One Foo associated with Bars of status=0'); 
    728892 
     893## and load_iter 
     894@tmp = (); 
     895$iter = Foo->load_iter(undef, 
     896    { sort => 'created_on', direction => 'descend', limit => 1, 
     897    join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 
     898while ( my $obj = $iter->() ) { 
     899    push @tmp, $obj; 
     900} 
     901are_objects(\@tmp, [ $foo[0] ], 'One Foo associated with Bars of status=0, by load_iter'); 
     902 
    729903## This is the same join as the last one, but without the limit--so 
    730904## we should get both Foo objects this time, in descending order. 
     
    734908are_objects(\@tmp, \@foo, 'All Foos associated with Bars of status=0'); 
    735909 
     910## and load_iter. 
     911@tmp = (); 
     912$iter = Foo->load_iter(undef, 
     913    { sort => 'created_on', direction => 'descend', 
     914      join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 
     915while ( my $obj = $iter->() ) { 
     916    push @tmp, $obj; 
     917} 
     918are_objects(\@tmp, \@foo, 'All Foos associated with Bars of status=0, by load_iter'); 
     919 
    736920## Filter join results by providing a value for 'status'; only Foo[0] 
    737921## has a 'status' == 2, so only that record should be returned. 
     
    741925are_objects(\@tmp, [ $foo[0] ], 'Foos of status=2 associated with Bars of status=0'); 
    742926 
     927## and load_iter. 
     928@tmp = (); 
     929$iter = Foo->load_iter({ status => 2 }, 
     930    { sort => 'created_on', direction => 'descend', 
     931      join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 
     932while ( my $obj = $iter->() ) { 
     933    push @tmp, $obj; 
     934} 
     935are_objects(\@tmp, [ $foo[0] ], 'Foos of status=2 associated with Bars of status=0, by load_iter'); 
     936 
    743937# Join across a column. 
    744938@tmp = Foo->load({}, 
     
    751945      join => [ 'Bar', undef, { foo_id => \'= foo_id', status => 0 }, { unique => 1 } ] }); 
    752946are_objects(\@tmp, [ $foo[0] ], 'Foos of status=2 loaded by explicit join across columns'); 
     947 
     948# and load_iter. 
     949@tmp = (); 
     950$iter = Foo->load_iter({}, 
     951    { sort => 'created_on', direction => 'descend', 
     952      join => [ 'Bar', undef, { foo_id => \'= foo_id', status => 0 }, { unique => 1 } ] }); 
     953while ( my $obj = $iter->() ) { 
     954    push @tmp, $obj; 
     955} 
     956are_objects(\@tmp, \@foo, 'Foos loaded by explicit join across columns, by load_iter'); 
     957 
     958@tmp = (); 
     959$iter = Foo->load_iter({ status => 2 }, 
     960    { sort => 'created_on', direction => 'descend', 
     961      join => [ 'Bar', undef, { foo_id => \'= foo_id', status => 0 }, { unique => 1 } ] }); 
     962while ( my $obj = $iter->() ) { 
     963    push @tmp, $obj; 
     964} 
     965are_objects(\@tmp, [ $foo[0] ], 'Foos of status=2 loaded by explicit join across columns, by load_iter'); 
    753966 
    754967## TEST EXISTS METHOD 
  • trunk/tmpl/cms/dialog/comment_reply.tmpl

    r2784 r3219  
    2222    <input type="hidden" name="return_url" value="<mt:if name="return_url"><mt:var name="return_url" escape="html"><mt:else><mt:var name="mt_url">?__mode=list_comments&amp;blog_id=<mt:var name="blog_id" escape="url"></mt:if>" /> 
    2323    <div id="comment"> 
    24         <p class="comment-meta"><__trans phrase="On [_1], [_2] commented on [_3]" params="<span class="comment-date"><$mt:var name="comment_created_on"$></span>%%<span class="commenter-name"><$mt:var name="commenter_name" escape="html"$></span>%%<span class="entry-title"><$mt:var name="entry_title" escape="html"$></span>"></p> 
     24        <p class="comment-meta"><__trans phrase="On [_1], [_2] commented on [_3]" params="<span class="comment-date"><$mt:var name="comment_created_on"$></span>%%<span class="commenter-name"><$mt:var name="commenter_name" escape="html"$></span>%%<span class="entry-title"><$mt:var name="entry_title" escape="html" escape="html"$></span>"></p> 
    2525        <div class="comment-body"> 
    2626            <$mt:var name="comment_text"$> 
  • trunk/tmpl/cms/edit_asset.tmpl

    r2784 r3219  
    2424        label="<__trans phrase="Stats">"> 
    2525        <ul class="object-stats"> 
    26             <li><__trans phrase="[_1] - Created by [_2]" params="<$mt:date ts="$created_on_ts" relative="1" _default="$created_on_formatted"$>%%<$mt:var name="created_by" escape="html"$>"></li> 
     26            <li><__trans phrase="[_1] - Created by [_2]" params="<$mt:date ts="$created_on_ts" relative="1" _default="$created_on_formatted"$>%%<$mt:var name="created_by" escape="html" escape="html"$>"></li> 
    2727        <mt:if name="modified_by"> 
    28             <li><__trans phrase="[_1] - Modified by [_2]" params="<$mt:date ts="$modified_on_ts" relative="1" _default="$modified_on_formatted"$>%%<$mt:var name="modified_by" escape="html"$>"></li> 
     28            <li><__trans phrase="[_1] - Modified by [_2]" params="<$mt:date ts="$modified_on_ts" relative="1" _default="$modified_on_formatted"$>%%<$mt:var name="modified_by" escape="html" escape="html"$>"></li> 
    2929        </mt:if> 
    3030        </ul> 
  • trunk/tmpl/cms/edit_author.tmpl

    r2784 r3219  
    7878} 
    7979function passwordResetConfirm() { 
    80     if (confirm('<__trans phrase="_WARNING_PASSWORD_RESET_SINGLE" params="<mt:var name="name" escape="js">%%<mt:var name="email" escape="js">">')) { 
     80    var username = '<mt:var name="name" escape="js">'; 
     81    var email = '<mt:var name="email" escape="js">'; 
     82    if (confirm('<__trans phrase="_WARNING_PASSWORD_RESET_SINGLE" params="'+username+'%%'+email+'">')) { 
    8183        document.forms['recover'].submit(); 
    8284    } 
  • trunk/tmpl/cms/edit_commenter.tmpl

    r2784 r3219  
    2929        label="<__trans phrase="Useful links">"> 
    3030        <ul> 
    31             <li><a href="<mt:var name="script_url">?__mode=list_comments&amp;blog_id=<mt:var name="blog_id" escape="url">&amp;filter_key=_comments_by_user&amp;filter_val=<mt:var name="id" escape="url">"><__trans phrase="Comments from [_1]" params="<mt:var name="nickname" escape="html">"></a></li> 
     31            <li><a href="<mt:var name="script_url">?__mode=list_comments&amp;blog_id=<mt:var name="blog_id" escape="url">&amp;filter_key=_comments_by_user&amp;filter_val=<mt:var name="id" escape="url">"><__trans phrase="Comments from [_1]" params="<mt:var name="nickname" escape="html" escape="html">"></a></li> 
    3232        </ul> 
    3333    </mtapp:widget> 
  • trunk/tmpl/cms/edit_entry.tmpl

    r3098 r3219  
    353353            <mt:unless name="new_object"> 
    354354            <ul> 
    355                 <li><__trans phrase="[_1] - Created by [_2]" params="<$mt:date ts="$created_on_ts" relative="1" _default="$created_on_formatted"$>%%<$mt:var name="created_by" escape="html"$>"></li> 
     355                <li><__trans phrase="[_1] - Created by [_2]" params="<$mt:date ts="$created_on_ts" relative="1" _default="$created_on_formatted"$>%%<$mt:var name="created_by" escape="html" escape="html"$>"></li> 
    356356            <mt:if name="status_publish"> 
    357                 <li><__trans phrase="[_1] - Published by [_2]" params="<$MTDate ts="$authored_on_ts" relative="1" _default="$authored_on_formatted"$>%%<$mt:var name="author_name" escape="html"$>"></li> 
     357                <li><__trans phrase="[_1] - Published by [_2]" params="<$MTDate ts="$authored_on_ts" relative="1" _default="$authored_on_formatted"$>%%<$mt:var name="author_name" escape="html" escape="html"$>"></li> 
    358358            </mt:if> 
    359359            <mt:if name="modified_by"> 
    360                 <li><__trans phrase="[_1] - Edited by [_2]" params="<$MTDate ts="$modified_on_ts" relative="1" _default="$modified_on_formatted"$>%%<$mt:var name="modified_by" escape="html"$>"></li> 
     360                <li><__trans phrase="[_1] - Edited by [_2]" params="<$MTDate ts="$modified_on_ts" relative="1" _default="$modified_on_formatted"$>%%<$mt:var name="modified_by" escape="html" escape="html"$>"></li> 
    361361            </mt:if> 
    362362            </ul> 
     
    898898 
    899899function listPreviousPings () { 
    900     window.open('<TMPL_VAR NAME=SCRIPT_URL>?__mode=pinged_urls&entry_id=<TMPL_VAR NAME=ID>&blog_id=<TMPL_VAR NAME=BLOG_ID>', 'urls', 'width=400,height=400,resizable=yes,scrollbars=yes'); 
     900    window.open('<mt:var name="script_url">?__mode=pinged_urls&entry_id=<mt:var name="id" escape="html">&blog_id=<mt:var name="blog_id" escape="html">', 'urls', 'width=400,height=400,resizable=yes,scrollbars=yes'); 
    901901} 
    902902/* ]]> */ 
  • trunk/tmpl/cms/edit_role.tmpl

    r2784 r3219  
    257257                label="<__trans phrase="Created by">" 
    258258                hint=""> 
    259                 <p><mt:if name="created_by"><mt:var name="created_by"><mt:else><em><__trans phrase="System"></em></mt:if></p> 
     259                <p><mt:if name="created_by"><mt:var name="created_by" escape="html"><mt:else><em><__trans phrase="System"></em></mt:if></p> 
    260260            </mtapp:setting> 
    261261        </mt:if> 
  • trunk/tmpl/cms/include/asset_table.tmpl

    r1226 r3219  
    7272    </mt:if> 
    7373                </td> 
    74                 <td class="as-created-by"><mt:if name="created_by"><mt:var name="created_by"><mt:else><em><__trans phrase="System"></em></mt:if></td> 
     74                <td class="as-created-by"><mt:if name="created_by"><mt:var name="created_by" escape="html"><mt:else><em><__trans phrase="System"></em></mt:if></td> 
    7575                <td><span title="<mt:var name="created_on_formatted">"><mt:if name="created_on_relative"><mt:if name="dates_relative"><mt:var name="created_on_relative"><mt:else><mt:var name="created_on_formatted"></mt:if><mt:else><mt:var name="created_on_formatted"></mt:if></span></td> 
    7676                <td class="si status-view"><mt:if name="url"><a href="<mt:var name="url">" target="view_uploaded" title="<__trans phrase="View">"><img src="<mt:var name="static_uri">images/spacer.gif" alt="<__trans phrase="View">" width="13" height="9" /></a><mt:else>&nbsp;</mt:if></td> 
  • trunk/tmpl/cms/include/comment_detail.tmpl

    r2692 r3219  
    66                            <$mt:CommentAuthorIdentity$> 
    77        <mt:IfCommentParent> 
    8                             <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="<span class="vcard author"><$mt:CommentAuthorLink$></span>%%<mt:CommentParent><$mt:CommentLink$></mt:CommentParent>%%<mt:CommentParent><$mt:CommentAuthor$></mt:CommentParent>"> 
     8                            <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="<span class="vcard author"><$mt:CommentAuthorLink escape="html"$></span>%%<mt:CommentParent><$mt:CommentLink$></mt:CommentParent>%%<mt:CommentParent><$mt:CommentAuthor escape="html"$></mt:CommentParent>"> 
    99        <mt:Else> 
    10                             <span class="vcard author"><$mt:CommentAuthorLink$></span> 
     10                            <span class="vcard author"><$mt:CommentAuthorLink escape="html"$></span> 
    1111        </mt:IfCommentParent> 
    1212                            | <a href="<$mt:CommentLink$>"><abbr class="published" title="<$mt:CommentDate format_name="iso8601"$>"><$mt:CommentDate$></abbr></a> 
  • trunk/tmpl/cms/include/entry_table.tmpl

    r3063 r3219  
    169169            <mt:if name="is_editable"> 
    170170                    <input type="hidden" name="author_id_<$mt:var name="id"$>" value="<$mt:var name="row_author_id"$>" id="entry_author_id_<$mt:var name="id"$>"> 
    171                     <a href="javascript:void(0)" onclick="return openDialog(this.form, 'dialog_select_author', 'blog_id=<$mt:var name="blog_id"$>&amp;multi=0&amp;idfield=entry_author_id_<$mt:var name="id"$>&amp;namefield=entry_author_name_<$mt:var name="id"$>')"><span id="entry_author_name_<$mt:var name="id"$>"><$mt:var name="row_author_name"$></span></a> 
    172             <mt:else> 
    173                     <$mt:var name="author_name"$> 
     171                    <a href="javascript:void(0)" onclick="return openDialog(this.form, 'dialog_select_author', 'blog_id=<$mt:var name="blog_id"$>&amp;multi=0&amp;idfield=entry_author_id_<$mt:var name="id"$>&amp;namefield=entry_author_name_<$mt:var name="id"$>')"><span id="entry_author_name_<$mt:var name="id"$>"><$mt:var name="row_author_name" escape="html"$></span></a> 
     172            <mt:else> 
     173                    <$mt:var name="author_name" escape="html"$> 
    174174            </mt:if> 
    175175                </td> 
  • trunk/tmpl/cms/include/header.tmpl

    r2977 r3219  
    9292    </mt:unless> 
    9393            <li id="help" class="help"><a href="javascript:void(0)" onclick="openManual('<mt:var name="template_filename" escape="js">')"><__trans phrase="Help"></a></li> 
    94             <li id="user"><a href="<$mt:var name="mt_url"$>?__mode=view&amp;_type=author&amp;id=<$mt:var name="author_id"$>"><__trans phrase="Hi [_1]," params="<$mt:var name="author_name"$>"></a></li> 
     94            <li id="user"><a href="<$mt:var name="mt_url"$>?__mode=view&amp;_type=author&amp;id=<$mt:var name="author_id" escape="html" escape="html"$>"><__trans phrase="Hi [_1]," params="<$mt:var name="author_name" escape="html" escape="html"$>"></a></li> 
    9595        <mt:if name="can_logout"> 
    9696            <li id="logout"><a href="<$mt:var name="mt_url"$>?__mode=logout"><__trans phrase="Logout"></a></li> 
  • trunk/tmpl/cms/include/import_start.tmpl

    r1098 r3219  
    1212 
    1313<pre><__trans phrase="Importing entries into blog" params="<mt:var name="blog_name" escape="html">"> 
    14 <mt:if name="import_as_me"><__trans phrase="Importing entries as user '[_1]'" params="<mt:var name="author_name">"><mt:else><__trans phrase="Creating new users for each user found in the blog"></mt:if> 
     14<mt:if name="import_as_me"><__trans phrase="Importing entries as user '[_1]'" params="<mt:var name="author_name" escape="html" escape="html">"><mt:else><__trans phrase="Creating new users for each user found in the blog"></mt:if> 
    1515 
  • trunk/tmpl/cms/include/list_associations/page_title.tmpl

    r1098 r3219  
    11    <mt:if name="user_view"> 
    2         <mt:setvarblock name="page_title"><__trans phrase="Permissions for [_1]" params="<mt:var name="edit_name" escape="html">"></mt:setvarblock> 
     2        <mt:setvarblock name="page_title"><__trans phrase="Permissions for [_1]" params="<mt:var name="edit_name" escape="html" escape="html">"></mt:setvarblock> 
    33    </mt:if> 
    44    <mt:if name="usergroup_view"> 
  • trunk/tmpl/cms/include/list_associations/table_role_view.tmpl

    r1098 r3219  
    22    <td> 
    33    <mt:if name="is_administrator"> 
    4         <a href="<$mt:var name="script_url"$>?__mode=list_associations&amp;role_id=<$mt:var name="role_id"$>"><$mt:var name="role_name" escape="html"$> 
     4        <a href="<$mt:var name="script_url"$>?__mode=list_associations&amp;role_id=<$mt:var name="role_id" escape="html"$>"><$mt:var name="role_name" escape="html"$> 
    55    <mt:else> 
    66        <$mt:var name="role_name" escape="html"$> 
     
    1111    <td> 
    1212        <mt:if name="is_administrator"> 
    13             <a href="<mt:var name="script_url">?__mode=list_associations&amp;author_id=<mt:var name="user_id">" class="icon-right icon-user"><$mt:var name="user_name" escape="html"$></a> 
     13            <a href="<mt:var name="script_url">?__mode=list_associations&amp;author_id=<mt:var name="user_id" escape="html">" class="icon-right icon-user"><$mt:var name="user_name" escape="html"$></a> 
    1414        <mt:else> 
    1515            <span class="icon-right icon-user"><$mt:var name="user_name" escape="html"$></span> 
  • trunk/tmpl/cms/include/list_associations/table_user_view.tmpl

    r1098 r3219  
    11<mt:if name="user_id"> 
    22    <mt:if name="is_administrator"> 
    3         <a href="<mt:var name="script_url">?__mode=list_associations&amp;author_id=<mt:var name="user_id">" class="icon-right icon-user"><$mt:var name="user_name" escape="html"$></a> 
     3        <a href="<mt:var name="script_url">?__mode=list_associations&amp;author_id=<mt:var name="user_id" escape="html">" class="icon-right icon-user"><$mt:var name="user_name" escape="html"$></a> 
    44    <mt:else> 
    55        <span class="icon-right icon-user"><$mt:var name="user_name" escape="html"$></span> 
  • trunk/tmpl/cms/include/listing_panel.tmpl

    r1098 r3219  
    6262                            <tr id="<mt:var name="panel_type">-<mt:var name="id">" class="<mt:if name="__odd__">odd<mt:else>even</mt:if>"> 
    6363                                <td class="cb"><input type="<mt:if name="panel_multi">checkbox<mt:else>radio</mt:if>" class="select" name="<mt:var name="panel_type">-cb" value="<mt:var name="id">" <mt:if name="disabled">disabled="disabled"</mt:if> /></td> 
    64                                 <td class="panel-label"><label><mt:var name="label"></label></td> 
     64                                <td class="panel-label"><label><mt:var name="label" escape="html"></label></td> 
    6565                                <td class="panel-description"> 
    66                                     <mt:if name="link"><span class="view-site-link"><a href="<mt:var name="link" escape="html">" target="_blank"><img src="<mt:var name="static_uri">images/spacer.gif" title="<__trans phrase="Go to [_1]" params="<mt:var name="label" escape="html">">" width="13" height="9" alt="" /></a></span></mt:if> 
    67                                     <mt:if name="link"><span class="float_desc"></mt:if><mt:var name="description"><mt:if name="link"></span></mt:if> 
     66<mt:Ignore><!-- No, the duplicate escape modifiers below is not a typo. --></mt:Ignore> 
     67                                    <mt:if name="link"><span class="view-site-link"><a href="<mt:var name="link" escape="html">" target="_blank"><img src="<mt:var name="static_uri">images/spacer.gif" title="<__trans phrase="Go to [_1]" params="<mt:var name="label" escape="html" escape="html">">" width="13" height="9" alt="" /></a></span></mt:if> 
     68                                    <mt:if name="link"><span class="float_desc"></mt:if><mt:var name="description" escape="html"><mt:if name="link"></span></mt:if> 
    6869                                </td> 
    6970                            </tr> 
  • trunk/tmpl/cms/include/log_table.tmpl

    r1100 r3219  
    2323            <td class="weblog"><a href="<$mt:var name="script_url"$>?__mode=view_log&amp;blog_id=<$mt:var name="blog_id"$>"><$mt:var name="weblog_name" escape="html"$></a></td> 
    2424    </mt:if> 
    25             <td class="action-by"><mt:if name="username"><$mt:var name="username"$><mt:else><__trans phrase="[_1]" params="<$mt:var name="log_ip"$>"></mt:if></td> 
     25            <td class="action-by"><mt:if name="username"><$mt:var name="username" escape="html"$><mt:else><__trans phrase="[_1]" params="<$mt:var name="log_ip"$>"></mt:if></td> 
    2626            <td class="date"><mt:if name="is_last"><a name="last"></a></mt:if><span title="<$mt:var name="created_on_formatted"$>"><mt:if name="created_on_relative"><mt:if name="dates_relative"><$mt:var name="created_on_relative"$><mt:else><$mt:var name="created_on_formatted"$></mt:if><mt:else><$mt:var name="created_on_formatted"$></mt:if></span></td> 
    2727        </tr> 
  • trunk/tmpl/cms/include/template_table.tmpl

    r3082 r3219  
    3131    <mt:else if name="template_type" eq="archive"> 
    3232        <a href="javascript:void(0)" 
    33             onclick="doForMarkedInThisWindow(getByID('<$mt:var name="template_type" default="template"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">', 'id', 'publish_archive_templates', {}, '<__trans phrase="to publish" escape="js">'); return false;" 
     33            onclick="doForMarkedInThisWindow(getByID('<$mt:var name="template_type" default="template" escape="html"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">', 'id', 'publish_archive_templates', {}, '<__trans phrase="to publish" escape="js">'); return false;" 
    3434            accesskey="a" 
    3535            title="<__trans phrase="Publish selected templates (a)">" 
     
    7474        <tbody> 
    7575    </mt:if> 
    76             <tr class="<mt:if name="__odd__">odd<mt:else>even</mt:if> template-<$mt:var name="template_type" default="template"$>"> 
     76            <tr class="<mt:if name="__odd__">odd<mt:else>even</mt:if> template-<$mt:var name="template_type" default="template" escape="html"$>"> 
    7777                <td class="cb"><input type="checkbox" name="id" class="select" value="<mt:var name="id">" /></td> 
    7878                <td class="template-name"><a href="<mt:var name="script_url">?__mode=view&amp;_type=template&amp;id=<mt:var name="id">&amp;blog_id=<mt:var name="blog_id">"><mt:var name="name" escape="html"></a></td> 
     
    139139<mt:else> 
    140140    <mt:if name="blog_id"> 
    141     <div id="<$mt:var name="template_type" default="template"$>-listing" class="listing zero-state-listing zero-state"> 
     141    <div id="<$mt:var name="template_type" default="template" escape="html"$>-listing" class="listing zero-state-listing zero-state"> 
    142142        <div class="listing-header"> 
    143143            <$mt:var name="listing_header"$> 
  • trunk/tmpl/cms/include/users_content_nav.tmpl

    r1501 r3219  
    22<mt:if name="USER_VIEW"> 
    33    <mt:unless name="EDIT_AUTHOR_ID" eq="PSEUDO"> 
    4     <li><a href="<mt:var name="SCRIPT_URL">?__mode=view&amp;_type=author&amp;id=<mt:var name="EDIT_AUTHOR_ID">"><b><__trans phrase="Profile"></b></a></li> 
     4    <li><a href="<mt:var name="SCRIPT_URL">?__mode=view&amp;_type=author&amp;id=<mt:var name="EDIT_AUTHOR_ID" escape="html">"><b><__trans phrase="Profile"></b></a></li> 
    55    </mt:unless> 
    6     <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;author_id=<mt:var name="EDIT_AUTHOR_ID">"><b><__trans phrase="Permissions"></b></a></li> 
     6    <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;author_id=<mt:var name="EDIT_AUTHOR_ID" escape="html">"><b><__trans phrase="Permissions"></b></a></li> 
    77</mt:if> 
    88 
    99<mt:if name="edit_author"> 
    10     <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=view&amp;_type=author<mt:if name="id">&amp;id=<mt:var name="id"></mt:if>"><b><__trans phrase="Profile"></b></a></li> 
     10    <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=view&amp;_type=author<mt:if name="id">&amp;id=<mt:var name="id" escape="html"></mt:if>"><b><__trans phrase="Profile"></b></a></li> 
    1111    <mt:unless name="new_object"> 
    12         <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;author_id=<mt:var name="id">"><b><__trans phrase="Permissions"></b></a></li> 
     12        <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;author_id=<mt:var name="id" escape="html">"><b><__trans phrase="Permissions"></b></a></li> 
    1313    </mt:unless> 
    1414</mt:if> 
    1515 
    1616<mt:if name="ROLE_VIEW"> 
    17     <li><a href="<mt:var name="SCRIPT_URL">?__mode=edit_role&amp;id=<mt:var name="ROLE_ID">"><b><__trans phrase="Details"></b></a></li> 
    18     <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;role_id=<mt:var name="ROLE_ID">"><b><__trans phrase="Users"></b></a></li> 
     17    <li><a href="<mt:var name="SCRIPT_URL">?__mode=edit_role&amp;id=<mt:var name="ROLE_ID" escape="html">"><b><__trans phrase="Details"></b></a></li> 
     18    <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;role_id=<mt:var name="ROLE_ID" escape="html">"><b><__trans phrase="Users"></b></a></li> 
    1919</mt:if> 
    2020 
    2121<mt:if name="edit_role"> 
    22     <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=edit_role&amp;id=<mt:var name="ID">"><b><__trans phrase="Details"></b></a></li> 
    23     <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;role_id=<mt:var name="ID">"><b><__trans phrase="Users"></b></a></li> 
     22    <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=edit_role&amp;id=<mt:var name="ID" escape="html">"><b><__trans phrase="Details"></b></a></li> 
     23    <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;role_id=<mt:var name="ID" escape="html">"><b><__trans phrase="Users"></b></a></li> 
    2424</mt:if> 
    2525 
     
    2727    <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_authors"><b><__trans phrase="Users"></b></a></li> 
    2828    <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_roles"><b><__trans phrase="Roles"></b></a></li> 
    29     <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Permissions"></b></a></li> 
     29    <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;blog_id=<mt:var name="BLOG_ID" escape="html">"><b><__trans phrase="Permissions"></b></a></li> 
    3030</mt:if> 
    3131 
     
    3434    <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_authors"><b><__trans phrase="Users"></b></a></li> 
    3535    <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_roles"><b><__trans phrase="Roles"></b></a></li> 
    36     <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;blog_id=<mt:var name="BLOG_ID">"><b><__trans phrase="Permissions"></b></a></li> 
     36    <li><a href="<mt:var name="SCRIPT_URL">?__mode=list_associations&amp;blog_id=<mt:var name="BLOG_ID" escape="html">"><b><__trans phrase="Permissions"></b></a></li> 
    3737</mt:if> 
    3838 
    3939<mt:if name="list_role"> 
    4040    <mt:if name="EDIT_AUTHOR_ID"> 
    41         <li><a href="<mt:var name="SCRIPT_URL">?__mode=view&amp;_type=author&amp;id=<mt:var name="EDIT_AUTHOR_ID">"><b><__trans phrase="Profile"></b></a></li> 
    42         <li class="active"><a href="<mt:var name="SCRIPT_URL">?__mode=list_roles&amp;author_id=<mt:var name="EDIT_AUTHOR_ID">"><b><__trans phrase="Roles"></b></a></li> 
     41        <li><a href="<mt:var name="SCRIPT_URL">?__mode=view&amp;_type=author&amp;id=<mt:var name="EDIT_AUTHOR_ID" escape="html">"><b><__trans phrase