- sort testcases by sort_order, then by testcase ID (for fallback sorting)

- create Litmus::StripScripts subclass of HTML::StripScripts so we can implement our own HREF validation, like say, allowing ftp:// and mailto:// links.


git-svn-id: svn://10.0.0.236/trunk@201765 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ccooper%deadsquid.com
2006-07-07 20:34:58 +00:00
parent fbcdbd2f64
commit 6626bffe35
3 changed files with 55 additions and 12 deletions

View File

@@ -72,7 +72,7 @@ __PACKAGE__->set_sql(CommunityEnabledBySubgroup => qq{
SELECT t.*
FROM testcases t, testcase_subgroups tsg
WHERE tsg.subgroup_id=? AND tsg.testcase_id=t.testcase_id AND t.enabled=1 AND t.community_enabled=1
ORDER BY tsg.sort_order ASC
ORDER BY tsg.sort_order ASC, t.testcase_id ASC
});
Litmus::DB::Testcase->has_many(test_results => "Litmus::DB::Testresult", {order_by => 'submission_time DESC'});

View File

@@ -0,0 +1,43 @@
# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*-
=head1 COPYRIGHT
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License
# at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and
# limitations under the License.
#
# The Original Code is Litmus.
#
# The Initial Developer of the Original Code is
# the Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2006
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Chris Cooper <ccooper@deadsquid.com>
# Zach Lipton <zach@zachlipton.com>
#
# ***** END LICENSE BLOCK *****
=cut
package Litmus::StripScripts;
use base qw(HTML::StripScripts::Parser);
# Override broken href validation code.
sub validate_href_attribute {
my ($self, $text) = @_;
$self->SUPER::validate_href_attribute or $text =~ m<^((https?|ftp|mailto)://[\w\-\.]{1,100}(?:\:\d{1,5})?(?:/(?:[\w\-.!~*|;/?=+\$\,%#]|&amp;){0,100})?)$>x ? $1 : undef;
}
1;

View File

@@ -47,7 +47,7 @@ package Litmus::Template;
use strict;
use Litmus::Config;
use HTML::StripScripts::Parser;
use Litmus::StripScripts;
use Text::Markdown;
use base qw(Template);
@@ -66,14 +66,14 @@ my %constants;
$constants{litmus_version} = $Litmus::Config::version;
# html tag stripper:
my $strip = HTML::StripScripts::Parser->new(
{
AllowHref => 1,
AllowSrc => 1,
Context => 'Flow'
},
strict_names => 1,
);
my $strip = Litmus::StripScripts->new(
{
AllowHref => 1,
AllowSrc => 1,
Context => 'Document'
},
strict_names => 1,
);
###############################################################################
# Templatization Code
@@ -148,7 +148,7 @@ sub create {
$strip->parse($data);
$strip->eof();
return $strip->filtered_document();
return $strip->filtered_document;
},
# process the text with the markdown text processor
@@ -199,4 +199,4 @@ sub process {
Litmus::Auth::getCurrentUser()->is_admin() : 0;
$self->SUPER::process($template, \%vars, $outstream, @opts);
}
}