| 1 | package URL::Transform::using::Remove; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | URL::Transform::using::Remove - no url transformation just remove the content | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | my $urlt = URL::Transform::using::Remove->new( | ||||||||||
| 10 | 'output_function' => sub { $output .= "@_" }, | ||||||||||
| 11 | ); | ||||||||||
| 12 | $urlt->parse_string("window.location='http://perl.org';"); | ||||||||||
| 13 | |||||||||||
| 14 | print "and this is the output: ", $output; | ||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||
| 18 | |||||||||||
| 19 | Using module you can performs an url transformation by removing everything! | ||||||||||
| 20 | It's quite safe! ;-) | ||||||||||
| 21 | |||||||||||
| 22 | This module is used by L<URL::Transform> to remove all JavaScript from | ||||||||||
| 23 | the HTML documents as it is nearly impossible to update urls inside the | ||||||||||
| 24 | JavaScript using generic way. | ||||||||||
| 25 | |||||||||||
| 26 | =cut | ||||||||||
| 27 | |||||||||||
| 28 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 3 | our $VERSION = '0.01'; | |||||||||
| 32 | |||||||||||
| 33 | 3 | ▶ | use Carp::Clan 'croak'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | |||||||||||
| 35 | 3 | ▶ | use base 'Class::Accessor::Fast'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | =head1 PROPERTIES | ||||||||||
| 39 | |||||||||||
| 40 | output_function | ||||||||||
| 41 | transform_function | ||||||||||
| 42 | |||||||||||
| 43 | =cut | ||||||||||
| 44 | |||||||||||
| 45 | 3 | __PACKAGE__->mk_accessors(qw{ | |||||||||
| 46 | output_function | ||||||||||
| 47 | transform_function | ||||||||||
| 48 | }); | ||||||||||
| 49 | |||||||||||
| 50 | =head1 METHODS | ||||||||||
| 51 | |||||||||||
| 52 | =head2 new | ||||||||||
| 53 | |||||||||||
| 54 | Object constructor. | ||||||||||
| 55 | |||||||||||
| 56 | Requires: | ||||||||||
| 57 | |||||||||||
| 58 | output_function | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | 6 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 63 | 6 | my $class = shift; | |||||||||
| 64 | |||||||||||
| 65 | 6 | my $self = $class->SUPER::new({ @_ }); | |||||||||
| 66 | |||||||||||
| 67 | 6 | my $output_function = $self->output_function; | |||||||||
| 68 | # my $transform_function = $self->transform_function; | ||||||||||
| 69 | |||||||||||
| 70 | 6 | ▶ | croak 'pass print function' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | if not (ref $output_function eq 'CODE'); | ||||||||||
| 72 | |||||||||||
| 73 | # croak 'pass transform url function' | ||||||||||
| 74 | # if not (ref $transform_function eq 'CODE'); | ||||||||||
| 75 | |||||||||||
| 76 | 6 | return $self; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | =head2 parse_string($string) | ||||||||||
| 81 | |||||||||||
| 82 | Pass empty string to output_function. | ||||||||||
| 83 | |||||||||||
| 84 | =cut | ||||||||||
| 85 | |||||||||||
| 86 | 7 | ▶ | sub parse_string { | ||||||||
|
Subroutine
parse_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 87 | 7 | my $self = shift; | |||||||||
| 88 | 7 | my $string = shift; | |||||||||
| 89 | |||||||||||
| 90 | 7 | $self->output_function->(''); | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | =head2 parse_chunk($string) | ||||||||||
| 95 | |||||||||||
| 96 | Pass empty string to output_function. | ||||||||||
| 97 | |||||||||||
| 98 | =cut | ||||||||||
| 99 | |||||||||||
| 100 | 0 | ▶ | sub parse_chunk { | ||||||||
|
Subroutine
parse_chunk: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 101 | 0 | my $self = shift; | |||||||||
| 102 | |||||||||||
| 103 | 0 | $self->output_function->(''); | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | =head2 parse_file($file_name) | ||||||||||
| 108 | |||||||||||
| 109 | Pass empty string to output_function. | ||||||||||
| 110 | |||||||||||
| 111 | =cut | ||||||||||
| 112 | |||||||||||
| 113 | 0 | ▶ | sub parse_file { | ||||||||
|
Subroutine
parse_file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 114 | 0 | my $self = shift; | |||||||||
| 115 | |||||||||||
| 116 | 0 | $self->output_function->(''); | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | |||||||||||
| 120 | 3 | 1; | |||||||||
| 121 | |||||||||||
| 122 | |||||||||||
| 123 | __END__ | ||||||||||