For a complete introduction to Interchange filters, please see the filter glossary entry.
Table of Contents
acl2hash — convert Interchange ACL string to a Perl hash representation
The filter is specific to the ACL widget and probably should not be used otherwise.
The filter doesn't need to be selected for the widget to
operate in the table-editor
.
Interchange 5.9.0:
Source: code/Filter/acl2hash.filter
Lines: 34
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: acl2hash.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $ CodeDef acl2hash Filter CodeDef acl2hash Description acl2hash CodeDef acl2hash Visibility private CodeDef acl2hash Routine <<EOR sub { my ($value) = @_; my $orig = $value; $value =~ s/^[\s,\0]+//; $value =~ s/[\s,\0]+$//; return $value if $value =~ /^\{.*\}$/s; $value =~ s/\0//g; my $hash = Vend::Util::get_option_hash($value) or return '{}'; my @del; while(my ($k, $v) = each %$hash) { push @del, $k if $v =~ /d/; push @del, $k if ! length($k); } delete @{$hash}{@del} if @del; my $out = ::uneval_it($hash); return $out; } EOR
alpha — eliminate non-alpha characters
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/alpha.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: alpha.filter,v 1.7 2007-08-20 21:11:09 jon Exp $ CodeDef alpha Filter CodeDef alpha Description A-Za-z only CodeDef alpha Help Returns only ASCII alphabetic characters (A-Z and a-z) CodeDef alpha Routine <<EOR sub { my $val = shift; $val =~ s/[^A-Za-z]+//g; return $val; } EOR
alphanumeric — eliminate non-alphanumeric characters
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/alphanumeric.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: alphanumeric.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef alphanumeric Filter CodeDef alphanumeric Description A-Za-z0-9 only CodeDef alphanumeric Routine <<EOR sub { my $val = shift; $val =~ s/[^A-Za-z0-9]+//g; return $val; } EOR
backslash — eliminate backslashes
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/backslash.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: backslash.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef backslash Filter CodeDef backslash Description Strip backslash CodeDef backslash Routine <<EOR sub { my $val = shift; $val =~ s/\\+//g; return $val; } EOR
bold — enclose input in HTML <b> (bold) tag
Example: Filter example
"[filter bold]To Boldly Go Where No One Has Gone Before![/filter]" -- Star Trek
Interchange 5.9.0:
Source: code/Filter/bold.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: bold.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef bold Filter CodeDef bold Description HTML bold CodeDef bold Routine <<EOR sub { return '<b>' . shift(@_) . '</b>'; } EOR
cgi — expand to value of the CGI variable specified in body
The filter expands to the value of a CGI variable. Name of the variable is specified in filter body.
Example: Filter example
[cgi name=online_cgi_test set="TEST VALUE" hide=1] My test value is [filter cgi]online_cgi_test[/filter]
Interchange 5.9.0:
Source: code/Filter/cgi.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: cgi.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef cgi Filter CodeDef cgi Description Get CGI value of variable CodeDef cgi Routine <<EOR sub { return $CGI::values{$_[0]}; } EOR
checkbox — return user-supplied value if its length is 1 or more, an empty string otherwise
The filter checks for the length of input. When the length of input is non-zero, the filter returns input itself. When the length is zero, the filter returns an empty string.
The filter is suitable for retrieving values out of HTML checkboxes.
Interchange 5.9.0:
Source: code/Filter/checkbox.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: checkbox.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $ CodeDef checkbox Filter CodeDef checkbox Routine <<EOR sub { my $val = shift; return length($val) ? $val : ''; } EOR
colons_to_null — replace double colons "::" with \0 (null) character
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/colons_to_null.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: colons_to_null.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef colons_to_null Filter CodeDef colons_to_null Description :: to NULL CodeDef colons_to_null Routine <<EOR sub { my $val = shift; $val =~ s/::/\0/g; return $val; } EOR
commify — add thousands separator to a number, and trim to specified number of decimal places
The filter adds a thousands separator to a number, and trims decimal places to a specified maximum length.
Example: Filter example
[set online_commify_test]1234567890.123456[/set] [filter op=commify.2 interpolate=1][scratchd online_commify_test][/filter]
Interchange 5.9.0:
Source: code/Filter/commify.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef commify Filter CodeDef commify Description Commify CodeDef commify Routine <<EOR sub { my ($val, $tag, $places) = @_; $places = 2 unless defined $places; $val = sprintf("%.${places}f", $val) if defined $places; return Vend::Util::commify($val); } EOR
compress_space — eliminate leading and trailing whitespace and compress all "in-string" whitespace occurrences to exactly 1 space each
The filter eliminates leading and trailing whitespace, and compresses all occurrences of whitespace in a string to exactly 1 space on each occurrence.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/compress_space.filter
Lines: 21
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: compress_space.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef compress_space Filter CodeDef compress_space Description Collapse whitespace CodeDef compress_space Routine <<EOR sub { my $val = shift; $val =~ s/\s+$//g; $val =~ s/^\s+//g; $val =~ s/\s+/ /g; return $val; } EOR
convert_date — convert date to a specified format
The filter calls convert-date
to output date according to the
specified format string.
For the accepted formats in which the input date needs to be specified,
see convert-date
.
See time glossary entry for a list and description of format specifiers.
Example: Filter example
[filter convert_date."%B %e, %Y"][time][/filter].
This filter looks almost exactly like the convert-date
tag,
but there's a simple difference in the implementation.
convert-date
tag called with an empty
or invalid time string it will default to the current
time; this filter called with an empty or invalid time string
will default to an empty value.
Interchange 5.9.0:
Source: code/Filter/convert_date.filter
Lines: 26
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: convert_date.filter,v 1.7 2007-03-30 23:40:44 pajamian Exp $ CodeDef convert_date Filter CodeDef convert_date Description Convert date CodeDef convert_date Visibility private CodeDef convert_date Routine <<EOR sub { my $time = shift(@_); # Don't convert nothing to something return '' unless $time; shift(@_); my $fmt = shift(@_); while(my $add = shift(@_)) { $fmt .= " $add"; } return $Tag->convert_date({ fmt => $fmt, body => $time}); } EOR
crypt — run Unix crypt() function on input data
Example: Filter example with random salt
Encrypted string TEST
with random salt is:
[filter crypt]TEST[/filter].
Example: Filter example with hand-specified salt
Encrypted stringTEST
with salt ofAB
is: [filter crypt.AB]TEST[/filter].
Interchange 5.9.0:
Source: code/Filter/crypt.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: crypt.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $ CodeDef crypt Filter CodeDef crypt Description Crypt CodeDef crypt Routine <<EOR sub { my ($val, $tag, $salt) = @_; return crypt($val, $salt ? $salt : random_string(2)); } EOR
currency — format number as currency, honoring default or specified locale
The filter formats input number as a currency. All currency-related options and default locale are honored, and a specific locale can also be set as well.
Example: Displaying a value in specific locale formatted as a currency
[filter currency.fr_FR]40.2[/filter]
Interchange 5.9.0:
Source: code/Filter/currency.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: currency.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef currency Filter CodeDef currency Description Currency CodeDef currency Routine <<EOR sub { my ($val, $tag, $locale) = @_; my $convert = $locale ? 1 : 0; return Vend::Util::currency($val, 0, $convert, { locale => $locale }); } EOR
date2time — convert date (possibly with specified time) to number of seconds since Epoch
The filter replaces date specification in form of
MM
[/-]DD
[/-]YY(YY)?
(:hh
(mm
)?)?
to a number of seconds since epoch.
If the year specification contains 2 digits only and is less than
50
, as is say, 02
,
then it is treated as an offset from year 2000
, and not
1900
. In other words, 05
is understood
as year 2005
, 80
is understood as
1980
.
Unspecified month or day default to 1
, unspecified
hours or minutes default to 0
.
Example: Converting dates and times to seconds since Epoch
[filter date2time]01/01/2005[/filter] [filter date2time]01/01/05[/filter] [filter date2time]01-01-2005[/filter] [filter date2time]01-01-05[/filter] [filter date2time]01-01-2005:10[/filter] [filter date2time]01-01-05:1045[/filter]
This filter is considered deprecated, and is replaced by <filter>datetime2epoch</filter>.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The timelocal()
function used in the filter comes from the
Time::Local
Perl module.
Interchange 5.9.0:
Source: code/Filter/date2time.filter
Lines: 50
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: date2time.filter,v 1.6 2007-03-30 23:40:44 pajamian Exp $ CodeDef date2time Filter CodeDef date2time Description Date to UNIX time (deprecated - use datetime2epoch instead) CodeDef date2time Visibility private CodeDef date2time Routine <<EOR sub { my $val = shift; use Time::Local; $val =~ s/\0+//g; if($val =~ m:(\d+)[-/]+(\d+)[-/]+(\d+):) { my ($yr, $mon, $day) = ($3, $1, $2); my $time; $val =~ /:(\d+)$/ and $time = $1; if(length($yr) < 4) { $yr =~ s/^0//; $yr = $yr < 50 ? $yr + 2000 : $yr + 1900; } $mon =~ s/^0//; $day =~ s/^0//; $val = sprintf("%d%02d%02d", $yr, $mon, $day); return $val unless $time; $val .= sprintf('%04d', $time); } my $time; $val =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)?(\d\d)?/; my ($yr, $mon, $day, $hr, $min) = ($1 || 0, $2 || 1, $3 || 1, $4 || 0, $5 || 0); $mon--; eval { $time = timelocal(0, $min, $hr, $day, $mon, $yr); }; if($@) { logError("bad time value passed to date2time: %s", $@); return 0; } return $time; } EOR
date_change — convert MMDDYYYY date (possibly with specified time) to YYYYMMDDhhmm
The filter replaces date specification in form of
MM
[/-]DD
[/-]YY(YY)?
(:hh
(mm
)?)?
or
YYYY
[/-]MM
[/-]DD
(:hh
(mm
)?)?
to
.
YYYYMMDD
((hh
)?(mm
)?)?
If the year specification contains 2 digits only and is less than
50
, as is say, 02
,
then it is treated as an offset from year 2000
, and not
1900
. In other words, 05
is understood
as year 2005
, 80
is understood as year
1980
.
Time specification unspecified in input get omitted from output as well.
The filter optionally accepts three arguments:
iso
- output date in ISO format
undef
- don't default to current date if no date is specified
no_time
- output only date, without time portion
Example: Using date_change
[filter date_change]2005-01-01[/filter] [filter date_change]2005/01/01[/filter] [filter date_change]2005-01-01:10[/filter] [filter date_change]2005/05/29:1536[/filter] [filter date_change]05-29-2005:1536[/filter] [filter date_change]05-29-05:1536[/filter] [filter date_change]0000-00-00[/filter] [filter date_change][/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The filter is most commonly used with date selection fields.
If only two out of four time digits are specified, then due to the operation
of the sprintf()
function, they tend to indicate minutes
and not hours!
When the input data starts with year specification, the year must have
4-digit format (i.e. 2005
and
not just 05
)!
If the date is empty, the filter defaults to current date. To
force an absence of a date (as required by some SQL databases),
use the undef
filter option.
Interchange 5.9.0:
Source: code/Filter/date_change.filter
Lines: 84
# Copyright 2002-2016 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef date_change Filter CodeDef date_change Description Date widget CodeDef date_change Routine <<EOR sub { my $val = shift; shift; # discard tag my $opt = { map { $_ => 1 } @_ }; HTML::Entities::decode_entities($val) if $val =~ /&/; $val =~ s/\0+//g; my $re = $opt->{undef} ? qr:^(\d*)[-/]+(\d*)[-/]+(\d*)(.*)$: : qr:^(\d+)[-/]+(\d+)[-/]+(\d+)(.*)$: ; return $val unless $val =~ /$re/; my ($year, $month, $day, $timeval); if (length($1) == 4) { # ISO date style 2003-03-20 ($year, $month, $day) = ($1, $2, $3); } else { # U.S. date style 3/20/2003 or 3/20/03 ($year, $month, $day) = ($3, $1, $2); } $timeval = $4; if ($opt->{undef}) { # return nothing (undef, which DBI treats as SQL NULL) for an # empty date (all zeroes or nothing at all) return unless grep /[1-9]/, ($year, $month, $day); } # Y2K fun: Try to guess intent of year "03" as "2003" if (length($year) < 4) { $year = $year < 50 ? $year + 2000 : $year + 1900; } my ($date_format, $time_format); if ($opt->{iso}) { $date_format = '%04d-%02d-%02d'; $time_format = 'T%02d:%02d:%02d'; } elsif ($opt->{common}) { $date_format = '%04d-%02d-%02d'; $time_format = ' %02d:%02d:%02d'; } else { $date_format = '%04d%02d%02d'; $time_format = '%02d%02d'; } my $time; if ($timeval =~ /^:(\d{1,4})\s*$/) { # accept traditional Interchange date_time widget times # of format '0130', e.g. '20080201:0130' $time = sprintf('%04d', $1); $time = sprintf($time_format, substr($time, 0, 2), substr($time, 2, 2)); } elsif ( # accept times of format '1:30', '1:30:05', # to support PostgreSQL's timestamp with time zone format # e.g. '2008-02-01 01:30:05-07' my ($hours, $minutes, $seconds) = ($timeval =~ /\s(\d\d?):(\d\d?)(?::(\d\d+))/) ) { $time = sprintf($time_format, $hours, $minutes, $seconds); } my $out = sprintf($date_format, $year, $month, $day); $out .= $time if $time and not $opt->{no_time}; return $out; } EOR
datetime2epoch — convert date (possibly with specified time) to number of seconds since Epoch
The filter replaces date specification with optional time, in format of
, orMM
[/-]DD
[/-]YY(YY)?
(:hh
(:?mm
(:ss
)?)?)?
YYYY
-MM
-DD
([T
]hh
(:mm
(:ss
)?)?)?
to a number of seconds since Unix epoch.
If the year specification contains 2 digits only and is less than
50
, then it is treated as an offset from year
2000
, and not 1900
.
In other words, 05
is understood
as year 2005
,
80
is understood as
1980
.
Unspecified month or day default to 01
, unspecified
hours or minutes default to 00
.
Example: Converting dates and times to seconds since Epoch
[filter datetime2epoch]01/01/2008[/filter] [filter datetime2epoch]01/01/08[/filter] [filter datetime2epoch]01-01-2008[/filter] [filter datetime2epoch]01-01-08[/filter] [filter datetime2epoch]01-01-2008:10[/filter] [filter datetime2epoch]01-01-08:10:45[/filter] [filter datetime2epoch]01-01-08:10:45:00[/filter]
Example: Converting ISO/MySQL dates and times to seconds since Epoch
[filter datetime2epoch]2008-01-01 10[/filter] [filter datetime2epoch]2008-01-01 10:45[/filter] [filter datetime2epoch]2008-01-01 10:45:00[/filter]
This filter is designed to replace <filter>date2time</filter>, which can be considered deprecated.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The timelocal()
function used in the filter comes from the
Time::Local
Perl module.
Interchange 5.9.0:
Source: code/Filter/datetime2epoch.filter
Lines: 46
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: datetime2epoch.filter,v 1.2 2007-03-30 23:40:44 pajamian Exp $ CodeDef datetime2epoch Filter CodeDef datetime2epoch Description Date and optional time to seconds since the UNIX Epoch CodeDef datetime2epoch Routine <<EOR sub { use Time::Local; my ($year, $mon, $day, $hr, $min, $sec, $time); my $val = shift; $val =~ s/\0+//g; $val =~ m%^\s*(\d\d)[-/]+(\d+)[-/]+(\d+)% and do { ($year, $mon, $day) = ($3, $1, $2); $val =~ /:(\d\d):?(\d\d)?:?(\d\d)?\s*$/ and $time = sprintf('T%02d:%02d:%02d', $1, $2 || 0, $3 || 0); if (length($year) < 4) { $year =~ s/^0//; $year = $year < 50 ? $year + 2000 : $year + 1900; } $val = sprintf('%d-%02d-%02d%s', $year, $mon || 1, $day || 1, $time); }; $val =~ /^\s*(\d\d\d\d)-(\d\d)-(\d\d)(?:[T\s](\d\d)?(?::(\d\d)?(?::(\d\d)?)?)?)?/; ($year, $mon, $day, $hr, $min, $sec) = ($1, $2, $3, $4 || 0, $5 || 0,$6 || 0); eval { $time = timelocal($sec, $min, $hr, $day, --$mon, $year); }; if ($@) { logError("bad time value passed to datetime2epoch: %s", $@); return 0; } return $time; } EOR
dbi_quote — safely quote strings for use in SQL statements using DBI's quote method
This filter uses the Perl DBI quoting method (or actually the DBD, if it redefines it) to make strings safe for use in SQL commands.
All database-specific needs are honored, including (but not limited
to) \
escapes for PostgreSQL or MySQL,
truncating at the first ASCII NUL for PostgreSQL, and turning a newline into a
literal two-character \n
for MySQL.
The default database handle is used (the first ProductFiles
database),
unless a different one is specified.
Example: Quoting a literal string, specifying DBI quote method
[filter dbi_quote.DATABASE_NAME]some string \ or other[/filter]
The above would produce 'some string \\ or other'
for MySQL or PostgreSQL, and
'some string \ or other'
for Oracle.
Example: Quoting for the $Db query method
ActionMap set <<EOR sub { my ($action, $name) = split('/', shift, 2); my ($val, $set); # lookup code first $Tag->perl({tables => 'sets'}); $val = $Tag->filter({op => 'dbi_quote.sets', body => $name}); $set = $Db{sets}->query({sql => "select code,description from sets where name = $val"}); ... } EOR
DBI quoting is different from Interchange's native <filter>sql</filter> filter. See the DBI man page details about the DBI quoting method.
Since the filter uses database handles, safe must be considered if
it is being used via the $Tag
object in a Perl block.
For more information see DBI(3) and the DBD documentation for your database.
Interchange 5.9.0:
Source: code/Filter/dbi_quote.filter
Lines: 26
# Copyright 2005-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: dbi_quote.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $ CodeDef dbi_quote Filter CodeDef dbi_quote Description SQL quoting using DBI CodeDef dbi_quote Routine <<EOR sub { my ($val, $tag, $table) = @_; $table ||= $Vend::Cfg->{ProductFiles}[0]; my $db; unless ($db = dbref($table)) { ::logError("filter dbi_quote cannot find database handle for table '%s'", $table); return; } return $db->quote($val); } EOR
decode_entities — decode encoded HTML characters back to their unencoded representation
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The filter is most commonly used as pre_filter
in
mv_metadata entries, for fields that contain
characters from a character set other than iso8859-1.
For example, & is replaced with &, < with < etc.
Interchange 5.9.0:
Source: code/Filter/decode_entities.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: decode_entities.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef decode_entities Filter CodeDef decode_entities Description Decode HTML entities CodeDef decode_entities Routine <<EOR sub { return HTML::Entities::decode(shift); } EOR
digits — eliminate non-digit characters
The filter eliminates any non-digit characters (that is, anything that's not
in 0-9
range).
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/digits.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: digits.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef digits Filter CodeDef digits Description Digits only CodeDef digits Routine <<EOR sub { my $val = shift; $val =~ s/\D+//g; return $val; } EOR
digits_dash — eliminate non-digit characters, with the exception of dashes
The filter eliminates any non-digit characters, except dashes. (That is,
anything that's not a dash ("-
") or
in a 0-9
range).
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/digits_dash.filter
Lines: 19
# Copyright 2008 Interchange Development Group # Copyright 2008 Davor Ocelic # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: digits_dash.filter,v 1.1 2008-04-27 17:37:10 docelic Exp $ CodeDef digits_dash Filter CodeDef digits_dash Description Digits-dashes CodeDef digits_dash Routine <<EOR sub { my $val = shift; $val =~ s/[^\d-]+//g; return $val; } EOR
digits_dot — eliminate non-digit characters, with the exception of dots
The filter eliminates any non-digit characters, except dots. (That is,
anything that's not a dot (".
") or
in a 0-9
range).
Example: Filter example
[filter digits_dot]Only the date should come out, and it is 01.01.2000[/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/digits_dot.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: digits_dot.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef digits_dot Filter CodeDef digits_dot Description Digits-dots CodeDef digits_dot Routine <<EOR sub { my $val = shift; $val =~ s/[^\d.]+//g; return $val; } EOR
dos — convert UNIX or Max ASCII text to DOS format
convert UNIX or Mac ASCII newlines to DOS format.
Unix uses LF (Line feed: \n) sequence to identify a newline.
DOS uses CRLF (Carriage return/Line feed: \r\n) sequence to identify a newline.
Mac uses CR (Carriage return: \r) sequence to identify a newline.
Example: Filter example
[filter dos] Input text with Unix newlines Input text with DOS newlines Input text with Max newlines [/filter]
Interchange 5.9.0:
Source: code/Filter/dos.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: dos.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef dos Filter CodeDef dos Description UNIX to DOS newlines CodeDef dos Routine <<EOR sub { my $val = shift; $val =~ s/\r?\n/\r\n/g; return $val; } EOR
duration — calculate end date from given start date and duration
Example: Obtaining an end date string
[cgi name=start_date set=200502120800 hide=1] [cgi name=length set="12 hours" hide=1] [filter op=duration.start_date.length /]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The timelocal()
function used in the filter comes from the
Time::Local
Perl module.
Interchange 5.9.0:
Source: code/Filter/duration.filter
Lines: 76
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: duration.filter,v 1.7 2009-05-01 13:50:00 pajamian Exp $ CodeDef duration Filter CodeDef duration Description Duration CodeDef duration Routine <<EOR sub { my ($val, undef, $startvar, $durvar, @extra) = @_; ## Accepts two parameters, the name of the CGI variables which ## hold the start date/time and the duration value. With this: # # [cgi name=start_date set=200502120800] # [cgi name=length set="12 hours"] # [filter op=duration.start_date.length /] # # The filter call will return 20050212200000 # ## Can also be used like this, with the same output: # # [filter duration.-dummy.12.hours]200502120800[/filter] # use vars qw/$CGI/; my $start = $CGI->{$startvar} || $val; my $durstring = $CGI->{$durvar}; use Time::Local; if (!length($durstring) && $durvar =~ /^\d+$/) { $durstring = join(' ', $durvar, @extra); } ## Want to allow setting the value directly return $val unless $durstring; $start =~ s/\0+//g; if($start =~ m:(\d+)[-/]+(\d+)[-/]+(\d+):) { my ($yr, $mon, $day) = ($3, $1, $2); my $time; $start =~ /:(\d+)$/ and $time = $1; if(length($yr) < 4) { $yr =~ s/^0//; $yr = $yr < 50 ? $yr + 2000 : $yr + 1900; } $mon =~ s/^0//; $day =~ s/^0//; $start = sprintf("%d%02d%02d", $yr, $mon, $day); return $val unless $time; $start .= sprintf('%04d', $time); } my $time; $start =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)?(\d\d)?/; my ($yr, $mon, $day, $hr, $min) = ($1 || 0, $2 || 1, $3 || 1, $4 || 0, $5 || 0); $mon--; eval { $time = timelocal(0, $min, $hr, $day, $mon, $yr); }; if($@) { logError("bad time value passed to duration filter: %s", $@); return 0; } $time = adjust_time($durstring, $time); return POSIX::strftime("%Y%m%d%H%M%S", localtime($time)); } EOR
encode_entities — encode non-standard HTML characters
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The filter is most commonly used to make untrusted CGI input variables harmless to the Interchange environment.
For example, & is replaced with &, < with < etc.
Interchange 5.9.0:
Source: code/Filter/encode_entities.filter
Lines: 23
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: encode_entities.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $ CodeDef e Filter CodeDef e Alias encode_entities CodeDef entities Filter CodeDef entities Alias encode_entities CodeDef encode_entities Filter CodeDef encode_entities Description Encode HTML entities CodeDef encode_entities Routine <<EOR sub { return HTML::Entities::encode(shift, $ESCAPE_CHARS::std); } EOR
encode_special_entities
Interchange 5.9.0:
Source: code/Filter/encode_special_entities.filter
Lines: 21
# Copyright 2010 Interchange Development Group # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef encode_special_entities Filter CodeDef encode_special_entities Description Encode HTML special entities "&<> CodeDef encode_special_entities Routine <<EOR sub { my $val = shift; $val =~ s/"/"/g; $val =~ s/&/&/g; $val =~ s/</</g; $val =~ s/>/>/g; return $val; } EOR
encrypt — PGP-encrypt input
The filter PGP-encrypts the provided input.
It accepts two optional arguments, encryption key and encryption program.
Specifying command line options for the encryption program isn't possible, but it isn't needed as Interchange automatically adds the following options, depending on the program recognized:
gpg --batch --always-trust -e -a -r
KEY
pgpe -fat -r
KEY
pgp -fat -
KEY
Example: Filter example using specific key ID
[filter encrypt.KEY]Secret phrase or a credit card number[/filter]
Example: Filter example using specific key ID and encrypt program
[filter encrypt.KEY./usr/local/bin/gpg]Secret phrase or a credit card number[/filter]
Interchange 5.9.0:
Source: code/Filter/encrypt.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: encrypt.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $ CodeDef encrypt Filter CodeDef encrypt Description PGP encrypt CodeDef encrypt Routine <<EOR sub { my ($val, $tag, $key) = @_; return Vend::Order::pgp_encrypt($val, $key); } EOR
filesafe — make sure the input is ready for use as a filename
The filter makes sure (possibly by intervening) that the input string is ready and safe to be used as a filename.
Example: Filter example
[filter filesafe]/tmp/uploads/new_world_through_chemistry/new_world_through_chemistry_edit.mp4[/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/filesafe.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: filesafe.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef filesafe Filter CodeDef filesafe Description Safe for filename CodeDef filesafe Routine <<EOR sub { return Vend::Util::escape_chars(shift); } EOR
filter_select — automatically select filter based on HTML widget type
The filter identifies the widget type and returns the name of the corresponding suitable filter for it.
Keep in mind that you can specify <filter>filter_select</filter> along with your custom filters in the same call.
Interchange 5.9.0:
Source: code/Filter/filter_select.filter
Lines: 32
# Copyright 2005-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: filter_select.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $ CodeDef calculated Filter CodeDef calculated Alias filter_select CodeDef filter_select Filter CodeDef filter_select Description Auto-select filter CodeDef filter_select Visibility private CodeDef filter_select Version $Revision: 1.3 $ CodeDef filter_select Routine <<EOR sub { ## This replaces the calculated filter for the survey ## Selects an appropriate filter based on the widget type my $wid = $CGI->{type}; if($wid =~ /fillin/) { return 'nullselect'; } elsif($wid =~ /select.*multip/) { return 'null_to_comma'; } elsif ($wid =~ /checkbox/) { return 'checkbox null_to_comma'; } return ''; } EOR
gate — return input verbatim if the specified Scratch variable exists, empty string otherwise
The filter allows "conditional output" of the input string, based on the value of a scratch variable.
In other words, received input is passed through verbatim, if the specified scratch variable holds a true value. Empty string is returned otherwise.
Interchange 5.9.0:
Source: code/Filter/gate.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: gate.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef gate Filter CodeDef gate Description Gate with scratch CodeDef gate Routine <<EOR sub { my ($val, $var) = @_; return '' unless $::Scratch->{$var}; return $val; } EOR
hash2acl — convert Interchange ACL hash to string representation
The filter is specific to the ACL widget and probably should not be used otherwise.
The filter doesn't need to be selected for the widget to
operate in the table-editor
.
Interchange 5.9.0:
Source: code/Filter/hash2acl.filter
Lines: 34
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: hash2acl.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $ CodeDef hash2acl Filter CodeDef hash2acl Description hash2acl CodeDef hash2acl Visibility private CodeDef hash2acl Routine <<EOR sub { my ($value) = @_; my $orig = $value; $value =~ s/^\s+//; $value =~ s/\s+$//; $value =~ s/\0+//g; my $hash = Vend::Util::get_option_hash($value) or return $orig; my @opts; for(sort keys %$hash) { ! defined $hash and $hash->{$_} = ''; my $val = $_; $val =~ s/,/,/g; $val =~ s/=/=/g; push @opts, "$val=$hash->{$_}"; } $value = join ",", @opts; return $value; } EOR
hmac_sha1_hex
Interchange 5.9.0:
Source: dist/strap/config/hmac_sha1_hex.filter
Lines: 9
CodeDef hmac_sha1_hex Filter CodeDef hmac_sha1_hex Description hmac_sha1_hex hashing CodeDef hmac_sha1_hex Routine <<EOR use Digest::SHA; sub { my ($val, undef, $key) = @_; return Digest::SHA::hmac_sha1_hex($val, $key); } EOR
html2text — transform basic HTML input to plain-text
The filter performs simple replacement of input HTML —
it strips the
<b>
,
<i>
and
<u>
tags, and replaces
line breaks (<br>
) and
paragraphs (<p>
)
with newlines.
Example: Filter example
[filter html2text] <p> Perl is <b>a lot</b> of <u>fun</u>! </p> <p> Interesting tricks with <i>the language</i> can be seen at: <br> MJD's <a href="http://perl.plover.com/">plover.com</a>. </p> <p> Programming is an art. </p> [/filter]
Support for stripping
<b>
,
<i>
and
<u>
tags was added
in Interchange 5.5.2.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/html2text.filter
Lines: 18
# Copyright 2002-2009 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef html2text Filter CodeDef html2text Description Simple html2text CodeDef html2text Routine <<EOR sub { my $val = shift; $val =~ s%\s*<(?:br\s*/?|/?p[^>]*)>\s*%\n%gi; $val =~ s%<[/!a-zA-Z].*?>%%gs; return $val; } EOR
integer — return integer value of the input
Example: Erase whitespace, filter out non-digits, and return integer part of the number
The whole is: [filter op="no_white digits_dot integer"]Stock 904.82[/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/integer.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: integer.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef integer Filter CodeDef integer Description Integer CodeDef integer Routine <<EOR sub { return int(shift); } EOR
italics — enclose input in HTML <i> (italic) tag
Example: Filter example
"[filter italics]To Italicly Go Where No One Has Gone Before![/filter]" -- Modified Star Trek ;-)
Interchange 5.9.0:
Source: code/Filter/italics.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: italics.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $ CodeDef italics Filter CodeDef italics Description HTML Italics CodeDef italics Visibility private CodeDef italics Routine <<EOR sub { return '<i>' . shift(@_) . '</i>'; } EOR
large — enclose input in HTML <large> tag
Interchange 5.9.0:
Source: code/Filter/large.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: large.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $ CodeDef large Filter CodeDef large Description HTML large CodeDef large Visibility private CodeDef large Routine <<EOR sub { return '<large>' . shift(@_) . '</large>'; } EOR
last_non_null — return last non-null entry from an input consisting of null-separated fields
The filter splits the input on a null character (\0
)
and returns the last non-null entry.
Example: Filter example
[perl] $Tag->filter({ op => 'last_non_null', body => "One\0Two\0Three\0\0\0" }); [/perl]
Interchange 5.9.0:
Source: code/Filter/last_non_null.filter
Lines: 21
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: last_non_null.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef last_non_null Filter CodeDef last_non_null Description Reverse combo CodeDef last_non_null Routine <<EOR sub { my @some = reverse split /\0+/, shift; for(@some) { return $_ if length $_; } return ''; } EOR
lc — transform all input to lowercase
Example: Filter example
[filter lc]YOU ARE KINDLY INVITED TO <a href="http://www.j-walk.com/other/conf/">The 3rd Annual Nigerian EMail Conference</a>. [/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/lc.filter
Lines: 24
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: lc.filter,v 1.7 2007-03-30 23:40:44 pajamian Exp $ CodeDef lower Filter CodeDef lower Alias lc CodeDef lc Filter CodeDef lc Description Lower case CodeDef lc Routine <<EOR sub { use locale; if ($Scratch->{mv_locale}) { POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale}); } return lc(shift); } EOR
lcfirst — transform first character in input to lowercase
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/lcfirst.filter
Lines: 20
# Copyright 2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: lcfirst.filter,v 1.1 2007-07-13 08:22:47 racke Exp $ CodeDef lcfirst Filter CodeDef lcfirst Description First character lower case CodeDef lcfirst Routine <<EOR sub { use locale; if ($Scratch->{mv_locale}) { POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale}); } return lcfirst(shift); } EOR
line — output just the first line of input
Example: Filter example
[filter line]Line 1 (visible) Line 2 (not visible) Line 3 (not visible) [/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/line.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: line.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $ CodeDef line Filter CodeDef line Description First line CodeDef line Routine <<EOR sub { my $val = shift; $val =~ s/^(.*?)\r?\n.*$/$1/s; return $val; } EOR
line2options — replace newlines in input with commas
The filter replaces newlines in input (any combination of
\r
and \n
) with commas.
It also takes care of removing trailing whitespace along the way.
Interchange 5.9.0:
Source: code/Filter/line2options.filter
Lines: 27
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: line2options.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef line2options Filter CodeDef line2options Description line2options CodeDef line2options Routine <<EOR sub { my ($value, $tag, $delim) = @_; return $value unless length $value; $value =~ s/\s+$//; $value =~ s/^\s+//; my @opts = split /[\r\n]+/, $value; for(@opts) { s/^\s+//; s/[,\s]+$//; s/,/,/g; } return join ",", @opts; } EOR
linkdecode — decode hex-encoded entities found within URLs
The filter decodes hex-encoded entities found within URLs.
The filter is explicitly called linkdecode
because it
only operates on <form action=>
,
href=
and src=
contents.
Therefore, it is likely to be useful only when passed lines containing
HTML URLs or source specifiers (such as <a> or <img> tags).
Interchange 5.9.0:
Source: code/Filter/linkdecode.filter
Lines: 25
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: linkdecode.filter,v 1.6 2007-03-30 23:40:44 pajamian Exp $ CodeDef linkdecode Filter CodeDef linkdecode Description URLdecode link text CodeDef linkdecode Visibility private CodeDef linkdecode Routine <<EOR sub { my $body = shift; $body =~ s{(<form\s+[^>]*action=)(["'])(\%5b\w+.*?\%5d)\2} { $1 . $2 . unhexify($3) . $2 }egi; $body =~ s{(<\w+\s+[^>]*href=)(["'])(\%5b\w+.*?\%5d)\2} { $1 . $2 . unhexify($3) . $2 }egi; $body =~ s{(<i\w+\s+[^>]*src=)(["'])(\%5b\w+.*?\%5d)\2} { $1 . $2 . unhexify($3) . $2 }egi; return $body; } EOR
liven_urls — make all kinds of URLs clickable
The filter searches the input for all kinds of links, and wraps them into the standard HTML <a href=></a> package.
The filter can recognize all sorts of URLs and to a great detail.
Example: Filter example
[filter liven_urls] http://www.clusty.com/ ftp://@host.com/ ftp://host.com/ ftp://foo:@host.com/ ftp://myname@host.dom/%2Fetc/motd ftp://myname@host.dom/etc/motd ftp://myname@host.dom//etc/motd mailto:noaddress@host.dom file://vms.host.edu/disk$user/my/notes/note12345.txt prospero://host.dom//pros/name ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap:///o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one z39.50s://melvyl.ucop.edu/cat z39.50r://melvyl.ucop.edu/mags?elecworld.v30.n19 z39.50r://cnidr.org:2100/tmf?bkirch_rules__a1;esn=f;rs=marc mid:foo4%25foo1@bar.net cid:foo4*foo1@bar.net mid:960830.1639@XIson.com/partA.960830.1639@XIson.com [/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
The matching expressions were generated with the help of Abigail's Regex for URLs (link appears broken, and no replacement found).
To save on processing time, only the most common protocols (http/https, ftp and mailto) are actually enabled in the filter. For the rest of the protocols, you need to uncomment the appropriate lines in the filter source and restart Interchange.
Interchange 5.9.0:
Source: code/Filter/liven_urls.filter
Lines: 118
# Copyright 2005 Davor Ocelic (docelic@mail.inet.hr) # Copyright 2005-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: liven_urls.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $ CodeDef liven_urls Filter CodeDef liven_urls Description Make URLs clickable CodeDef liven_urls Routine <<EOR my %regexps = ( http => <<'ENDR', (?:https?://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)* \ (?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3})) \ (?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2})) \ |[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2})) \ |[;:@&=])*))*)(?:\?(?:(?:(?:[a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[:@&=+])*))*)?))|(?:(?: \ (?:(?:(?:[a-zA-Z\d\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/ \ (?:(?:(?:[a-zA-Z\d\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?))) #ENDR ); # my %regexps chomp $regexps{$_} for keys %regexps; sub { my ($val,$tag,@arg) = @_; @arg or @arg = (qw/http ftp mailto/); @arg = grep { $regexps{$_} } @arg; @arg or return $val; my $match_url = join '|', @regexps{@arg}; $val =~ s/($match_url)/<a href="$1">$1<\/a>/gsi; $val } EOR
loc — localize provided input
Interchange 5.9.0:
Source: code/Filter/loc.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: loc.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef loc Filter CodeDef loc Description Localize CodeDef loc Routine <<EOR sub { my $val = shift; return errmsg($val); } EOR
lookup — perform lookup in another database
The filter performs a lookup in another database.
See the section called “EXAMPLES” for clarification.
Example: Filter example
Suppose we have two databases, products and support, as follows:
code price description 144 12 Item 144 145 84 Item 145 146 314 Item 146
and
code product_supported 144 0 145 1 146 -1
Then, performing
[filter lookup.support.product_supported]144[/filter]
would
yield 0
.
Interchange 5.9.0:
Source: code/Filter/lookup.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: lookup.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $ CodeDef lookup Filter CodeDef lookup Description DB lookup CodeDef lookup Routine <<EOR sub { my ($val, $tag, $table, $column) = @_; return tag_data($table, $column, $val) || $val; } EOR
lspace_to_nbsp — replace leading spaces (" ") with nonbreakable space (" ") characters
The filter replaces leading space ("
") characters
with HTML's nonbreakable-space ("
")
characters.
This is similar in functionality to <filter>space_to_nbsp</filter> filter, where all space (not just leading) is converted.
Example: Filter example
</div> [filter lspace_to_nbsp] Text with leading whitespace. [/filter] </div>
Interchange 5.9.0:
Source: code/Filter/lspace_to_nbsp.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: lspace_to_nbsp.filter,v 1.2 2007-03-30 23:40:44 pajamian Exp $ CodeDef lspace_to_nbsp Filter CodeDef lspace_to_nbsp Description Leading SPACE to nbsp CodeDef lspace_to_nbsp Routine <<EOR sub { my $str = shift; $str =~ s/^( +)/' ' x length($1)/emg; return $str; } EOR
mac — convert UNIX or DOS ASCII text to Apple Macintosh format
convert UNIX or DOS ASCII newlines to Apple Macintosh format.
Unix uses LF (Line feed: \n) sequence to identify a newline.
DOS uses CRLF (Carriage return/Line feed: \r\n) sequence to identify a newline.
Mac uses CR (Carriage return: \r) sequence to identify a newline.
Example: Filter example
[filter mac] Input text with Unix newlines Input text with DOS newlines Input text with Max newlines [/filter]
Interchange 5.9.0:
Source: code/Filter/mac.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: mac.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef mac Filter CodeDef mac Description UNIX/DOS to Mac OS newlines CodeDef mac Routine <<EOR sub { my $val = shift; $val =~ s/\r?\n|\r\n?/\r/g; return $val; } EOR
mailto — enclose input in HTML <a href='mailto: ...'> link
Interchange 5.9.0:
Source: code/Filter/mailto.filter
Lines: 23
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: mailto.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef mailto Filter CodeDef mailto Description mailto: link CodeDef mailto Routine <<EOR sub { my ($val,$tag,@arg) = @_; my $out = qq{<a href="mailto:$val">}; my $anchor = $val; if(@arg) { $anchor = join " ", @arg; } $out .= "$anchor</a>"; } EOR
md5 — calculate MD5 sum of input
Example: Filter example
[filter md5][/filter] [filter md5]One[/filter] [filter md5]Two[/filter] [filter md5]MyPassword[/filter] [filter md5]Very long string[/filter]
Interchange 5.9.0:
Source: code/Filter/md5.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: md5.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef md5 Filter CodeDef md5 Description MD5 sum CodeDef md5 Routine <<EOR use Digest::MD5; sub { return Digest::MD5::md5_hex($_[0]); } EOR
mime_type — print file MIME type, based on file extension
The filter takes a filename as input, determines file extension and returns the appropriate MIME type for it.
Interchange 5.9.0:
Source: code/Filter/mime_type.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: mime_type.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef mime_type Filter CodeDef mime_type Description Find MIME type of filename CodeDef mime_type Routine <<EOR sub { return Vend::Util::mime_type(shift); } EOR
name — transform "Last, First" name format to "First Last"
The filter transforms "Last, First" input to "First Last". Most of the time, of course, this is used with people's names.
Example: Filter example for name and namecase correction
[filter op="name namecase"]DOE, John[/filter]
Interchange 5.9.0:
Source: code/Filter/name.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: name.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef name Filter CodeDef name Description Last, First to First Last CodeDef name Routine <<EOR sub { my $val = shift; return $val unless $val =~ /,/; my($last, $first) = split /\s*,\s*/, $val, 2; return "$first $last"; } EOR
namecase — transform any "NAME" to "Name"
The filter transforms uppercase text, usually "LAST" (as in 'last name') input to "Last".
"lowercase" words are not replaced with "Lowercase", just ALL-CAPS words are "normalized".
Interchange 5.9.0:
Source: code/Filter/namecase.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: namecase.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef namecase Filter CodeDef namecase Description Name case CodeDef namecase Routine <<EOR sub { use locale; my $val = shift; $val =~ s/([A-Z]\w+)/\L\u$1/g; return $val; } EOR
next_sequential
Interchange 5.9.0:
Source: code/Filter/next_sequential.filter
Lines: 59
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: next_sequential.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $ CodeDef next_sequential Filter CodeDef next_sequential Description Next sequential CodeDef next_sequential Visibility private CodeDef next_sequential Routine <<EOR sub { my ($value, $field, $table, $col, $qualifier) = @_; #::logDebug("called next_sequential filter value='$value' table=$table col=$col qual=$qualifier"); return $value if length($value); $table ||= $CGI::values{mv_data_table}; my $val; if(! $table) { return 1 if ! $field; return exists $CGI::values{$field} ? ($CGI::values{$field}) : ($::Values->{$field}); } $col ||= $field; eval { my $db = database_exists_ref($table) or die errmsg("next_sequential filter: no table '%s'", $table); my $tname = $db->name(); my $q = "SELECT $col FROM $tname"; if($qualifier) { my $qval = $CGI::values{$qualifier}; $qval = $db->quote($qval, $qualifier); $q .= " WHERE $qualifier = $qval"; } $q .= " ORDER BY $col desc"; #::logDebug("constructed query $q for next_sequential"); my $ary = $db->query($q) or die errmsg("next_sequential filter query failed: %s", $q); return 1 unless @$ary; $val = $ary->[0][0]; $val++; }; if($@) { logError($@); return undef; } return $val; } EOR
no_white — eliminate all whitespace in input
Interchange 5.9.0:
Source: code/Filter/no_white.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: no_white.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef no_white Filter CodeDef no_white Description No whitespace CodeDef no_white Routine <<EOR sub { my $val = shift; $val =~ s/\s+//g; return $val; } EOR
null_to_colons — replace \0 (null) characters with double colon "::"
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/null_to_colons.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: null_to_colons.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef null_to_colons Filter CodeDef null_to_colons Description NULL to :: CodeDef null_to_colons Routine <<EOR sub { my $val = shift; $val =~ s/\0+/::/g; return $val; } EOR
null_to_comma — replace \0 (null) characters with comma ","
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/null_to_comma.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: null_to_comma.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef null_to_comma Filter CodeDef null_to_comma Description NULL to COMMA CodeDef null_to_comma Routine <<EOR sub { my $val = shift; $val =~ s/\0+/,/g; return $val; } EOR
null_to_space — replace \0 (null) characters with space " "
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/null_to_space.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: null_to_space.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef null_to_space Filter CodeDef null_to_space Description NULL to SPACE CodeDef null_to_space Routine <<EOR sub { my $val = shift; $val =~ s/\0+/ /g; return $val; } EOR
nullselect — split input on \0 (null) characters and return first non-empty string
The filter splits input on \0
(null) characters
and returns the first non-empty string found.
The filter is suitable for retrieving values out of HTML Combo boxes.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/nullselect.filter
Lines: 21
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: nullselect.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef nullselect Filter CodeDef nullselect Description Combo box CodeDef nullselect Routine <<EOR sub { my @some = split /\0+/, shift; for(@some) { return $_ if length $_; } return ''; } EOR
oneline — delete everything after first null or newline character, effectively "onelining" the input
The filter deletes everything after the first null (\0
)
or newline (\r
or \n
) character.
Effectively, it only preserves and returns the first line of input.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/oneline.filter
Lines: 19
# Copyright 2005-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: oneline.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef oneline Filter CodeDef oneline Description Truncate at first newline (CR or LF) or ASCII NUL CodeDef oneline Visibility public CodeDef oneline Routine <<EOR sub { my $val = shift; $val =~ s/[\r\n\0].*//s; return $val; } EOR
option_format
Interchange 5.9.0:
Source: code/Filter/option_format.filter
Lines: 48
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: option_format.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef option_format Filter CodeDef option_format Description Option format CodeDef option_format Routine <<EOR sub { my ($value, $tag, $delim) = @_; return $value unless $value =~ /\0.*\0/s; my $scrubcommas; if(! length($delim) ) { $delim = ','; $scrubcommas = 1; } else { $delim =~ /pipe/i and $delim = '|' or $delim =~ /semicolon/i and $delim = ';' or $delim =~ /colon/i and $delim = ':' or $delim =~ /null/i and $delim = "\0" ; } my @opts = split /\0/, $value; my @out; while(@opts) { my ($v, $l, $d) = splice @opts, 0, 3; $l = length($l) ? "=$l" : ''; $l =~ s/,/,/g if $scrubcommas; $d = $d ? '*' : ''; next unless length("$v$l"); push @out, "$v$l$d"; } return join $delim, @out; } EOR
options2line — replace commas in input with newlines
The filter replaces commas in input with newlines (\n
).
It also takes care of removing trailing whitespace along the way.
Interchange 5.9.0:
Source: code/Filter/options2line.filter
Lines: 26
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: options2line.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef options2line Filter CodeDef options2line Description options2line CodeDef options2line Routine <<EOR sub { my ($value, $tag, $delim) = @_; return $value unless length $value; $value =~ s/\s+$//; $value =~ s/^\s+//; my @opts = split /\s*,\s*/, $value; for(@opts) { s/,/,/g; } $value = return join "\n", @opts; return $value; } EOR
pagefile — make sure the input is ready for use as an Interchange page filename
The filter makes sure (possibly by intervening) that the input string is ready and safe to be used as an Interchange page name.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/pagefile.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: pagefile.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef pagefile Filter CodeDef pagefile Routine <<EOR sub { $_[0] =~ s:^[./]+::; return $_[0]; } EOR
pgbool — return "f" (false) or "t" (true), depending on input data
The filter returns "f
" (false) if the input is
undefined, 0
, f
or
false
(in a case-insensitive manner).
Otherwise, it returns "t
" (true).
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/pgbool.filter
Lines: 22
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: pgbool.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $ CodeDef pgbool Filter CodeDef pgbool Description PostgreSQL Boolean (undef as false) CodeDef pgbool Visibility private CodeDef pgbool Routine <<EOR sub { my $val = shift; return 'f' if ! defined($val); $val =~ s/\s+//g; return 'f' if $val =~ /^(?:0|f(?:alse)?)?$/i; return 't'; } EOR
pgbooln — return undef (NULL), "f" (false) or "t" (true), depending on input data
The filter returns undefined value (NULL) if the input is
undefined. It returns "f
" (false) if the input is
0
, f
or
false
(in a case-insensitive manner).
Otherwise, it returns "t
" (true).
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/pgbooln.filter
Lines: 22
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: pgbooln.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $ CodeDef pgbooln Filter CodeDef pgbooln Description PostgreSQL Boolean (undef as NULL) CodeDef pgbooln Visibility private CodeDef pgbooln Routine <<EOR sub { my $val = shift; return if ! defined($val); $val =~ s/\s+//g; return 'f' if $val =~ /^(?:0|f(?:alse)?)?$/i; return 't'; } EOR
pre — enclose input in HTML <pre> (preformatted) tag
Interchange 5.9.0:
Source: code/Filter/pre.filter
Lines: 16
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: pre.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef pre Filter CodeDef pre Routine <<EOR sub { return '<pre>' . shift(@_) . '</pre>'; } EOR
qb_safe — make input safe for QuickBooks by removing unfriendly characters
The filter makes data safe for Intuit QuickBooks, because QB will crash at the drop of a hat.
Example: Filter example
<filter>qb_safe</filter> the input and limit it to 25 characters.
[filter op="qb_safe 25" interpolate=1][ol-param sku][/filter]
Interchange 5.9.0:
Source: code/Filter/qb_safe.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: qb_safe.filter,v 1.8 2007-03-30 23:40:45 pajamian Exp $ CodeDef qb_safe Filter CodeDef qb_safe Description Safe for Quickbooks CodeDef qb_safe Visibility private CodeDef qb_safe Routine <<EOR sub { my $val = shift; $val =~ s/[\"\/\\]//g; return $val; } EOR
restrict_html — filter out all but the restricted set of allowed HTML tags in input
The filter restricts the set of HTML tags that can appear in the input. Tags not found among the allowed ones are filtered out.
Example: Filter example
[filter restrict_html.p.br.ul.li.b] <ul> <li> Item lists are allowed. </ul> <p> As well as paragraphs and<br> newlines. </p> Links, such as <a href="http://www.icdevgroup.org">ICDEVGROUP</a> are <b>not</b> allowed. [/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/restrict_html.filter
Lines: 23
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: restrict_html.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef restrict_html Filter CodeDef restrict_html Description Restrict HTML CodeDef restrict_html Visibility private CodeDef restrict_html Routine <<EOR sub { my $val = shift; shift; my %allowed; $allowed{lc $_} = 1 for @_; $val =~ s{<(/?(\w[-\w]*)[\s>])}{ ($allowed{lc $2} ? '<' : '<') . $1 }ge; return $val; } EOR
roman — transform input integer to Roman numerals
Interchange 5.9.0:
Source: code/Filter/roman.filter
Lines: 37
# Copyright 2005 Cursor Software Limited (http://www.cursor.biz/) # Copyright 2005-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: roman.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef roman Filter CodeDef roman Description Integer to Roman numerals CodeDef roman Visibility private CodeDef roman Routine <<EOR sub { my $val = shift; $val =~ s/\D+//g; return '' unless $val; $val =~ m/(\d*?)(\d{1,3})$/ or return ''; my $buf = 'M' x ($1 || 0); my @digits = reverse(split('',$2)); my @numerals = ( [ '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', ], [ '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', ], [ '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', ], ); for (my $i = $#digits; $i >= 0; $i--) { $buf .= $numerals[$i]->[$digits[$i]]; } return $buf; } EOR
round — round value in floating-point-safe way
Example: Filter example
[filter round.4]512.78953[/filter] [filter round.4]512.78955[/filter] [filter round.4]512.78958[/filter]
Interchange 5.9.0:
Source: code/Filter/round.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: round.filter,v 1.4 2007-11-15 01:14:14 jon Exp $ CodeDef round Filter CodeDef round Description Round numeric value to the specified number of decimal places (default 2) CodeDef round Routine <<EOR sub { my ($val, undef, $digits) = @_; return round_to_frac_digits($val, $digits); } EOR
sha1 — calculate SHA1 sum of input
Example: Filter example
[filter sha1][/filter] [filter sha1]One[/filter] [filter sha1]Two[/filter] [filter sha1]MyPassword[/filter] [filter sha1]Very long string[/filter]
Interchange 5.9.0:
Source: code/Filter/sha1.filter
Lines: 15
# Copyright 2007-2009 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef sha1 Filter CodeDef sha1 Description sha1 sum CodeDef sha1 Routine <<EOR sub { return Vend::Util::sha1_hex($_[0]); } EOR
show_null — replace null-characters (\0) with literal "\0"
The filter makes null characters in input visible, by escaping and making them appear as usual "\0"s.
Interchange 5.9.0:
Source: code/Filter/show_null.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: show_null.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef show_null Filter CodeDef show_null Description Show NULL CodeDef show_null Visibility private CodeDef show_null Routine <<EOR sub { my $val = shift; $val =~ s/\0/\\0/g; return $val; } EOR
small — enclose input in HTML <small> tag
Example: Filter example
You can see that "[filter small] This text is smaller than usual. [/filter]"
Interchange 5.9.0:
Source: code/Filter/small.filter
Lines: 16
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: small.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef small Filter CodeDef small Routine <<EOR sub { return '<small>' . shift(@_) . '</small>'; } EOR
space_to_nbsp — replace all spaces (" ") with nonbreakable space (" ") characters
The filter replaces all space ("
") characters
with HTML's nonbreakable-space ("
")
characters.
This is useful for places where you want strings to appear in a single line, without word-wrapping to the next line.
Example: Filter example
<div style="width: 80px;"> This is a very small DIV and will surely word-wrap this text to multiple lines. With the filter applied, however, it will force the DIV to stretch and render as single line. </div> <div style="width: 80px;"> [filter space_to_nbsp] With the filter applied, however, it will force the DIV to stretch and render as single line. [/filter] </div>
Example: Filter example
<div> [filter space_to_nbsp.compress] Multiple spaces in a line will render as just single space. [/filter] </div>
In HTML, multiple spaces in a line render as just one space on the
screen. When the spaces are converted to " ", however, every
nonbreakable space will produce one space character on the screen —
it's how HTML works.
Use the filter's compress
when you want to
preserve the behavior of only one space being visible on the screen.
Interchange 5.9.0:
Source: code/Filter/space_to_nbsp.filter
Lines: 24
# Copyright 2002-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: space_to_nbsp.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef space_to_nbsp Filter CodeDef space_to_nbsp Description All SPACE to nbsp CodeDef space_to_nbsp Routine <<EOR sub { my ($str, $tag, $opt) = @_; if ( $opt ) { $str =~ s/ +/ /g; } else { $str =~ s/ / /g; } $str; } EOR
space_to_null — replace space " " with \0 (null) character
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/space_to_null.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: space_to_null.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef space_to_null Filter CodeDef space_to_null Description SPACE to NULL CodeDef space_to_null Routine <<EOR sub { my $val = shift; $val =~ s/\s+/\0/g; return $val; } EOR
sql — quote strings for use in SQL statements, without referencing a specific database
The filter replaces single quotes ('
) with
two single quotes (''
). In addition, it
replaces each backslash (\
) with two backslashes
(\\
) to properly escape all content, but
backslash escaping can be turned off by setting the
pragma.
The filter is intended to be used on SQL strings.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/sql.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: sql.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef sql Filter CodeDef sql Description SQL quoting, generic CodeDef sql Routine <<EOR sub { my $val = shift; $val =~ s:':'':g; $val =~ s:\\:\\\\:g unless $::Pragma->{filter_sql_no_backslash}; return $val; } EOR
strftime — transform UNIX time (number of seconds) to a date/time string, according to specified format
The filter transforms UNIX time (measured in a number of seconds since the epoch) to human-readable date/time string, according to the specified format.
If the format is unspecified, the system outputs time in the default format,
such as Fri Dec 16 15:04:33 2005
.
Interchange 5.9.0:
Source: code/Filter/strftime.filter
Lines: 28
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: strftime.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef strftime Filter CodeDef strftime Description Date from UNIX time CodeDef strftime Routine <<EOR sub { my $time = shift(@_); shift(@_); my $fmt = shift(@_); while(my $add = shift(@_)) { $fmt .= " $add"; } if($fmt) { return POSIX::strftime($fmt, localtime($time)); } else { return scalar localtime($time); } } EOR
strikeout — enclose input in HTML <strike> tag
Interchange 5.9.0:
Source: code/Filter/strikeout.filter
Lines: 16
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: strikeout.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef strikeout Filter CodeDef strikeout Routine <<EOR sub { return '<strike>' . shift(@_) . '</strike>'; } EOR
strip — trim leading and trailing whitespace
Interchange 5.9.0:
Source: code/Filter/strip.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: strip.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef strip Filter CodeDef strip Description Trim whitespace CodeDef strip Routine <<EOR sub { my $val = shift; $val =~ s/^\s+//; $val =~ s/\s+$//; return $val; } EOR
strip_html
Interchange 5.9.0:
Source: code/Filter/strip_html.filter
Lines: 34
# Copyright 2009 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef strip_html Filter CodeDef strip_html Description Strip HTML CodeDef strip_html Routine <<EOR sub { my $val = shift; # get rid of HTML comments $val =~ s/<!(?:--(?:[^-]*|-[^-]+)*--\s*)>//s; # replace these container tags with a space $val =~ s{</?(?:p|ol|ul|li|div|h[123456]|pre|dl|dd|dt|form|option|textarea \ |blockquote)(?:\s[^>]*)?>}{ }ig; # replace these self-closing tags with a space $val =~ s{<[bh]r(?:\s*/|\s[^>]*)?>}{ }ig; # remove all remaining tags and leave no space $val =~ s{</?\w[^>]*>}{}g; # collapse all whitespace, as HTML does when rendering anyway, # to facilitate truncating at a certain number of characters $val =~ s{\A\s+}{}; $val =~ s{\s+\z}{}; $val =~ s{\s+}{ }g; return $val; } EOR
strip_path
Interchange 5.9.0:
Source: code/Filter/strip_path.filter
Lines: 17
# Copyright 2002-2016 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. CodeDef strip_path Filter CodeDef strip_path Description Strip all path segments, leaving file name CodeDef strip_path Routine <<EOR sub { local $_ = shift; s{.*[/\\]}{}s; return $_; } EOR
tabbed — replace newlines in input with TAB characters
The filter replaces all occurrences of a newline in the input with a TAB character.
Windows-style newlines (\r\n
) are supported.
"Compression" is not done — each newline is replaced by one
TAB.
Interchange 5.9.0:
Source: code/Filter/tabbed.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: tabbed.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef tabbed Filter CodeDef tabbed Description Newline to TAB CodeDef tabbed Routine <<EOR sub { my $val = shift; $val =~ s/\r?\n/\t/g; return $val; } EOR
text2html — transform input plain-text to most basic HTML
Example: Filter example
[filter text2html] Perl is a lot of fun! Interesting tricks with the language can be seen at MJD's <a href="http://perl.plover.com/">plover.com</a>. Programming is an art. [/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/text2html.filter
Lines: 22
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: text2html.filter,v 1.6 2009-04-15 11:14:59 ton Exp $ CodeDef text2html Filter CodeDef text2html Description Simple text2html CodeDef text2html Routine <<EOR sub { my $val = shift; $val =~ s!\r?\n\r?\n!<br$Vend::Xtrailer><br$Vend::Xtrailer>!g; $val =~ s!\r\r!<br$Vend::Xtrailer><br$Vend::Xtrailer>!g; $val =~ s!\r?\n!<br$Vend::Xtrailer>!g; $val =~ s!\r!<br$Vend::Xtrailer>!g; return $val; } EOR
textarea_get — replace & (ampersand) entities in input with literal &
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/textarea_get.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: textarea_get.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef textarea_get Filter CodeDef textarea_get Description Textarea GET CodeDef textarea_get Routine <<EOR sub { my $val = shift; $val =~ s/\&/\&/g; return $val; } EOR
textarea_put — replace &, < and [ characters with their encoded representation
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/textarea_put.filter
Lines: 21
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: textarea_put.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef textarea_put Filter CodeDef textarea_put Description Textarea PUT CodeDef textarea_put Routine <<EOR sub { my $val = shift; $val =~ s/\&/\&/g; $val =~ s/\[/[/g; $val =~ s/</</g; return $val; } EOR
tt — enclose input in HTML <tt> (typewriter) tag
Example: Filter example
R. J. Zavada's <a href="http://www.jfk-info.com/zreport.htm">report</a>:<br/> [filter tt]Zapruder, eight millimeter, 8mm, cage print, B&H Model J Printer,<br/> B&H 414PD Camera, NARA, ARRB[/filter]
Interchange 5.9.0:
Source: code/Filter/tt.filter
Lines: 16
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: tt.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $ CodeDef tt Filter CodeDef tt Routine <<EOR sub { return '<tt>' . shift(@_) . '</tt>'; } EOR
uc — transform all input to uppercase
Example: Filter example
[filter uc]You are kindly invited to the[/filter] <a href="http://www.j-walk.com/other/conf/">The 3rd Annual Nigerian EMail Conference</a>.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/uc.filter
Lines: 24
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: uc.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $ CodeDef upper Filter CodeDef upper Alias uc CodeDef uc Filter CodeDef uc Description Upper case CodeDef uc Routine <<EOR sub { use locale; if ($Scratch->{mv_locale}) { POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale}); } return uc(shift); } EOR
ucfirst — transform first character in input to uppercase
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/ucfirst.filter
Lines: 20
# Copyright 2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: ucfirst.filter,v 1.1 2007-07-13 08:22:47 racke Exp $ CodeDef ucfirst Filter CodeDef ucfirst Description First character upper case CodeDef ucfirst Routine <<EOR sub { use locale; if ($Scratch->{mv_locale}) { POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale}); } return ucfirst(shift); } EOR
unix — convert DOS or Mac ASCII text to Unix format
convert DOS or Mac ASCII newlines to Unix format.
Unix uses LF (Line feed: \n) sequence to identify a newline.
DOS uses CRLF (Carriage return/Line feed: \r\n) sequence to identify a newline.
Mac uses CR (Carriage return: \r) sequence to identify a newline.
Example: Filter example
[filter unix]Those pesky DOS characters, we can only be lucky that there are none hiding in this text ;-)[/filter]
Example: Filter example
[filter unix] Input text with Unix newlines Input text with DOS newlines Input text with Max newlines [/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/unix.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: unix.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef unix Filter CodeDef unix Description DOS to UNIX newlines CodeDef unix Routine <<EOR sub { my $val = shift; $val =~ s/\r\n|\r/\n/g; return $val; } EOR
upload
Interchange 5.9.0:
Source: code/Filter/upload.filter
Lines: 23
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: upload.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef upload Filter CodeDef upload Description Return uploaded file CodeDef upload Routine <<EOR sub { my ($fn, $vn) = @_; if( tag_value_extended($vn, { test => 'isfile', })) { return tag_value_extended($vn, { file_contents => 1 }); } else { return $fn; } } EOR
urldecode — replace encoded (hex) characters with their unencoded representation
Example: Filter example
[filter op="urlencode urldecode"]http://myhost.mydomain.local/path/script.cgi?var1=val1&var2=val2[/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/urldecode.filter
Lines: 25
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: urldecode.filter,v 1.5 2007-09-21 16:15:48 kwalsh Exp $ CodeDef url Filter CodeDef url Alias urldecode CodeDef urld Filter CodeDef urld Alias urldecode CodeDef urldecode Filter CodeDef urldecode Description URL decode CodeDef urldecode Routine <<EOR sub { my $val = shift; $val =~ s|\%([a-fA-F0-9][a-fA-F0-9])|chr(hex($1))|eg; return $val; } EOR
urlencode — replace non-word characters or a colon with encoded (hex) representation
The filter replaces non-word characters or colons with their encoded (hex) representation.
Example: Filter example
[filter urlencode]http://myhost.mydomain.local/path/script.cgi?var1=val1&var2=val2[/filter]
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/urlencode.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: urlencode.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef urlencode Filter CodeDef urlencode Description URL encode CodeDef urlencode Routine <<EOR sub { my $val = shift; $val =~ s|([^\w:])|sprintf "%%%02x", ord $1|eg; return $val; } EOR
value — expand to value of the UserDB variable specified in body
The filter expands to the value of a UserDB variable. Name of the variable is specified in filter body.
Example: Filter example
[value name=online_value_test set="TEST VALUE" hide=1] My test value is [filter value]online_value_test[/filter]
Interchange 5.9.0:
Source: code/Filter/value.filter
Lines: 18
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: value.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef value Filter CodeDef value Description Return $Values->{VALUE} CodeDef value Visibility private CodeDef value Routine <<EOR sub { return $::Values->{$_[0]}; } EOR
vars_and_comments — interpolate variables and remove comments
Interchange 5.9.0:
Source: code/Filter/vars_and_comments.filter
Lines: 22
# Copyright 2004-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: vars_and_comments.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $ CodeDef vars_and_comments Filter CodeDef vars_and_comments Description Vars/comments CodeDef vars_and_comments Visibility private CodeDef vars_and_comments Routine <<EOR sub { my $body = shift; my $bodyref = ref($body) ? $body : \$body; Vend::Interpolate::vars_and_comments($bodyref); return ref($body) ? $body: $$bodyref; } EOR
word — eliminate any non-word characters
The filter eliminates non-word characters in the input.
(Non-word characters are those outside the
[a-zA-Z0-9_
] range.)
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/word.filter
Lines: 19
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: word.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef word Filter CodeDef word Description A-Za-z_0-9 CodeDef word Routine <<EOR sub { my $val = shift; $val =~ s/\W+//g; return $val; } EOR
yesno — return Yes for non-empty input, No otherwise
Return Yes
(or it's locale-specific variant)
on non-empty input (whitespace is considered non-empty too).
Return No
(or it's locale-specific variant) otherwise.
Example: Filter example
OK (yes)? [filter yesno]Good input[/filter] OK (no)? [filter yesno][/filter]
Example: Reaching "yesno" decision after any whitespace is removed first
OK (yes)? [filter yesno]Good input[/filter] OK (yes)? [filter yesno][/filter] OK (no)? [filter strip yesno][/filter]
Interchange 5.9.0:
Source: code/Filter/yesno.filter
Lines: 20
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: yesno.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef yesno Filter CodeDef yesno Description 1/0 to Yes/No CodeDef yesno Routine <<EOR sub { my $val = shift(@_) ? 'Yes' : 'No'; return $val unless $Vend::Cfg->{Locale}; return $val unless defined $Vend::Cfg->{Locale}{$val}; return $Vend::Cfg->{Locale}{$val}; } EOR
zerofix — eliminate possible zeros at beginning of input
The filter eliminates zeros (0
) that might be present
at the beginning of an input string.
For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).
Interchange 5.9.0:
Source: code/Filter/zerofix.filter
Lines: 17
# Copyright 2002-2007 Interchange Development Group and others # Copyright 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: zerofix.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $ CodeDef zerofix Filter CodeDef zerofix Description Strip leading zeros CodeDef zerofix Routine <<EOR sub { $_[0] =~ /^0*(.*)/; return $1; } EOR