diff options
-rw-r--r-- | htdocs/config/validator.conf | 65 | ||||
-rwxr-xr-x | httpd/cgi-bin/check | 71 |
2 files changed, 97 insertions, 39 deletions
diff --git a/htdocs/config/validator.conf b/htdocs/config/validator.conf index 3f0f2f4..8dff9ee 100644 --- a/htdocs/config/validator.conf +++ b/htdocs/config/validator.conf @@ -1,26 +1,61 @@ # # Main Configuration File for the W3C Markup Validation Service. # -# $Id: validator.conf,v 1.13 2004-09-03 01:26:33 link Exp $ +# $Id: validator.conf,v 1.14 2004-09-04 21:06:16 link Exp $ # # See 'perldoc Config::General' for the syntax, and be aware that the # 'SplitPolicy' is 'equalsign', ie. keys and values are separated by '\s*=\s*'. # # +# Base Path for Markup Validator files. +# +# You MUST set these unless you use the default locations for the files. +# e.g. the config files in "/etc/w3c/" and everything else in +# "/usr/local/validator/". +# + +<Paths> + # + # Base path... (defaults to "/usr/local/validator"). + #Base = /usr/local/validator + + # + # Location of template files + Templates = $Base/share/templates/en_US + + <SGML> + # + # The SGML Library Path. + Library = $Base/htdocs/sgml-lib + + # + # The SGML Parser to use. Defaults to /usr/bin/onsgmls. + Parser = /usr/bin/onsgmls + </SGML> +</Paths> + +# # This controls whether the debugging options are allowed to be enabled. Allow Debug = yes # # This lets you permanently enable the debugging options. Can be overridden # with CGI options (unlike "Allow Debug" above). -Enable Debug = no +Enable Debug = no # # Whether private RFC1918 addresses are allowed. Allow Private IPs = no # +# Protocols the validator is allowed to use for retrieving documents. +# The default is to allow http and https. +<Protocols> + Allow = data,http,https +</Protocols> + +# # Email address of the maintainer of this service. Maintainer = www-validator@w3.org @@ -32,29 +67,27 @@ Home Page = http://validator.w3.org/ # Base URI for the Element Reference. Element Ref URI = http://www.htmlhelp.com/reference/html40/ -# -# The SGML Library Path. -SGML Library = /home/link/Work/w3.org/validator-HEAD/htdocs/sgml-lib -# -# The SGML Parser to use. Defaults to /usr/bin/onsgmls. -SGML Parser = /usr/bin/onsgmls - -# -# Location of template files -Template Path = /home/link/Work/w3.org/validator-HEAD/share/templates/en_US # # Mapping tables etc... +# +# +# Maps element names to URLs (cf. "Element Ref URI" above). <Elements> Include eref.cfg </Elements> +# +# Main document Type Registry; contains all information on the types +# of documents we support and how they are processed. <Types> Include types.conf </Types> +# +# Mapping of charset names to their IANA names and how iconv(3) knows them. <Charsets> Include charset.cfg </Charsets> @@ -65,17 +98,9 @@ Template Path = /home/link/Work/w3.org/validator-HEAD/share/templates/en_US Include type.cfg </Types> - # # Source for the "Tip of The Day" blurbs. <Tips> Include tips.cfg </Tips> - -# -# Protocols the validator is allowed to use for retrieving documents. -# The default is to allow http and https. -<Protocols> - Allow = data,http,https -</Protocols> diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index 8c73c45..cd9d6b8 100755 --- a/httpd/cgi-bin/check +++ b/httpd/cgi-bin/check @@ -9,7 +9,7 @@ # This source code is available under the license at: # http://www.w3.org/Consortium/Legal/copyright-software # -# $Id: check,v 1.333 2004-09-03 01:26:33 link Exp $ +# $Id: check,v 1.334 2004-09-04 21:06:17 link Exp $ # # Disable buffering on STDOUT! @@ -98,12 +98,17 @@ our $HAVE_SOAP_LITE; # 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', + my %config_opts = ( + -ConfigFile => ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'), -MergeDuplicateOptions => TRUE, -MergeDuplicateBlocks => TRUE, -SplitPolicy => 'equalsign', @@ -113,10 +118,12 @@ BEGIN { -AutoLaunder => TRUE, -AutoTrue => TRUE, -DefaultConfig => { - Protocols => {Allow => 'http,https'}, - 'SGML Parser' => '/usr/bin/onsgmls', - 'Template Path' => '/usr/local/validator/share/templates/en_US', - }, + Protocols => {Allow => 'http,https'}, + Paths => { + Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'), + SGML => {Parser => '/usr/bin/onsgmls'}, + }, + }, ); my %cfg = Config::General->new(%config_opts)->getall(); $CFG = \%cfg; @@ -124,13 +131,37 @@ BEGIN { if ($@) { die <<".EOF."; Could not read configuration. Set the W3C_VALIDATOR_CFG environment variable -or copy conf/* to /etc/w3c/, and make sure that the configuration file, as well -as all included files are readable by the web server user. The error was: -'$@' +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. + } + + # + # Check a filesystem path for existance and "readability". + sub pathcheck (@) { + my %paths = map {$_ => [-d $_, -r _]} @_; + my @_d = grep {not $paths{$_}->[0]} keys %paths; + my @_r = grep {not $paths{$_}->[1]} keys %paths; + return TRUE if (scalar(@_d) + scalar(@_r) == 0); + die <<".EOF." if scalar @_d; +Does not exist or is not a directory: @_d +.EOF. + die <<".EOF." if scalar @_r; +Directory not readable (permission denied): @_r .EOF. } # + # Check paths in config... + { + my @dirs = (); + push @dirs, $CFG->{Paths}->{Base}; + push @dirs, $CFG->{Paths}->{Templates}; + push @dirs, $CFG->{Paths}->{SGML}->{Library}; + &pathcheck(@dirs); + } + + # # Split allowed protocols into a list. if (my $allowed = delete($CFG->{Protocols}->{Allow})) { $CFG->{Protocols}->{Allow} = [ split(/\s*,\s*/, $allowed) ]; @@ -138,8 +169,8 @@ as all included files are readable by the web server user. The error was: # # Make sure onsgmls exists and is executable. - unless (-x $CFG->{'SGML Parser'}) { - die qq(Configured SGML Parser "$CFG->{'SGML Parser'}" not executable!\n); + unless (-x $CFG->{Paths}->{SGML}->{Parser}) { + die qq(Configured SGML Parser "$CFG->{Paths}->{SGML}->{Parser}" not executable!\n); } { # Make types config indexed by FPI. @@ -194,7 +225,7 @@ as all included files are readable by the web server user. The error was: # # Strings - $VERSION = q$Revision: 1.333 $; + $VERSION = q$Revision: 1.334 $; $VERSION =~ s/Revision: ([\d\.]+) /$1/; # @@ -270,11 +301,11 @@ $File->{'Other Namespaces'} = []; # Other (non-root) Namespaces. ############################################################################### my $T = HTML::Template->new( - filename => File::Spec->catfile($CFG->{'Template Path'}, 'result.tmpl'), + filename => File::Spec->catfile($CFG->{Paths}->{Templates}, 'result.tmpl'), die_on_bad_params => FALSE, ); my $E = HTML::Template->new( - filename => File::Spec->catfile($CFG->{'Template Path'}, 'fatal-error.tmpl'), + filename => File::Spec->catfile($CFG->{Paths}->{Templates}, 'fatal-error.tmpl'), die_on_bad_params => FALSE, ); @@ -599,7 +630,7 @@ sub parse (\$) { # # By default, use SGML catalog file and SGML Declaration. - my $catalog = File::Spec->catfile($CFG->{'SGML Library'}, 'sgml.soc'); + my $catalog = File::Spec->catfile($CFG->{Paths}->{SGML}->{Library}, 'sgml.soc'); my @spopt = qw( -R -wvalid @@ -610,7 +641,7 @@ sub parse (\$) { # # Switch to XML semantics if file is XML. if (&is_xml($File)) { - $catalog = File::Spec->catfile($CFG->{'SGML Library'}, 'xml.soc'); + $catalog = File::Spec->catfile($CFG->{Paths}->{SGML}->{Library}, 'xml.soc'); push(@spopt, '-wxml'); &add_warning($File, 'note', 'Note:', <<".EOF."); The Validator XML support has @@ -644,11 +675,13 @@ sub parse (\$) { # # Tell onsgmls about the SGML Library. - $ENV{SGML_SEARCH_PATH} = $CFG->{'SGML Library'}; + $ENV{SGML_SEARCH_PATH} = $CFG->{Paths}->{SGML}->{Library}; # # Set the command to execute. - my @cmd = ($CFG->{'SGML Parser'}, '-n', '-c', $catalog, @spopt); + my @cmd = ($CFG->{Paths}->{SGML}->{Parser}, '-n', '-c', $catalog, @spopt); + + # # Set debug info for HTML report. |