| Plagger documentation | Contained in the Plagger distribution. |
Plagger::Plugin::Filter::TTP - Replace ttp:// with http://
- module: Filter::TTP
This plugin replaces ttp:// with http://. ttp:// is a widely
adopted way of linking an URL without leaking a referer.
When set to 1, uses HTML::Parser to avoid replacing ttp:// inside
HTML attributes. Defaults to 0.
Matsuno Tokuhiro
Tatsuhiko Miyagawa
| Plagger documentation | Contained in the Plagger distribution. |
package Plagger::Plugin::Filter::TTP; use strict; use base qw( Plagger::Plugin::Filter::Base ); use URI::Find; use URI::http; sub filter { my($self, $body) = @_; local @URI::ttp::ISA = qw(URI::http); my $count = 0; my $finder = URI::Find->new(sub { my ($uri, $orig_uri) = @_; if ($uri->scheme eq 'ttp') { $count++; return qq{<a href="h$orig_uri">$orig_uri</a>}; } else { return $orig_uri; } }); $finder->find(\$body); ($count, $body); } 1; __END__