[interchange-cvs] interchange - heins modified lib/Vend/Interpolate.pm

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Wed Oct 10 20:24:00 2001


User:      heins
Date:      2001-10-11 00:23:38 GMT
Modified:  lib/Vend Tag: STABLE_4_8-branch Interpolate.pm
Log:
     * Add restrict_html filter which allows only passed tags to be
       used. Called with:

            [filter restrict_html.a.b.i.u.blockquote.li.ol.ul.p]
                <A HREF="junk.html"> this </A>
                        <SCRIPT> Some stuff </SCRIPT>
            [/filter]

		Outputs:

				<A HREF="junk.html"> this </A>
						&lt;SCRIPT> Some stuff &lt;/SCRIPT>

Revision  Changes    Path
No                   revision



No                   revision



2.9.2.4   +12 -2     interchange/lib/Vend/Interpolate.pm


rev 2.9.2.4, prev_rev 2.9.2.3
Index: Interpolate.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.9.2.3
retrieving revision 2.9.2.4
diff -u -r2.9.2.3 -r2.9.2.4
--- Interpolate.pm	2001/10/09 19:23:36	2.9.2.3
+++ Interpolate.pm	2001/10/11 00:23:38	2.9.2.4
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.9.2.3 2001/10/09 19:23:36 racke Exp $
+# $Id: Interpolate.pm,v 2.9.2.4 2001/10/11 00:23:38 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -27,7 +27,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.9.2.3 $, 10);
+$VERSION = substr(q$Revision: 2.9.2.4 $, 10);
 
 @EXPORT = qw (
 
@@ -1148,6 +1148,16 @@
 	loc => sub {
 					my $val = shift;
 					return ::errmsg($val);
+				},
+
+	restrict_html => sub {
+					my $val = shift;
+					shift;
+					my %allowed;
+					@allowed{@_} = @_;
+					$val =~ s{<(/?(\w[-\w]*)[\s>])}
+						     { ($allowed{lc $2} ? '<' : '&lt;') . $1 }ge;
+					return $val;
 				},
 
 	);