From 6626bffe350a7dd3225628b800cefb9999c0ec2c Mon Sep 17 00:00:00 2001 From: "ccooper%deadsquid.com" Date: Fri, 7 Jul 2006 20:34:58 +0000 Subject: [PATCH] - 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 --- mozilla/webtools/litmus/Litmus/DB/Testcase.pm | 2 +- .../webtools/litmus/Litmus/StripScripts.pm | 43 +++++++++++++++++++ mozilla/webtools/litmus/Litmus/Template.pm | 22 +++++----- 3 files changed, 55 insertions(+), 12 deletions(-) create mode 100755 mozilla/webtools/litmus/Litmus/StripScripts.pm diff --git a/mozilla/webtools/litmus/Litmus/DB/Testcase.pm b/mozilla/webtools/litmus/Litmus/DB/Testcase.pm index 898e856977c..fc2585b8601 100755 --- a/mozilla/webtools/litmus/Litmus/DB/Testcase.pm +++ b/mozilla/webtools/litmus/Litmus/DB/Testcase.pm @@ -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'}); diff --git a/mozilla/webtools/litmus/Litmus/StripScripts.pm b/mozilla/webtools/litmus/Litmus/StripScripts.pm new file mode 100755 index 00000000000..ea4a8f5e6ac --- /dev/null +++ b/mozilla/webtools/litmus/Litmus/StripScripts.pm @@ -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 + # Zach Lipton + # + # ***** 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\-.!~*|;/?=+\$\,%#]|&){0,100})?)$>x ? $1 : undef; +} + +1; diff --git a/mozilla/webtools/litmus/Litmus/Template.pm b/mozilla/webtools/litmus/Litmus/Template.pm index f2af1f6a505..6c97b094a99 100755 --- a/mozilla/webtools/litmus/Litmus/Template.pm +++ b/mozilla/webtools/litmus/Litmus/Template.pm @@ -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); -} \ No newline at end of file +}