/[smeserver]/rpms/e-smith-hosts/sme9/e-smith-hosts-2.4.0.comment_hostname_validator.patch
ViewVC logotype

Contents of /rpms/e-smith-hosts/sme9/e-smith-hosts-2.4.0.comment_hostname_validator.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download)
Fri Feb 6 21:37:09 2015 UTC (9 years, 9 months ago) by stephdl
Branch: MAIN
CVS Tags: e-smith-hosts-2_4_0-12_el6_sme, e-smith-hosts-2_4_0-11_el6_sme, HEAD
Changes since 1.5: +1 -1 lines
* Fri Feb 6 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 2.4.0-11.sme
- Add a migrate fragment to sanitize the host comment [SME: 8723]
- Code done by  Charlie Brady <charlieb-contribs-bugzilla@budge.apana.org.au>
- and Huib <sme@artixdesign.com>

1 diff -Nur e-smith-hosts-2.4.0.old8723/root/etc/e-smith/db/hosts/migrate/30sanitise_host_comment e-smith-hosts-2.4.0.bz8723/root/etc/e-smith/db/hosts/migrate/30sanitise_host_comment
2 --- e-smith-hosts-2.4.0.old8723/root/etc/e-smith/db/hosts/migrate/30sanitise_host_comment 1970-01-01 01:00:00.000000000 +0100
3 +++ e-smith-hosts-2.4.0.bz8723/root/etc/e-smith/db/hosts/migrate/30sanitise_host_comment 2015-01-22 08:30:50.193365257 +0100
4 @@ -0,0 +1,10 @@
5 +{
6 + # Purge quoting chars in comments to fix bug 8723 & bug 8806
7 + foreach my $host ($DB->get_all)
8 + {
9 + my $comment = $host->prop('Comment');
10 + next unless $comment;
11 + $comment =~ s/[^a-zA-Z0-9\ \_\-\,\.]+//g;
12 + $host->merge_props(Comment => $comment);
13 + }
14 +}
15 diff -Nur e-smith-hosts-2.4.0.old8723/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries e-smith-hosts-2.4.0.bz8723/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries
16 --- e-smith-hosts-2.4.0.old8723/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries 2015-01-18 11:25:40.356221775 +0100
17 +++ e-smith-hosts-2.4.0.bz8723/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries 2015-01-18 12:57:12.694843190 +0100
18 @@ -271,4 +271,18 @@
19 <base>MUST_BE_VALID_HOSTNAME_OR_IP</base>
20 <trans>Must be a valid hostname or IP number</trans>
21 </entry>
22 + <entry>
23 + <base>HOSTNAME_COMMENT_ERROR</base>
24 + <trans>
25 + Error: unexpected characters in the comment of "{$hostname}.{$domain}".
26 + The comment must contain only letters, spaces, numbers, dots, commas, undescores, hyphens and must start with a letter or number.
27 + </trans>
28 + </entry>
29 + <entry>
30 + <base>HOSTNAME_VALIDATOR_ERROR</base>
31 + <trans>
32 + Error: unexpected characters in host name: "{$hostname}.{$domain}". The host name should contain only
33 + letters, numbers, and hyphens and must start with a letter or a number.
34 + </trans>
35 + </entry>
36 </lexicon>
37 diff -Nur e-smith-hosts-2.4.0.old8723/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/hostentries.pm e-smith-hosts-2.4.0.bz8723/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/hostentries.pm
38 --- e-smith-hosts-2.4.0.old8723/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/hostentries.pm 2015-01-18 11:25:40.356221775 +0100
39 +++ e-smith-hosts-2.4.0.bz8723/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/hostentries.pm 2015-01-18 12:56:12.236214717 +0100
40 @@ -420,11 +420,17 @@
41 my $hostname = lc $q->param('name');
42 my $domain = lc $q->param('domain');
43 my $fqdn = "$hostname.$domain";
44 + my $comment = $q->param('comment');
45 $self->cgi->param(-name=>'name', -value=>$hostname);
46
47 unless ( $hostname =~ /^[a-z0-9][a-z0-9-]*$/ )
48 {
49 - return $self->error('HOSTNAME_DESCRIPTION');
50 + return $self->error('HOSTNAME_VALIDATOR_ERROR');
51 + }
52 +
53 + unless ( $comment =~ /^([a-zA-Z0-9][\_\.\-,A-Za-z0-9\s]*)$/ )
54 + {
55 + return $self->error('HOSTNAME_COMMENT_ERROR');
56 }
57 # Look for duplicate hosts.
58 my $hostrec = undef;

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed