summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorot <ot@localhost>2009-02-17 14:10:41 +0000
committerot <ot@localhost>2009-02-17 14:10:41 +0000
commitc137f1f778405d1db72828c3f28791d6ccd27505 (patch)
treeb09637c7883dd2ce1750b384556fa0d0dcbe0bf5
parent437cd0c641650ddd2843accc307a05a42bdd7446 (diff)
downloadmarkup-validator-c137f1f778405d1db72828c3f28791d6ccd27505.zip
markup-validator-c137f1f778405d1db72828c3f28791d6ccd27505.tar.gz
markup-validator-c137f1f778405d1db72828c3f28791d6ccd27505.tar.bz2
fixing bug in fuzzy matching routine that would match with list of attributes even when an unknown element would be found
-rwxr-xr-xhttpd/cgi-bin/check17
1 files changed, 13 insertions, 4 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index 16e6f32..486dfba 100755
--- a/httpd/cgi-bin/check
+++ b/httpd/cgi-bin/check
@@ -14,7 +14,7 @@
# This source code is available under the license at:
# http://www.w3.org/Consortium/Legal/copyright-software
#
-# $Id: check,v 1.648 2009-02-16 14:11:42 ot Exp $
+# $Id: check,v 1.649 2009-02-17 14:10:41 ot Exp $
#
# Disable buffering on STDOUT!
$| = 1;
@@ -198,7 +198,7 @@ Directory not readable (permission denied): @_r
#
# Strings
- $VERSION = q$Revision: 1.648 $;
+ $VERSION = q$Revision: 1.649 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -3015,11 +3015,20 @@ sub error
}
else {
my @matches;
- @matches = String::Approx::amatch($bogus_elt_attr, ["3i"], keys %{$self->{CFG}->{Attributes}});
+ if ($err->{num} eq '108') {
+ @matches = String::Approx::amatch($bogus_elt_attr, ["3i"], keys %{$self->{CFG}->{Attributes}});
+ }
+ elsif ($err->{num} eq '76') {
+ @matches = String::Approx::amatch($bogus_elt_attr, ["3i"], keys %{$self->{CFG}->{Elements}});
+ }
if (@matches){
my %distances;
- @distances{@matches} = map { abs } String::Approx::adistr(lc($bogus_elt_attr), @matches);
+ @distances{@matches} = map { abs } String::Approx::adist(lc($bogus_elt_attr), @matches);
my @matches_sorted = sort { $distances{$a} <=> $distances{$b} } @matches;
+ # a bit of printf debugging can't hurt
+ # foreach my $match (@matches_sorted) {
+ # $err->{msg} .= '<br /> match '.$match.': '.$distances{$match};
+ # }
if (@matches > 1){
$err->{msg} .= '. Maybe you meant "'.$matches_sorted[0].'" or "'.$matches_sorted[1].'"?';