- From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 23 Nov 2009 22:15:20 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin In directory hutz:/tmp/cvs-serv9510/httpd/cgi-bin Modified Files: check sendfeedback.pl Log Message: Run perltidy on perl sources. Index: sendfeedback.pl =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/sendfeedback.pl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- sendfeedback.pl 29 Jun 2009 14:37:08 -0000 1.12 +++ sendfeedback.pl 23 Nov 2009 22:15:18 -0000 1.13 @@ -7,15 +7,15 @@ use strict; use warnings; - ## Modules. See also the BEGIN block further down below. -use CGI qw(); +use CGI qw(); use File::Spec::Functions qw(catfile); -use HTML::Template 2.6 qw(); -use Config::General 2.32 qw(); # Need 2.32 for <msg 0>, rt.cpan.org#17852 +use HTML::Template 2.6 qw(); +use Config::General 2.32 qw(); # Need 2.32 for <msg 0>, rt.cpan.org#17852 use vars qw($DEBUG $CFG %RSRC $VERSION); + # Define global constants use constant TRUE => 1; use constant FALSE => 0; @@ -23,60 +23,63 @@ # Things inside BEGIN don't happen on every request in persistent # environments, such as mod_perl. So let's do globals, eg. read config here. BEGIN { - # Launder data for -T; -AutoLaunder doesn't catch this one. - if (exists $ENV{W3C_VALIDATOR_HOME}) { - $ENV{W3C_VALIDATOR_HOME} =~ /^(.*)$/; - $ENV{W3C_VALIDATOR_HOME} = $1; - } - # - # Read Config Files. - eval { - my %config_opts = ( - -ConfigFile => ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'), - -MergeDuplicateOptions => TRUE, - -MergeDuplicateBlocks => TRUE, - -SplitPolicy => 'equalsign', - -UseApacheInclude => TRUE, - -IncludeRelative => TRUE, - -InterPolateVars => TRUE, - -AutoLaunder => TRUE, - -AutoTrue => TRUE, - -DefaultConfig => { - Paths => { - Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'), - }, - }, - ); - my %cfg = Config::General->new(%config_opts)->getall(); - $CFG = \%cfg; - }; - if ($@) { - die <<".EOF."; + # Launder data for -T; -AutoLaunder doesn't catch this one. + if (exists $ENV{W3C_VALIDATOR_HOME}) { + $ENV{W3C_VALIDATOR_HOME} =~ /^(.*)$/; + $ENV{W3C_VALIDATOR_HOME} = $1; + } + + # + # Read Config Files. + eval { + my %config_opts = ( + -ConfigFile => + ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'), + -MergeDuplicateOptions => TRUE, + -MergeDuplicateBlocks => TRUE, + -SplitPolicy => 'equalsign', + -UseApacheInclude => TRUE, + -IncludeRelative => TRUE, + -InterPolateVars => TRUE, + -AutoLaunder => TRUE, + -AutoTrue => TRUE, + -DefaultConfig => { + Paths => { + Base => + ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'), + }, + }, + ); + my %cfg = Config::General->new(%config_opts)->getall(); + $CFG = \%cfg; + }; + if ($@) { + die <<".EOF."; Could not read configuration. Set the W3C_VALIDATOR_CFG environment variable or copy conf/* to /etc/w3c/. Make sure that the configuration file and all included files are readable by the web server user. The error was:\n'$@' .EOF. - } -} # end of BEGIN block. + } +} # end of BEGIN block. # # Get rid of (possibly insecure) $PATH. delete $ENV{PATH}; -our $q = new CGI; -our $lang = 'en_US'; # @@@ TODO: conneg +our $q = new CGI; +our $lang = 'en_US'; # @@@ TODO: conneg # Read error message + explanations file %RSRC = Config::General->new( - -MergeDuplicateBlocks => 1, - -ConfigFile => catfile($CFG->{Paths}->{Templates}, $lang, - 'error_messages.cfg'), - )->getall(); + -MergeDuplicateBlocks => 1, + -ConfigFile => + catfile($CFG->{Paths}->{Templates}, $lang, 'error_messages.cfg'), +)->getall(); our $T = HTML::Template->new( - filename => catfile($CFG->{Paths}->{Templates}, $lang, 'feedback.tmpl'), - die_on_bad_params => FALSE, + filename => catfile($CFG->{Paths}->{Templates}, $lang, 'feedback.tmpl'), + die_on_bad_params => FALSE, ); our $errlist = ""; @@ -84,13 +87,15 @@ our $validated_uri; our $errmsg_id; -sub process_query { +sub process_query +{ $validated_uri = $q->param('uri'); - $errmsg_id = $q->param('errmsg_id'); + $errmsg_id = $q->param('errmsg_id'); if ($errmsg_id) { $errmsg_text = "$RSRC{msg}->{$errmsg_id}->{original}"; $errmsg_text = de_template_explanation($errmsg_text); } + # Trigger "thanks for your message. If your query requires an answer,..." ack paragraph my $sent = $q->param('send'); if ($sent) { @@ -99,33 +104,42 @@ } } -sub send_message { -# sends message to www-validator list @@ TODO @@ +sub send_message +{ + + # sends message to www-validator list @@ TODO @@ } -sub error_choices { -# creates drop-down menu with all possible error messages to send feedback about - my @msgnumbers = keys( %{$RSRC{msg}} ); +sub error_choices +{ + + # creates drop-down menu with all possible error messages to send feedback about + my @msgnumbers = keys(%{$RSRC{msg}}); @msgnumbers = sort { $a <=> $b } @msgnumbers; my $errlabel; - for my $errnum ( @msgnumbers ) { + for my $errnum (@msgnumbers) { $errlabel = $RSRC{msg}->{$errnum}->{original}; $errlabel = de_template_explanation($errlabel); - if (length($errlabel) > 70) { $errlabel = substr($errlabel, 0, 67)."..." } - $errlist = $errlist.'<option value="'. $errnum.'"'; + if (length($errlabel) > 70) { + $errlabel = substr($errlabel, 0, 67) . "..."; + } + $errlist = $errlist . '<option value="' . $errnum . '"'; if ($errmsg_id) { - if ($errnum == $errmsg_id) { $errlist = $errlist.'selected="selected" '; } + if ($errnum == $errmsg_id) { + $errlist = $errlist . 'selected="selected" '; + } } - $errlist = $errlist."> $errnum $errlabel</option>\n"; + $errlist = $errlist . "> $errnum $errlabel</option>\n"; } } +sub de_template_explanation +{ -sub de_template_explanation { -# takes the error message template, and replace "template keywords" with real life keywords + # takes the error message template, and replace "template keywords" with real life keywords my $explanation = shift; - if ($explanation){ + if ($explanation) { $explanation =~ s/\%1/X/; $explanation =~ s/\%2/Y/; $explanation =~ s/\%3/Z/; @@ -136,24 +150,26 @@ return $explanation; } +sub prepare_error_message +{ -sub prepare_error_message { -# if the form sent contains errors (what kind exactly?) -# @@ TODO @@ + # if the form sent contains errors (what kind exactly?) + # @@ TODO @@ } -sub print_prefilled_form { +sub print_prefilled_form +{ $T->param(page_title => "Feedback"); - $T->param(uri => $validated_uri); - $T->param(errmsg_id => $errmsg_id); -# $T->param(errlist => $errlist); + $T->param(uri => $validated_uri); + $T->param(errmsg_id => $errmsg_id); + + # $T->param(errlist => $errlist); $T->param(explanation => $errmsg_text); print $T->output; } - - process_query; + #error_choices; print_prefilled_form; Index: check =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/check,v retrieving revision 1.719 retrieving revision 1.720 diff -u -d -r1.719 -r1.720 --- check 16 Nov 2009 19:50:26 -0000 1.719 +++ check 23 Nov 2009 22:15:18 -0000 1.720 @@ -33,8 +33,8 @@ use warnings; use utf8; - package W3C::Validator::MarkupValidator; + # # Modules. See also the BEGIN block further down below. # @@ -44,26 +44,26 @@ # polluting our namespace. [...5789 lines suppressed...] + $tmpl->param( + fatal_ip_error => 1, + fatal_ip_host => $uri->host() || 'undefined', + ); + $tmpl->param(fatal_ip_hostname => 1) + if ($addr and $uri->host() ne $addr); + return 0; + } + return 1; } # Local Variables: # mode: perl # indent-tabs-mode: nil -# tab-width: 2 -# perl-indent-level: 2 +# perl-indent-level: 4 # End: -# ex: ts=2 sw=2 et +# ex: ts=4 sw=4 et
Received on Monday, 23 November 2009 22:15:22 UTC