- From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 02 Mar 2009 18:41:16 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv31965/httpd/cgi-bin
Modified Files:
check
Log Message:
fix logic/flow for handling illegal attribute/element
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.650
retrieving revision 1.651
diff -u -d -r1.650 -r1.651
--- check 2 Mar 2009 18:32:36 -0000 1.650
+++ check 2 Mar 2009 18:41:14 -0000 1.651
@@ -3004,8 +3004,15 @@
{
my $bogus_elt_attr = $err->{msg};
$bogus_elt_attr =~ s/.*"(.+)".*/$1/;
+ if ($err->{num} eq '108') {
+ $err->{msg} = "Attribute \"".$bogus_elt_attr."\" is not a valid attribute";
+ }
- if ( (
+ if((exists $self->{CFG}->{Attributes}->{lc($bogus_elt_attr)}) and (lc($bogus_elt_attr) eq $bogus_elt_attr) and ($err->{num} eq '108')) {
+ # attribute not available in this context.
+ $err->{msg} = 'Attribute "'.$bogus_elt_attr.'" exists, but can not be used for this element.';
+ }
+ elsif ( (
((exists $self->{CFG}->{Attributes}->{lc($bogus_elt_attr)}) and ($err->{num} eq '108'))
or
((exists $self->{CFG}->{Elements}->{lc($bogus_elt_attr)}) and ($err->{num} eq '76'))
@@ -3015,11 +3022,7 @@
{
$err->{msg} .= '. Did you mean "'.lc($bogus_elt_attr).'"?';
}
- elsif((lc($bogus_elt_attr) eq $bogus_elt_attr) and ($err->{num} eq '108')) {
- # attribute not available in this context.
- $err->{msg} = 'Attribute '.$bogus_elt_attr.' exists, but can not be used for this element.';
- }
- else {
+ else { #fuzzy-match and suggest alternatives
my @matches;
if ($err->{num} eq '108') {
@matches = String::Approx::amatch($bogus_elt_attr, ["3i"], keys %{$self->{CFG}->{Attributes}});
Received on Monday, 2 March 2009 18:41:26 UTC