All pastes #12059 Raw Edit

Untitled

public text v1 · immutable
#12059 ·published 2005-05-18 16:33 UTC
rendered paste body
sub fix_old_html {
	require HTML::Entities;
	my @in = @_;
	foreach (@in) {
		s#(?<=\<)(/?[A-Z]+)(.*?)(?=\>)#
			my ($start, $end) = ($1, $2);
			$end =~ s/(?<=\s)([A-Z]+)(?=\=)/lc($1)/eg;
			lc($start) . $end;
		#eg;
		s#(<a\b[^>]*)target=(['"]?)_blank\2#$1#g;
		1 while (s|&(?!#?[a-zA-Z0-9]{2,6};)|&amp;|g);
		s#<img\b([^>]*)>#<img$1 />#g;
		$_ = HTML::Entities::encode($_, "\xA0-\xFF");
	}
	return @in;
}