<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>t/04context.t</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -9,6 +9,7 @@ Makefile.old
 META.yml
 pm_to_blib
 t/var/mojomojo.db
+t/var/mojomojo.yml
 t/var/upload
 mojomojos.kpf
 MojoMojo-*</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -114,9 +114,9 @@ sub defang_attribs_callback {
 
         # Allow src URI's from configuration.
         my @allowed_src_regex;
-
         # Tests may not have a $c
         if ( defined $c ) {
+          
             if ( exists $c-&gt;stash-&gt;{allowed_src_regexes} ) {
                 @allowed_src_regex = @{ $c-&gt;stash-&gt;{allowed_src_regexes} };
             }
@@ -131,7 +131,10 @@ sub defang_attribs_callback {
             }
         }
         for my $allowed_src_regex (@allowed_src_regex) {
-            return 0 if $$attr_val_r =~ $allowed_src_regex;
+            if ( $$attr_val_r =~ $allowed_src_regex ) {
+                return 0;
+            }
+            
         }
 
         # When $c and src uri authority are defined we want to make sure
@@ -145,9 +148,17 @@ sub defang_attribs_callback {
                 return 1;
             }
         }
-        else {
+        # We have an authority but no context.  
+        # Probably means we're testing with just the Defang formatter 
+        # instead of the Full formatter chain.
+        # We will defang any src's left with an authority (defang_src)
+        # since the approved ones were already allowed in above.
+        elsif ( defined $src_uri_object-&gt;authority ) {
             return 1;
         }
+        else {
+            return 2;
+        }
     }
 
     return 0;</diff>
      <filename>lib/MojoMojo/Formatter/Defang.pm</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,10 @@
 #!/usr/bin/perl -w
-use Test::More tests =&gt; 26;
+use Test::More tests =&gt; 27;
 use HTTP::Request::Common;
 use Test::Differences;
+use FindBin '$Bin';
+use lib &quot;$Bin/../lib&quot;;
+use Data::Dumper;
 
 my $original_formatter
   ;    # used to save/restore whatever formatter is set up in mojomojo.db
@@ -23,6 +26,7 @@ END {
 }
 
 ( undef, $c ) = ctx_request('/');
+#warn Dumper $c-&gt;config;
 ok( $original_formatter = $c-&gt;pref('main_formatter'),
     'save original formatter' );
 
@@ -432,4 +436,12 @@ HTML
 $expected = '&lt;p&gt;&lt;img defang_src=&quot;//malicious.com/foto.jpg&quot; /&gt;&lt;/p&gt;
 '; 
 $got = get( POST '/.jsrpc/render', [ content =&gt; $content ] );
-eq_or_diff( $got, $expected, $test );
\ No newline at end of file
+eq_or_diff( $got, $expected, $test );
+
+$test    = 'remote img src allowed in .conf';
+$content = &lt;&lt;'HTML';
+&lt;p&gt;&lt;object width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/P_hTFilWY9w&amp;amp;hl=en&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/P_hTFilWY9w&amp;amp;hl=en&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
+HTML
+$expected = $content;
+$got = get( POST '/.jsrpc/render', [ content =&gt; $content ] );
+is( $got, $expected, $test );</diff>
      <filename>t/formatter_all_textile.t</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use MojoMojo::Formatter::Defang;
-use Test::More tests =&gt; 5;
+use Test::More tests =&gt; 6;
 use Test::Differences;
 
 my ( $content, $got, $expected, $test );
@@ -55,3 +55,11 @@ $content  = '&lt;img src=&quot;http://far.away.com/imatge.jpg&quot; /&gt;';
 $expected = '&lt;img defang_src=&quot;http://far.away.com/imatge.jpg&quot; /&gt;';
 MojoMojo::Formatter::Defang-&gt;format_content( \$content );
 eq_or_diff( $content, $expected, $test );
+
+$test    = 'img src local tag';
+$content = &lt;&lt;'HTML';
+&lt;img src=&quot;/.static/catalyst.png&quot; alt=&quot;Powered by Catalyst&quot; title=&quot;Powered by Catalyst&quot; /&gt;
+HTML
+$expected = $content;
+MojoMojo::Formatter::Defang-&gt;format_content( \$content );
+eq_or_diff( $content, $expected, $test );</diff>
      <filename>t/formatter_defang.t</filename>
    </modified>
    <modified>
      <diff>@@ -55,7 +55,7 @@ sub init_schema {
 
     unlink($db_file) if -e $db_file;
     mkdir($db_dir) unless -d $db_dir;
-
+    
     my $dsn = $ENV{&quot;MOJOMOJO_TEST_SCHEMA_DSN&quot;} || &quot;dbi:SQLite:${db_file}&quot;;
     my $dbuser = $ENV{&quot;MOJOMOJO_TEST_SCHEMA_DBUSER&quot;} || '';
     my $dbpass = $ENV{&quot;MOJOMOJO_TEST_SCHEMA_DBPASS&quot;} || '';
@@ -88,6 +88,9 @@ sub init_schema {
                 }
            }
         },
+               'allowed' =&gt; {
+           src =&gt; [qw(youtube.com youporn.org iusethis.com)] ,
+       },
         'View::Email' =&gt; { sender =&gt; { mailer =&gt; 'Test' } },
     };
     YAML::DumpFile('t/var/mojomojo.yml',$config);</diff>
      <filename>t/lib/MojoMojoTestSchema.pm</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>t/var/mojomojo.yml</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>2920df1f7aa4ebb75b8f08a63de42b609d982aa2</id>
    </parent>
  </parents>
  <author>
    <name>mateu x hunter</name>
    <email>hunter@missoula.org</email>
  </author>
  <url>http://github.com/marcusramberg/mojomojo/commit/48b05e51fb81f699dd3a36731da7ebffb5f88aab</url>
  <id>48b05e51fb81f699dd3a36731da7ebffb5f88aab</id>
  <committed-date>2009-06-01T16:08:26-07:00</committed-date>
  <authored-date>2009-06-01T16:08:26-07:00</authored-date>
  <message>Ease back throttle on defang src.
Test that /.static/* src are not defanged.
remove t/var/mojomojo.yml since it's created by
MojoMojoTestSchema and 01app.t.  Thank rafl
for pointing it out.</message>
  <tree>06770cb541077d60eda65d5c6c589007ea1c871a</tree>
  <committer>
    <name>mateu x hunter</name>
    <email>hunter@missoula.org</email>
  </committer>
</commit>
