[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mason-cvs
Subject:    [Mason-checkins] [3822] Make HTML::Entities a required module.
From:       autarch () urth ! org
Date:       2007-04-10 18:45:40
Message-ID: E1HbLLY-0008Ub-Ft () urth ! org
[Download RAW message or body]

Revision: 3822
Author:   autarch
Date:     2007-04-10 13:45:40 -0500 (Tue, 10 Apr 2007)
ViewCVS:  https://svn.urth.org/listing.php?repname=Mason&rev=3822

Log Message:
-----------
Make HTML::Entities a required module. This simplifies our code and
tests, and really, who doesn't install HTML::Parser these days?

I can rever this if there's objections, but it does simplify things a
little bit.

Modified Paths:
--------------
    trunk/Build.PL
    trunk/Changes
    trunk/lib/HTML/Mason/Escapes.pm
    trunk/lib/HTML/Mason/Exceptions.pm
    trunk/t/06-compiler.t
    trunk/t/13-errors.t
    trunk/t/21-escapes.t
Modified: trunk/Build.PL
===================================================================
--- trunk/Build.PL	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/Build.PL	2007-04-10 18:45:40 UTC (rev 3822)
@@ -48,10 +48,10 @@
 my $build = Mason::Build->new
   ( module_name => 'HTML::Mason',
     requires    => \%prereq,
-    recommends  => { 'HTML::Entities' => 0 },
-    build_requires => { 'Module::Build' => 0.26,
-                        'Test'          => 0,
-                        'Test::Builder' => 0,
+    build_requires => { 'HTML::Entities' => 0,
+                        'Module::Build'  => 0.26,
+                        'Test'           => 0,
+                        'Test::Builder'  => 0,
                       },
     license     => 'perl',
     create_makefile_pl => 'passthrough',

Modified: trunk/Changes
===================================================================
--- trunk/Changes	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/Changes	2007-04-10 18:45:40 UTC (rev 3822)
@@ -13,6 +13,10 @@
   requested, you got a "Use of uninitialized value" warning from
   ApacheHandler in your logs. Reported by Ogden Nefix.
 
+- HTML::Entities is now a prereq. Not requiring it made for various
+  weird gyrations in the tests that didn't seem to work all the time,
+  causing various failures.
+
 [ ENHANCEMENTS ]
 
 - Added a new Compiler::ToObject parameter,

Modified: trunk/lib/HTML/Mason/Escapes.pm
===================================================================
--- trunk/lib/HTML/Mason/Escapes.pm	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/lib/HTML/Mason/Escapes.pm	2007-04-10 18:45:40 UTC (rev 3822)
@@ -11,8 +11,9 @@
 use strict;
 use warnings;
 
-use HTML::Mason::Tools qw(load_pkg);
+use HTML::Entities ();
 
+
 my %html_escape = ('&' => '&amp;', '>'=>'&gt;', '<'=>'&lt;', '"'=>'&quot;');
 my $html_escape = qr/([&<>"])/;
 
@@ -27,9 +28,6 @@
 {
     return unless defined ${ $_[0] };
 
-    load_pkg( 'HTML::Entities',
-              'HTML escaping requires the HTML::Entities module, available from CPAN.');
-
     HTML::Entities::encode_entities( ${ $_[0] } );
 }
 

Modified: trunk/lib/HTML/Mason/Exceptions.pm
===================================================================
--- trunk/lib/HTML/Mason/Exceptions.pm	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/lib/HTML/Mason/Exceptions.pm	2007-04-10 18:45:40 UTC (rev 3822)
@@ -315,8 +315,6 @@
     my $out;
     my $interp = HTML::Mason::Interp->new(out_method => \$out);
 
-    # Can't use |h escape in here because if we fail to load
-    # HTML::Entities we end up in an endless loop.
     my $comp = $interp->make_component(comp_source => <<'EOF');
 
 <%args>

Modified: trunk/t/06-compiler.t
===================================================================
--- trunk/t/06-compiler.t	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/t/06-compiler.t	2007-04-10 18:45:40 UTC (rev 3822)
@@ -59,12 +59,10 @@
 
 #------------------------------------------------------------
 
-    if ( load_pkg('HTML::Entities') )
-    {
-        $group->add_test( name => 'default_escape_flags',
-                          description => 'test that no escaping is done by default',
-                          interp_params => { use_object_files => 0 },
-                          component => <<'EOF',
+    $group->add_test( name => 'default_escape_flags',
+                      description => 'test that no escaping is done by default',
+                      interp_params => { use_object_files => 0 },
+                      component => <<'EOF',
 Explicitly HTML-escaped: <% $expr |h %><p>
 Explicitly HTML-escaped redundantly: <% $expr |hh %><p>
 Explicitly URL-escaped: <% $expr |u
@@ -76,7 +74,7 @@
 my $expr = "<b><i>Hello there</i></b>.";
 </%init>
 EOF
-                          expect => <<'EOF',
+                      expect => <<'EOF',
 Explicitly HTML-escaped: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly HTML-escaped redundantly: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly URL-escaped: %3Cb%3E%3Ci%3EHello%20there%3C%2Fi%3E%3C%2Fb%3E.<p>
@@ -84,17 +82,14 @@
 No flags again: <b><i>Hello there</i></b>.<p>
 Explicitly not escaped: <b><i>Hello there</i></b>.<p>
 EOF
-                        );
-    }
+                    );
 
 #------------------------------------------------------------
 
-    if ( load_pkg('HTML::Entities') )
-    {
-        $group->add_test( name => 'default_escape_flags_new',
-                          description => 'test new escape flags',
-                          interp_params => { use_object_files => 0 },
-                          component => <<'EOF',
+    $group->add_test( name => 'default_escape_flags_new',
+                      description => 'test new escape flags',
+                      interp_params => { use_object_files => 0 },
+                      component => <<'EOF',
 Explicitly HTML-escaped: <% $expr | h %><p>
 Explicitly HTML-escaped redundantly: <% $expr | h,h %><p>
 Explicitly URL-escaped: <% $expr |u
@@ -106,7 +101,7 @@
 my $expr = "<b><i>Hello there</i></b>.";
 </%init>
 EOF
-                          expect => <<'EOF',
+                      expect => <<'EOF',
 Explicitly HTML-escaped: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly HTML-escaped redundantly: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly URL-escaped: %3Cb%3E%3Ci%3EHello%20there%3C%2Fi%3E%3C%2Fb%3E.<p>
@@ -114,17 +109,14 @@
 No flags again: <b><i>Hello there</i></b>.<p>
 Explicitly not escaped: <b><i>Hello there</i></b>.<p>
 EOF
-                        );
-    }
+                    );
 
 #------------------------------------------------------------
 
-    if ( load_pkg('HTML::Entities') )
-    {
-        $group->add_test( name => 'default_escape_flags_2',
-                          description => 'test that turning on default escaping works',
-                          interp_params => { use_object_files => 0, default_escape_flags => 'h' },
-                          component => <<'EOF',
+    $group->add_test( name => 'default_escape_flags_2',
+                      description => 'test that turning on default escaping works',
+                      interp_params => { use_object_files => 0, default_escape_flags => 'h' },
+                      component => <<'EOF',
 Explicitly HTML-escaped: <% $expr |h %><p>
 Explicitly HTML-escaped redundantly: <% $expr |hh %><p>
 Explicitly URL-escaped: <% $expr |un
@@ -136,7 +128,7 @@
 my $expr = "<b><i>Hello there</i></b>.";
 </%init>
 EOF
-                          expect => <<'EOF',
+                      expect => <<'EOF',
 Explicitly HTML-escaped: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly HTML-escaped redundantly: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly URL-escaped: %3Cb%3E%3Ci%3EHello%20there%3C%2Fi%3E%3C%2Fb%3E.<p>
@@ -144,18 +136,15 @@
 No flags again: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly not escaped: <b><i>Hello there</i></b>.<p>
 EOF
-                        );
-    }
+                    );
 
 #------------------------------------------------------------
 
-    if ( load_pkg('HTML::Entities') )
-    {
-        $group->add_test( name => 'default_escape_flags_2_new',
-                          description => 'test that turning on default escaping works with new flags',
-                          interp_params => { use_object_files => 0,
-                                             default_escape_flags => [ 'h' ] },
-                          component => <<'EOF',
+    $group->add_test( name => 'default_escape_flags_2_new',
+                      description => 'test that turning on default escaping works with new flags',
+                      interp_params => { use_object_files => 0,
+                                         default_escape_flags => [ 'h' ] },
+                      component => <<'EOF',
 Explicitly HTML-escaped: <% $expr | h %><p>
 Explicitly HTML-escaped redundantly: <% $expr | h , h %><p>
 Explicitly URL-escaped: <% $expr | u, n
@@ -167,7 +156,7 @@
 my $expr = "<b><i>Hello there</i></b>.";
 </%init>
 EOF
-                          expect => <<'EOF',
+                      expect => <<'EOF',
 Explicitly HTML-escaped: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly HTML-escaped redundantly: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly URL-escaped: %3Cb%3E%3Ci%3EHello%20there%3C%2Fi%3E%3C%2Fb%3E.<p>
@@ -175,8 +164,7 @@
 No flags again: &lt;b&gt;&lt;i&gt;Hello there&lt;/i&gt;&lt;/b&gt;.<p>
 Explicitly not escaped: <b><i>Hello there</i></b>.<p>
 EOF
-                        );
-    }
+                    );
 
 #------------------------------------------------------------
 

Modified: trunk/t/13-errors.t
===================================================================
--- trunk/t/13-errors.t	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/t/13-errors.t	2007-04-10 18:45:40 UTC (rev 3822)
@@ -175,19 +175,16 @@
 
 #------------------------------------------------------------
 
-    if ( load_pkg('HTML::Entities') )
-    {
-        $group->add_test( name => 'check_error_format',
-                          description => 'Make sure setting error_format => "html" works',
-                          interp_params => { error_format => 'html',
-                                             error_mode => 'output',
-                                           },
-                          component => <<'EOF',
+    $group->add_test( name => 'check_error_format',
+                      description => 'Make sure setting error_format => "html" works',
+                      interp_params => { error_format => 'html',
+                                         error_mode => 'output',
+                                       },
+                      component => <<'EOF',
 % die("Horrible death");
 EOF
-                          expect => qr{^\s+<html>.*Horrible death}is,
-                        );
-    }
+                      expect => qr{^\s+<html>.*Horrible death}is,
+                    );
 
 #------------------------------------------------------------
 
@@ -197,7 +194,7 @@
 % $m->subexec("/does/not/exist");
 EOF
                       expect_error => qr{could not find component for initial path}is,
-                      );
+                    );
 
 #------------------------------------------------------------
 

Modified: trunk/t/21-escapes.t
===================================================================
--- trunk/t/21-escapes.t	2007-04-08 23:14:21 UTC (rev 3821)
+++ trunk/t/21-escapes.t	2007-04-10 18:45:40 UTC (rev 3822)
@@ -4,18 +4,11 @@
 
 use Test::More;
 
-BEGIN
-{
-    unless ( eval { require HTML::Entities; 1 } )
-    {
-        plan skip_all => 'These tests require HTML::Entities to run.';
-    }
-}
-
 use HTML::Mason::Escapes;
 
 plan tests => 3;
 
+
 my $html = qq|<>"& \x{2202}|;
 HTML::Mason::Escapes::basic_html_escape( \$html );
 is( $html, "&lt;&gt;&quot;&amp; \x{2202}",




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-checkins mailing list
Mason-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-checkins
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic