[interchange] Add filter for encoding HTML 2 special entities "&<>.
Stefan Hornburg <[email protected]>
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit badedf0224e763099e318ba8d376f6cdec180225 Author: Stefan Hornburg (Racke) <[email protected]> Date: Thu May 13 11:28:09 2010 +0200 Add filter for encoding HTML 2 special entities "&<>. MANIFEST | 1 + code/Filter/encode_special_entities.filter | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) --- diff --git a/MANIFEST b/MANIFEST index c97c408..06e444d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -22,6 +22,7 @@ code/Filter/digits_dot.filter code/Filter/dos.filter code/Filter/duration.filter code/Filter/encode_entities.filter +code/Filter/encode_special_entities.filter code/Filter/encrypt.filter code/Filter/filesafe.filter code/Filter/filter_select.filter diff --git a/code/Filter/encode_special_entities.filter b/code/Filter/encode_special_entities.filter new file mode 100644 index 0000000..0046da8 --- /dev/null +++ b/code/Filter/encode_special_entities.filter @@ -0,0 +1,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 \ No newline at end of file