aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-29 18:18:48 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-29 18:18:48 +0200
commit1eb7912a55921242a379fec76d6b93273ac3260e (patch)
tree26c532e38cde99b34408e2a4146819390e9108d7
parentf6ffcfd73fc0d0dd731c321efab9a408a176c801 (diff)
W3C validation script.
-rw-r--r--INSTALL10
-rw-r--r--TODO.org13
-rwxr-xr-xbin/fripost-panel2
-rw-r--r--lib/Fripost/Panel/Interface.pm9
-rw-r--r--lib/Fripost/Schema/Alias.pm1
-rwxr-xr-xmisc/w3c-validator.pl68
-rw-r--r--template/list-locals.html2
7 files changed, 91 insertions, 14 deletions
diff --git a/INSTALL b/INSTALL
index 4027c9d..26a1478 100644
--- a/INSTALL
+++ b/INSTALL
@@ -10,7 +10,8 @@ apt-get install libcgi-application-perl \
libcgi-application-plugin-session-perl \
libcgi-fast-perl \
libfreezethaw-perl \
- libhtml-template-perl
+ libhtml-template-perl \
+ liburi-escape-xs-perl
# Fripost Schema
@@ -20,10 +21,15 @@ apt-get install libnet-ldap-perl \
libdigest-perl \
libstring-mkpasswd-perl \
libnet-idn-encode-perl \
- liburi-escape-xs-perl \
libmail-gnupg-perl
+liburi-escape-xs-perl libnet-idn-encode-perl are not available on Debian 6.0
+(Squeeze). To install these dependencies on Debian < 7.0, run
+
+ cpanp install Net::IDN::Encode URI::Escape::XS
+
+
# Configuration
sudo adduser --system fpanel --home /var/lib/fripost-panel --shell /bin/false --group www-data
sudo mkdir -p /etc/fripost-panel/ /var/lib/fripost-panel/gnupg
diff --git a/TODO.org b/TODO.org
index c8600ce..f040a8c 100644
--- a/TODO.org
+++ b/TODO.org
@@ -10,13 +10,16 @@ domains/emails to Punycode internally?
- When adding a new list 'test', check for existing alias/mailbox/list 'test', 'test-request',...
- (Lists of the form 'test-request' are forbidden);
-* TODO Check for cycles when creating new aliases?
-(It is impossible since the authenticated user may not have full read access on the graph)
-Actually Postfix checks it and warns the administrator with a
+* CANCELED Check for cycles when creating new aliases?
+CLOSED: [2012-09-29 Thu 16:12]
+- CLOSING NOTE [2012-09-29 Thu 16:12] \\
+1/ It is impossible to do it properly since the authenticated user may not have full read access on the graph.
+2/ Cycles may also be created by catch-alls or mailbox forwarding, or even externally with another server.
+3/ Postfix warns the administrator with a
"unreasonable virtual_alias_maps map nesting for test-loop1@fripost.org"
-in the logs. So it's fine to do a partial check here.
+in the logs if there's a loop in the alias resolution.
-* TODO Write a script to check every runmode against the W3 validator.
+* DONE Write a script to check every runmode against the W3 validator.
(Cf. cgiapp_postrun);
* DONE Use FastCGI. References
diff --git a/bin/fripost-panel b/bin/fripost-panel
index feb0008..a9dbd39 100755
--- a/bin/fripost-panel
+++ b/bin/fripost-panel
@@ -53,7 +53,7 @@ cd "${PANEL_DIR}" || exit 1
case "${1}" in
start) start ;;
stop) stop ;;
- restart) stop && start ;;
+ restart) stop; start ;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
diff --git a/lib/Fripost/Panel/Interface.pm b/lib/Fripost/Panel/Interface.pm
index b9a9500..f102a21 100644
--- a/lib/Fripost/Panel/Interface.pm
+++ b/lib/Fripost/Panel/Interface.pm
@@ -17,7 +17,7 @@ use Fripost::Schema;
use Fripost::Password;
use HTML::Entities 'encode_entities';
use URI::Escape::XS 'encodeURIComponent';
-use Net::IDN::Encode qw/email_to_unicode domain_to_ascii/;
+use Net::IDN::Encode qw/email_to_unicode email_to_ascii/;
# This method is called right before the 'setup' method below. It
@@ -136,8 +136,8 @@ sub ListLocals : Runmode {
, isactive => $_->{isactive}
, ispending => $_->{ispending}
, transport => $_->{transport}
- , listURL => $CFG{'listurl_'.$_->{transport}}.$_->{list}.
- '@'.domain_to_ascii($d)
+ , listURL => $CFG{'listurl_'.$_->{transport}}.
+ email_to_ascii($_->{list}.'@'.$d)
};
}
@lists
@@ -325,7 +325,8 @@ sub EditLocal : Runmode {
$template->param( newChanges => $news );
$template->param( error => encode_entities ($error) ) if $error;
$template->param( canDelete => 1 ) if $t eq 'alias';
- $template->param( listURL => $CFG{'listurl_'.$local{transport}}.$l.'@'.$d )
+ $template->param( listURL => $CFG{'listurl_'.$local{transport}}.
+ email_to_ascii($l.'@'.$d) )
if $t eq 'list';
$q->delete('a');
return $template->output;
diff --git a/lib/Fripost/Schema/Alias.pm b/lib/Fripost/Schema/Alias.pm
index 51bf98f..7d729f0 100644
--- a/lib/Fripost/Schema/Alias.pm
+++ b/lib/Fripost/Schema/Alias.pm
@@ -177,7 +177,6 @@ sub _is_valid {
must_attrs( $a, qw/alias isactive maildrop/ );
$a->{alias} = email_valid( $a->{alias}, -exact => 1 );
$a->{maildrop} = [ map { email_valid($_) } @{$a->{maildrop}} ];
- # TODO: check for cycles?
}
diff --git a/misc/w3c-validator.pl b/misc/w3c-validator.pl
new file mode 100755
index 0000000..29bfd73
--- /dev/null
+++ b/misc/w3c-validator.pl
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+
+# Usage: w3c-validator.pl /tmp/fpanel/*.html
+#
+# To generate a bunch of HTML files for the RunModes you want to check,
+# add the following to lib/Fripost/Panel/Login.pm
+#
+# sub cgiapp_postrun {
+# my $self = shift;
+# my $out = shift;
+# unless ($$out eq '') {
+# open OUT, '>', "/tmp/fpanel/".$self->get_current_runmode
+# .int(rand 65536).'.'.$$.'.html';
+# print OUT $$out;
+# close OUT;
+# }
+# return $out;
+# }
+#
+# cd /opt/fripost-panel/
+# sudo mkdir /tmp/fpanel && sudo chown fpanel:www-data /tmp/fpanel/
+# sudo ./bin/fripost-panel restart
+#
+# Every HTML page will now be dumped into /tmp/fpanel/. Once you are done
+# browsing the RunModes,
+# sudo chmod -R +r /tmp/fpanel/
+# ./misc/w3c-validator.pl /tmp/fpanel/*.html
+#
+# /!\ Note: There is a serious privacy concern here. Do *NOT* forget to /!\
+# /!\ remove the postrun hook once you are done testing the application! /!\
+
+use 5.010_000;
+use strict;
+use warnings;
+use utf8;
+
+use WebService::Validator::HTML::W3C;
+my $v = WebService::Validator::HTML::W3C->new( detailed => 1 );
+
+foreach my $html (@ARGV) {
+ die "Error: Cannot read file $html" unless -f $html and -r $html;
+ $v->validate_file($html) or die "Cannot validate: ", $v->validator_error, "\n";
+
+ if (defined $v->errors) {
+ my @errors = @{$v->errors};
+ foreach (@errors) {
+ printf STDERR ( "line: %s, col: %s\n\terror: %s\n",
+ $_->line, $_->col,
+ $_->msg );
+ }
+ die "ERR: Cannot validate ".$html.' ('.(1+$#errors)." error(s) found).\n";
+ }
+ elsif (@{$v->warnings}) {
+ my @warnings = @{$v->warnings};
+ foreach (@warnings) {
+ printf STDERR ( "line: %s, col: %s\n\twarning: %s\n",
+ $_->line, $_->col,
+ $_->msg );
+ }
+ die "WARN: Cannot validate ".$html.' ('.(1+$#warnings)." warnings(s) found).\n";
+ }
+ elsif ($v->is_valid) {
+ print STDERR "Passed: $html\n";
+ }
+ else {
+ die "A weird thing happened with $html\n";
+ }
+}
diff --git a/template/list-locals.html b/template/list-locals.html
index 40ebeec..47b99cf 100644
--- a/template/list-locals.html
+++ b/template/list-locals.html
@@ -122,7 +122,7 @@
<tbody>
<TMPL_LOOP NAME=lists>
<TMPL_IF NAME=__even__><tr class="odd"><TMPL_ELSE><tr></TMPL_IF>
- <td><span class="list"><TMPL_UNLESS NAME=ispending><a href="./<TMPL_VAR NAME=listURI>/"></TMPL_UNLESS
+ <td><span class="list"><TMPL_UNLESS NAME=ispending><a href="<TMPL_VAR NAME=listURI>/"></TMPL_UNLESS
><TMPL_VAR NAME=list
><TMPL_UNLESS NAME=ispending></a> <a class="external" target="_blank" href="<TMPL_VAR NAME=listURL>">&#x27A0;</a></TMPL_UNLESS></span></td>
<td><TMPL_IF NAME=description><TMPL_VAR NAME=description><TMPL_ELSE><span class="none">(none)</span></TMPL_IF></td>