2 # Parse::DebianChangelog::ChangesFilters
4 # Copyright 2005 Frank Lichtenheld <frank@lichtenheld.de>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 Parse::DebianChangelog::ChangesFilters - filters to be applied to Debian changelog entries
29 This is currently only used internally by Parse::DebianChangelog and
30 is not yet documented. There may be still API changes until this module
35 package Parse::DebianChangelog::ChangesFilters;
37 our @ISA = qw(Exporter);
39 our %EXPORT_TAGS = ( 'all' => [ qw(
49 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
62 require HTML::Entities;
64 return HTML::Entities::encode_entities( "$_[0]", '<>&"' ) || '';
68 my ($text, $cgi) = @_;
70 $text=~ s|<URL:([-\w\.\/:~_\@]+):([a-zA-Z0-9\'() ]+)>
71 |$cgi->a({ -href=>$1 }, $2)
73 $text=~ s|https?:[\w/\.:\@+\-~\%\#?=&;,]+[\w/]
74 |$cgi->a({ -href=>$& }, $&)
76 $text=~ s|ftp:[\w/\.:\@+\-~\%\#?=&;,]+[\w/]
77 |$cgi->a({ -href=>$& }, $&)
84 my ($text, $cgi) = @_;
86 $text =~ s|[a-zA-Z0-9_\+\-\.]+\@([a-zA-Z0-9][\w\.+\-]+\.[a-zA-Z]{2,})
87 |$cgi->a({ -href=>"http://qa.debian.org/developer.php?login=$&" }, $&)
93 (my $text = $_[0]) =~ s|closes:\s*(?:bug)?\#?\s?\d+(?:\s*,\s*(?:bug)?\#?\s?\d+)*
94 |my $tmp = $&; { no warnings;
95 $tmp =~ s@(Bug)?\#(\d+)@<a class="buglink" href="http://bugs.debian.org/$2">$1\#$2</a>@ig; }
102 my ($text, $cgi) = @_;
104 $text =~ s!\b(?:CVE|CAN)-\d{4}-\d{4}\b
105 !$cgi->a({ -href=>"http://cve.mitre.org/cgi-bin/cvename.cgi?name=$&" }, $&)
111 my ($text, $cgi) = @_;
113 $text =~ s|\B\*([a-z][a-z -]*[a-z])\*\B
116 $text=~ s|\B\*([a-z])\*\B
119 $text=~ s|\B\#([a-z][a-z -]*[a-z])\#\B
122 $text=~ s|\B\#([a-z])\#\B
129 sub common_licenses {
130 my ($text, $cgi) = @_;
132 $text=~ s|/usr/share/common-licenses/GPL(?:-2)?
133 |$cgi->a({ -href=>"http://www.gnu.org/copyleft/gpl.html" }, $&)
135 $text=~ s|/usr/share/common-licenses/LGPL(?:-2(?:\.1)?)?
136 |$cgi->a({ -href=>"http://www.gnu.org/copyleft/lgpl.html" }, $&)
138 $text=~ s|/usr/share/common-licenses/Artistic
139 |$cgi->a({ -href=>"http://www.opensource.org/licenses/artistic-license.php" }, $&)
141 $text=~ s|/usr/share/common-licenses/BSD
142 |$cgi->a({ -href=>"http://www.debian.org/misc/bsd.license" }, $&)
149 my ($text, $cgi) = @_;
151 $text = encode_entities( $text, $cgi );
152 $text = http_ftp_urls( $text, $cgi );
153 $text = email_to_ddpo( $text, $cgi );
154 $text = bugs_to_bts( $text, $cgi );
155 $text = cve_to_mitre( $text, $cgi );
156 $text = pseudo_markup( $text, $cgi );
157 $text = common_licenses( $text, $cgi );
167 Parse::DebianChangelog
171 Frank Lichtenheld, E<lt>frank@lichtenheld.deE<gt>
173 =head1 COPYRIGHT AND LICENSE
175 Copyright (C) 2005 by Frank Lichtenheld
177 This program is free software; you can redistribute it and/or modify
178 it under the terms of the GNU General Public License as published by
179 the Free Software Foundation; either version 2 of the License, or
180 (at your option) any later version.
182 This program is distributed in the hope that it will be useful,
183 but WITHOUT ANY WARRANTY; without even the implied warranty of
184 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
185 GNU General Public License for more details.
187 You should have received a copy of the GNU General Public License
188 along with this program; if not, write to the Free Software
189 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA