/[smeserver]/rpms/e-smith-hosts/sme8/e-smith-hosts-2.2.0.comment_hostname_validator.patch
ViewVC logotype

Annotation of /rpms/e-smith-hosts/sme8/e-smith-hosts-2.2.0.comment_hostname_validator.patch

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


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

1 stephdl 1.2 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 stephdl 1.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 stephdl 1.2 +{
6 stephdl 1.3 + # 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 stephdl 1.6 + $comment =~ s/[^a-zA-Z0-9\ \_\-\,\.]+//g;
12 stephdl 1.3 + $host->merge_props(Comment => $comment);
13     + }
14 stephdl 1.2 +}
15 stephdl 1.1 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 stephdl 1.5 + The comment must contain only letters, spaces, numbers, dots, commas, undescores, hyphens and must start with a letter or number.
27 stephdl 1.1 + </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/lib/perl5/site_perl/esmith/FormMagick/Panel/hostentries.pm 2015-01-18 11:25:40.356221775 +0100
39     +++ e-smith-hosts-2.4.0.bz8723/root/usr/lib/perl5/site_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 stephdl 1.5 + my $comment = $q->param('comment');
45 stephdl 1.1 $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 stephdl 1.5 + unless ( $comment =~ /^([a-zA-Z0-9][\_\.\-,A-Za-z0-9\s]*)$/ )
54 stephdl 1.1 + {
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