W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2009

validator/httpd/cgi-bin check,1.686,1.687

From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
Date: Sat, 12 Sep 2009 14:22:51 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MmTV5-0001sP-7I@lionel-hutz.w3.org>
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv7189

Modified Files:
	check 
Log Message:
Code cleanups.

Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.686
retrieving revision 1.687
diff -u -d -r1.686 -r1.687
--- check	5 Sep 2009 12:07:36 -0000	1.686
+++ check	12 Sep 2009 14:22:49 -0000	1.687
@@ -413,18 +413,18 @@
 
 #
 # Set session switches.
-$File->{Opt}->{'Outline'}         = $q->param('outline') ? TRUE  :  FALSE;
+$File->{Opt}->{Outline}           = $q->param('outline') ? TRUE  :  FALSE;
 $File->{Opt}->{'Show Source'}     = $q->param('ss')      ? TRUE  :  FALSE;
 $File->{Opt}->{'Show Tidy'}       = $q->param('st')      ? TRUE  :  FALSE;
-$File->{Opt}->{'Verbose'}         = $q->param('verbose') ? TRUE  :  FALSE;
+$File->{Opt}->{Verbose}           = $q->param('verbose') ? TRUE  :  FALSE;
 $File->{Opt}->{'Group Errors'}    = $q->param('group')   ? TRUE  :  FALSE;
-$File->{Opt}->{'Debug'}           = $q->param('debug')   ? TRUE  :  FALSE;
-$File->{Opt}->{'No200'}           = $q->param('No200')   ? TRUE  :  FALSE;
-$File->{Opt}->{'Prefill'}         = $q->param('prefill') ? TRUE  :  FALSE;
+$File->{Opt}->{Debug}             = $q->param('debug')   ? TRUE  :  FALSE;
+$File->{Opt}->{No200}             = $q->param('No200')   ? TRUE  :  FALSE;
+$File->{Opt}->{Prefill}           = $q->param('prefill') ? TRUE  :  FALSE;
 $File->{Opt}->{'Prefill Doctype'} = $q->param('prefill_doctype') || 'html401';
-$File->{Opt}->{'Charset'}         = lc($q->param('charset')      || '');
-$File->{Opt}->{'DOCTYPE'}         = $q->param('doctype')         || '';
-$File->{Opt}->{'Output'}          = $q->param('output')          || 'html';
+$File->{Opt}->{Charset}           = lc($q->param('charset')      || '');
+$File->{Opt}->{DOCTYPE}           = $q->param('doctype')         || '';
+$File->{Opt}->{Output}            = $q->param('output')          || 'html';
 
 $File->{Opt}->{'User Agent'} = $q->param('user-agent') && $q->param('user-agent') ne 1 ? $q->param('user-agent') : "W3C_Validator/$VERSION";
 $File->{Opt}->{'User Agent'} =~ tr/\x00-\x09\x0b\x0c-\x1f//d;
@@ -1124,7 +1124,7 @@
 
 
   my $h; # event handler
-  if ($File->{Opt}->{'Outline'}) {
+  if ($File->{Opt}->{Outline}) {
       $h = W3C::Validator::EventHandler::Outliner->new($opensp, $File, $CFG);
   }
   else {
@@ -1214,28 +1214,24 @@
 
 
 ## if invalid content, AND if requested, pass through tidy
-if ((! $File->{'Is Valid'}) and ($File->{Opt}->{'Show Tidy'}) ) {
+if (!$File->{'Is Valid'} && $File->{Opt}->{'Show Tidy'}) {
   eval {
     local $SIG{__DIE__};
     require HTML::Tidy;
     my $tidy = HTML::Tidy->new({config_file => $CFG->{Paths}->{TidyConf}});
-
-    $File->{'Tidy'} = Encode::decode('utf-8', $tidy->clean(join"\n",@{$File->{Content}}));
-    $File->{'Tidy_OK'} = TRUE;
+    my $cleaned = $tidy->clean(join("\n", @{$File->{Content}}));
+    $cleaned = Encode::decode('utf-8', $cleaned);
+    $File->{Tidy} = $cleaned;
   };
-  if ($@) {
-    $File->{'Tidy_OK'} = FALSE;
-  }
+  $File->{Tidy_OK} = !$@;
 }
 else {
   # if document is valid, we don't really need tidy, do we?
-  $File->{'Tidy_OK'} = FALSE;
+  $File->{Tidy_OK} = FALSE;
 }
 
-if (!$File->{'Tidy_OK'}) {
-  # if tidy not available, disable
-  $File->{Opt}->{'Show Tidy'} = FALSE;
-}
+# if tidy not available, disable
+$File->{Opt}->{'Show Tidy'} &&= $File->{Tidy_OK};
 
 my $template;
 
@@ -1273,7 +1269,7 @@
 &fin_template($File, $template);
 
 $template->param(file_warnings => $File->{Warnings});
-$template->param(tidy_output => $File->{'Tidy'});
+$template->param(tidy_output => $File->{Tidy});
 $template->param(file_source => &source($File))
   if ($template->param('opt_show_source') or ($File->{'Is Upload'}) or ($File->{'Direct Input'}));
 
@@ -1344,10 +1340,10 @@
   # Output options...
   $T->param(opt_show_source  => $File->{Opt}->{'Show Source'});
   $T->param(opt_show_tidy    => $File->{Opt}->{'Show Tidy'});
-  $T->param(opt_show_outline => $File->{Opt}->{'Outline'});
-  $T->param(opt_verbose      => $File->{Opt}->{'Verbose'});
+  $T->param(opt_show_outline => $File->{Opt}->{Outline});
+  $T->param(opt_verbose      => $File->{Opt}->{Verbose});
   $T->param(opt_group_errors => $File->{Opt}->{'Group Errors'});
-  $T->param(opt_no200        => $File->{Opt}->{'No200'});
+  $T->param(opt_no200        => $File->{Opt}->{No200});
 
   #
   # Tip of the Day...
@@ -1532,9 +1528,9 @@
       $T->param(have_alt_badge => TRUE);
       }
 
-      if (exists $CFG->{Types}->{$File->{DOCTYPE}}->{Badge}->{'RDFa'}) {
+      if (exists $CFG->{Types}->{$File->{DOCTYPE}}->{Badge}->{RDFa}) {
         $T->param(have_badge_rdfa => TRUE);
-        $T->param(badge_rdfa => $CFG->{Types}->{$File->{DOCTYPE}}->{Badge}->{'RDFa'});
+        $T->param(badge_rdfa => $CFG->{Types}->{$File->{DOCTYPE}}->{Badge}->{RDFa});
       } else {
         $T->param(have_badge_rdfa => FALSE);
       }
@@ -1772,7 +1768,7 @@
   $File->{'Direct Input'} = TRUE;
   $File->{Charset}->{HTTP} = "utf-8"; # by default, the form accepts utf-8 chars
 
-  if ($File->{Opt}->{'Prefill'}) {
+  if ($File->{Opt}->{Prefill}) {
     # we surround the HTML fragment with some basic document structure
     my $prefill_Template = undef;
     if ($File->{Opt}->{'Prefill Doctype'} eq 'html401') {
@@ -2957,9 +2953,9 @@
   $thispage .= qq(?uri=$escaped_uri);
   $thispage .= ';ss=1'      if $File->{Opt}->{'Show Source'};
   $thispage .= ';st=1'      if $File->{Opt}->{'Show Tidy'};
-  $thispage .= ';outline=1' if $File->{Opt}->{'Outline'};
-  $thispage .= ';No200=1'   if $File->{Opt}->{'No200'};
-  $thispage .= ';verbose=1' if $File->{Opt}->{'Verbose'};
+  $thispage .= ';outline=1' if $File->{Opt}->{Outline};
+  $thispage .= ';No200=1'   if $File->{Opt}->{No200};
+  $thispage .= ';verbose=1' if $File->{Opt}->{Verbose};
   $thispage .= ';group=1'   if $File->{Opt}->{'Group Errors'};
   $thispage .= ';accept=' . uri_escape($File->{Opt}->{'Accept Header'}) if $File->{Opt}->{'Accept Header'};
   $thispage .= ';accept-language=' . uri_escape($File->{Opt}->{'Accept-Language Header'}) if $File->{Opt}->{'Accept-Language Header'};
@@ -3334,8 +3330,8 @@
   my $class = ref($proto) || $proto;
   my $self = $class->SUPER::new(@rest);
 
-  $self->{'W3C::Validator::CFG'}  = $CFG;
-  $self->{'W3C::Validator::File'} = $File;
+  $self->{W3C::Validator::CFG}  = $CFG;
+  $self->{W3C::Validator::File} = $File;
 
   $self->env_proxy();
   $self->agent($File->{Opt}->{'User Agent'});
@@ -3362,10 +3358,10 @@
 sub uri_ok {
   my ($self, $uri) = @_;
 
-  return 1 if ($self->{'W3C::Validator::CFG'}->{'Allow Private IPs'} or
+  return 1 if ($self->{W3C::Validator::CFG}->{'Allow Private IPs'} or
                !$uri->can('host'));
 
-  my $h5uri = $self->{'W3C::Validator::CFG'}->{External}->{HTML5};
+  my $h5uri = $self->{W3C::Validator::CFG}->{External}->{HTML5};
   if ($h5uri) {
     my $clone = $uri->clone(); $clone->query(undef); $clone->fragment(undef);
     $h5uri = URI->new($h5uri); $h5uri->query(undef); $h5uri->fragment(undef);
@@ -3380,7 +3376,7 @@
     }
   }
   if ($iptype && $iptype ne 'PUBLIC') {
-    my $File = $self->{'W3C::Validator::File'};
+    my $File = $self->{W3C::Validator::File};
     $File->{'Error Flagged'} = 1;
     $File->{Templates}->{Error}->param(fatal_ip_error    => 1);
     $File->{Templates}->{Error}->param(fatal_ip_hostname => 1)
Received on Saturday, 12 September 2009 14:23:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:14 GMT