[ic] HTML Special Entities

Stefan Hornburg (Racke) racke at linuxia.de
Wed May 12 13:54:19 UTC 2010


we are working on getting a site properly HTML validated. One of the problems
are menus or categories from the database containing an ampersand like
Dungeons & Dragons.

I wrote the following filter for this and the other HTML special entities:

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/"/&quot;/g;
	$val =~ s/&/&amp;/g;
	$val =~ s/</&lt;/g;
	$val =~ s/>/&gt;/g;

	return $val;

Any comments on this? What would be a good short alias for it?

Oh, and I really like the Firefox plugin HTML validator :-).
It is quite useful for cleaning up HTML.


LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team

More information about the interchange-users mailing list