line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CodeGen::Protection::Format::HTML; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Safely rewrite parts of HTML documents |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1031
|
use Moo; |
|
1
|
|
|
|
|
6606
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
1554
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
123
|
|
7
|
|
|
|
|
|
|
with 'CodeGen::Protection::Role'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _tidy { |
12
|
2
|
|
|
2
|
|
5
|
my ( $self, $code ) = @_; |
13
|
2
|
|
|
|
|
5
|
return $code; # we don't yet tidy |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _start_marker_format { |
17
|
5
|
|
|
5
|
|
13
|
'<!-- %s %s. Do not touch any code between this and the end comment. Checksum: %s -->'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _end_marker_format { |
21
|
5
|
|
|
5
|
|
13
|
'<!-- %s %s. Do not touch any code between this and the start comment. Checksum: %s -->'; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=encoding UTF-8 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
CodeGen::Protection::Format::HTML - Safely rewrite parts of HTML documents |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 VERSION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
version 0.02 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $rewrite = CodeGen::Protection::Format::HTML->new( |
43
|
|
|
|
|
|
|
protected_code => $text, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
say $rewrite->rewritten; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $rewrite = CodeGen::Protection::Format::HTML->new( |
48
|
|
|
|
|
|
|
existing_code => $existing_code, |
49
|
|
|
|
|
|
|
protected_code => $protected_code, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
say $rewrite->rewritten; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This module allows you to do a safe partial rewrite of documents. If you're |
56
|
|
|
|
|
|
|
familiar with L<DBIx::Class::Schema::Loader>, you probably know the basic |
57
|
|
|
|
|
|
|
concept. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Note that this code is designed for HTML documents and is not very |
60
|
|
|
|
|
|
|
configurable. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
In short, we wrap your "protected" (C<protected_code>) HTML code in start and |
63
|
|
|
|
|
|
|
end comments, with checksums for the code: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#<<< CodeGen::Protection::Format::HTML 0.01. Do not touch any code between this and the end comment. Checksum: fa97a021bd70bf3b9fa3e52f203f2660 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# protected HTML goes here |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#>>> CodeGen::Protection::Format::HTML 0.01. Do not touch any code between this and the start comment. Checksum: fa97a021bd70bf3b9fa3e52f203f2660 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
If C<existing_code> is provided, this module removes the code between the old |
72
|
|
|
|
|
|
|
code's start and end markers and replaces it with the C<protected_code>. If |
73
|
|
|
|
|
|
|
the code between the start and end markers has been altered, it will no longer |
74
|
|
|
|
|
|
|
match the checksums and rewriting the code will fail. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Curtis "Ovid" Poe <ovid@allaroundtheworld.fr> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Curtis "Ovid" Poe. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
85
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |